Project dependencies have changed since 1.4 for providedCompile project('path' : ':project', 'configuration' : 'tomcatOnly')

providedCompile project(‘path’ : ‘:project’, ‘configuration’ : ‘tomcatOnly’)

this works for bringing in a dependent war in gradle 1.4

It no longer works in gradle 1.5+

here is configuration from the subproject

configurations {tomcatOnly
 }
  task tomcatCommonJar(type: Jar) {
     archiveName = "sams-global-${version}.jar"
     from sourceSets.main.output
       include('com/sams/common/tomcat/**')
 }
   jar.dependsOn 'tomcatCommonJar'
  artifacts {
tomcatOnly tomcatCommonJar
}

here is the root project

apply plugin: 'java'
apply plugin: 'war'
apply plugin: 'maven'
apply plugin: 'eclipse'
apply plugin: 'application'
  dependencies {
  compile (project (':SAMS-COMMON')) {
       transitive = false
    }
 compile 'asm:asm:3.1'
 compile 'com.google.guava:guava:13.0.1'
 compile 'com.google.code.gson:gson:2.2.2'
 compile 'com.sun.jersey:jersey-bundle:1.16'
 compile 'com.sun.jersey.contribs.jersey-oauth:oauth-client:1.16'
 compile 'com.sun.jersey.contribs.jersey-oauth:oauth-signature:1.16'
 compile 'bmc:arapi7604_build002:7.6.04.sp2'
 compile 'com.codahale.metrics:metrics-core:3.0.1'
 compile 'com.codahale.metrics:metrics-json:3.0.1'
 compile 'com.codahale.metrics:metrics-servlets:3.0.1'
 compile 'com.fasterxml.jackson.core:jackson-databind:2.2.3'
 providedCompile project(path:':SAMS-COMMON', configuration: 'tomcatOnly')
       }

the root project has compile errors that are a result of the providedCompile statement not bringing in the dependent jar. What has changed between gradle 1.4 and 1.5+ because this works fine in 1.4?

Looks good to me. Did you do a clean build after switching Gradle versions?

I did a clean and made sure the jars were rebuilt. No difference in the behavior. I looked at the log files using debug and I can see that in 1.4 the dependent jar is brought in, but I am now using 1.8 and there is no sign of the dependent jar file. The only relevant lines I see in the 1.8 debug log is this

12:59:38.922 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting dependency sams:ConcurrentTaskEngine:unspecified(compile) -> com.sams:SAMS-COMMON:8.6.8(dependency: com.sams#SAMS-COMMON;8.6.8 {providedCompile=[tomcatOnly]}) 12:59:38.967 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration com.sams:SAMS-COMMON:8.6.8(tomcatOnly).

whereas in 1.4 I see

14:11:38.977 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting dependency sams#ConcurrentTaskEngine;unspecified(compile) -> com.sams#SAMS-COMMON;8.6.8([tomcatOnly])

14:11:40.639 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting dependency sams#ConcurrentTaskEngine;unspecified(providedRuntime) -> com.sams#SAMS-COMMON;8.6.8([tomcatOnly])

14:11:40.710 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Visiting configuration com.sams#SAMS-COMMON;8.6.8(tomcatOnly).

14:11:40.713 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.DependencyGraphBuilder] Attaching com.sams#SAMS-COMMON;8.6.8(tomcatOnly) to its parents.

I can also see the dependent jar being included in 1.4 and not in the 1.8 log file.

Something has changed semantically, I’m just not able to see it. Also, this issue starts with 1.5 and is consistent through 1.8.

Which build command are you running, and from which directory?

Here is a complete example. Running ‘gradle build’ succeeds with 1.5 and 1.6, but fails with 1.7, 1.8, or master. Raised GRADLE-2909. Thanks for reporting.

‘settings.gradle’:

include "foo", "bar"

‘foo/build.gradle’:

apply plugin: 'java'
  dependencies {
        compile project(path:':bar', configuration: 'other')
        }

‘bar/build.gradle’:

apply plugin: "java"
  configurations {
    other
}
  task otherJar(type: Jar) {
    archiveName = "sams-global-${version}.jar" // build succeeds if this line is commented out
    from sourceSets.main.output
      include('bar/**')
 }
   jar {
     include("baz/**") // build succeeds if this line is commented out
}
  artifacts {
    other otherJar
}

‘foo/src/main/java/Main.java’:

public class Main {
    bar.Bar bbb;
}

‘bar/src/main/java/bar/Bar.java’:

package bar;
  public class Bar {}

Thanks for giving this a try. I was going to do the same thing to identify the issue, but I’m glad you were able to find it too. Will this be fixed in 1.9 ? I guess I will need to stay at an earlier version for now and I’m surprised no one else has bumped into this.

thanks again for the great support.