0

I have a web project that produces a war. The war adds a jar (another project of mine posted on an external repo) as compile dependency. This jar has its own compile dependency, which is listed in the jar's pom file, as well as in the project's build script (this is a Gradle project). I would like to add the jar, as well as all of its own dependencies to my war's WEB-INF/lib folder. However, when I build the web project with Gradle, only the direct dependency is added, not the transitive ones.

Here is my web project's build script:

apply plugin: 'war'

repositories {     
    maven {url "http://repo-url"}
}

configurations.all {
    resolutionStrategy {
        cacheChangingModulesFor 0, 'seconds'
    }
}

dependencies {

    compile('com.company.group:artifact-name:1.0.0-SNAPSHOT') {
        changing = true
        transitive = true
    }
}

The com.company.group:artifact-name:1.0.0-SNAPSHOT does have its own POM, which lists the following dependency:

<dependency>
<groupId>us.codecraft</groupId>
<artifactId>xsoup</artifactId>
<version>0.2.0</version>
<scope>compile</scope>
</dependency>

Also, I've set cacheChangingModulesFor to 0 seconds, so that, effectively, the latest version of the SNAPSHOT jar is used every time.

The issue I am having is the 'us.codecraft:xsoup:0.2.0' artifact does not get included in the war, even though it is a transitive dependency of the war.

Any thoughts? Ask for more details, if anything is unclear.

Alek
  • 11
  • 4
  • There is likely something wrong with the build or repository contents, but from a distance it's hard to say what it is. `changing = true` is the default for snapshot dependencies. `transitive = true` is the default as well. If the transitive dependency makes it onto the `compile` configuration, it will also make it into the War. Perhaps check the output of `gradle dependencies --configuration compile`, and try to build with `--refresh-dependencies`. – Peter Niederwieser Mar 17 '14 at 22:43
  • Thanks again, Peter, for your support on the same issue at http://forums.gradle.org/ – Alek Mar 18 '14 at 15:21

1 Answers1

0

Ok, it turns out the problem lay in how Gradle resolved the snapshot artifact that my web project depended on. For some unknown reason, during some builds Gradle would not download the most up-to-date jar, which prevented it from downloading the transitive dependency that I needed in my war, because it was not a dependency of this older jar. Deleting the older snapshot jar from my repo fixed the issue.

Alek
  • 11
  • 4