1

I have a multiproject project with a core project ace2 that is dependened on; it has dependencies. I cannot seem to get the transitive dependencies to NOT to end up in the other project dataentry2, War's web-inf\lib directory even when using a provided configuration (yes I want the compile etc.. dependencies included). More than that, the dependencies marked testCompile / testRuntime also end up there. So it seems that I am missing something significant here.

The Master Project:

allprojects {
    apply plugin: 'java'
    apply plugin: 'eclipse-wtp'
    repositories {
        mavenCentral()
    }
}

project(':ace2') {
    configurations {
        provided
    }
    sourceSets {
        main.compileClasspath += configurations.provided
        test.compileClasspath += configurations.provided
        test.runtimeClasspath += configurations.provided
    }

    eclipse {
        classpath {
            //Add the provided configuration items to the Eclipse classpath
            plusConfigurations += [ configurations.provided ]
            //But don't export them
            noExportConfigurations += [ configurations.provided ]
        }
    }
    dependencies {
        compile('org.apache.poi:poi:3.11')
        compile('org.apache.poi:poi-ooxml:3.11')
        ....
        provided "org.apache.tomcat:tomcat-catalina:8.0.22"
        ....
        testCompile('junit:junit:4.12') 
    }
}

project(':dataentry2') {
    apply plugin: 'war'
    dependencies {
        compile project(':ace2')
    } 
}

I also tried everything that is inside the ace2 project out in ace2's own build.gradle.

If I can solve the 'noExportConfigurations should be honoured' problem then I could add testCompile, testRuntime to noExportConfigurations.

Any ideas why noExportConfigurations (or whatever it is) isnt working for me?

I am thinking that the location of the noExportConfigurations inside the :ace2 project is a different scope to the eclipse in another project. I tried to move this outside into the top-level of the master project's build.gradle but I don't know the syntax. The following DOES NOT WORK:

noExportConfigurations += [ project(':ace2').configurations.provided ]
  • OS: Windows 8
  • Java: 1.8
  • Gradle (command-line): 2.4
  • Eclipse: STS 3.6.4 (Eclipse 4.4.2)
  • Eclipse Gradle: Gradle IDE 3.6.4.201503050952-RELEASE org.springsource.ide.eclipse.gradle.feature.feature.group Pivotal Software, Inc.

Thanks Andreas for your comments. I have created a bare bones example at https://github.com/oehm-smith/gradleMultiprojectProvided that doesnt work for me.

Following your comments I did an Eclipse > Right-click in project area > Export > War choosing 'apir' web project and some destination file. This .war contains the tomcat and junit jars.

Could you try that out - there is a https://github.com/oehm-smith/gradleMultiprojectProvided/blob/master/README.md

Gradle Multiproject with a Provided scope / configuration. Running war from the CL creates a .war with no jars marked with 'provided'. But run Eclipse > Run On Tomcat and the provided and test jars go to webinf/lib.

1. cd master
2. gradle war
3. jar tvf ../apir/build/libs/apir.war | grep jar
4. Observe no 'tomcat' jars are in the war

Now do in Eclipse:

1. In Eclipse with Gradle plugin ... 
right-click > import > gradle and select the master project > build > select > ok
2. Choose 'apir' project > right-click > run on server > piviol tc Server is fine to use (or Tomcat)
3. Choose 'pivotal tc Server ' > Browse Deployment Location
4. Observe there ARE 'tomcat' jars in the wtpwebapps/apir/WEB-INF/lib directory
HankCa
  • 9,129
  • 8
  • 62
  • 83
  • what I can say so far is that looking to Gradle source code, the ```noExportConfiguration``` is resolved by matching other configurations by name which are added automatically or manually to ```plusConfigurations```. Furthermore the ```noExportConfiguration``` will be deprecated with v2.5. and by default nothing will be exported anymore. – Andreas Schmid May 25 '15 at 12:39
  • Hi HankCa, even if I call either ```gradle build``` or ```gradle eclipse``` and export 'war' via Eclipse, I have neither 'tomcat-catalina' nor 'junit' in the created 'war' file. My "WEB-INF/libs" contains ```WEB-INF/lib/ace2.jar```, ```WEB-INF/lib/poi-3.11.jar```, ```WEB-INF/lib/poi-ooxml-3.11.jar```, ```WEB-INF/lib/commons-codec-1.9.jar```, ```WEB-INF/lib/poi-ooxml-schemas-3.11.jar```, ```WEB-INF/lib/xmlbeans-2.6.0.jar```, ```WEB-INF/lib/stax-api-1.0.1.jar``` which looks good for me! – Andreas Schmid May 25 '15 at 12:41
  • This seems to be a bug - https://issues.gradle.org/browse/GRADLE-2396. A work-around is to deploy the web app to Eclipse > tomcat, browse the `deployment location / webapps / the_webapp / WEB-INF / lib` and delete the problematic jars. `tomcat*.jar` for me. – HankCa May 29 '15 at 06:27
  • I am sorry but I still can't reproduce your problem. But if you are sure (I am not) it is GRADLE-2396 it will be hopefully fixed with Gradle 2.5 (my patch is already awaiting). – Andreas Schmid May 30 '15 at 07:22
  • Oh yes, on my Eclipse it is deployed correctly without any ```tomcat*.jar```. And also all the eclipse artifacts are setup correctly (no export for ```tomcat*.jar``` etc., correct deployment assembly in all projects). – Andreas Schmid May 30 '15 at 07:30
  • Its a worry you can't reproduce it. I look forward to Gradle 2.5 to run the problem there. – HankCa Jun 02 '15 at 23:39
  • I am sorry, maybe anybody else ... – Andreas Schmid Jun 03 '15 at 17:21

0 Answers0