Hi. First of all, sorry for the lengthy post, but I strived to be as detailed as possible. I have a two module build with api and core modules. core depends on api - everything works fine in this regard. Now I would like to add an integrationTest task to impl with the following characteristics: 1. check task depends on it, but it runs test task first (here is my problem) 2. I want to be able to only call test, or only integrationTest 3. integrationTest should have the following classpath: runtime (the jars for compile and runtime, and all jars from api module, and the api module itself, and all sourceSets.main classes and resources compiled for impl (here is another problem) 4. there is a sharedTest configuration where I define the jars to use by both test and integrationTest, and it might have common test classes (not yet configured and irrelevant) - this works nice as the test task already works with this layout
I can’t make #2 and $3 work. Here are the relevant excerpts from my build files:
build.gradle in the root project:
subprojects {
apply plugin: 'groovy'
repositories {
mavenCentral()
}
sourceSets {
sharedTest
integrationTest
}
configurations {
all {
resolutionStrategy {
failOnVersionConflict()
}
exclude group: 'asm', module: 'asm'
exclude group: 'junit', module: 'junit'
}
sharedTestRuntime.extendsFrom sharedTestCompile
testCompile.extendsFrom sharedTestCompile
testRuntime.extendsFrom sharedTestRuntime
integrationTestCompile.extendsFrom compile, sharedTestCompile
integrationTestRuntime.extendsFrom runtime, integrationTestCompile, sharedTestRuntime
}
dependencies {
groovy group: 'org.codehaus.groovy', name: 'groovy', version: '2.0.0'
sharedTestCompile group: 'org.testng', name: 'testng', version: '6.5.2'
sharedTestCompile group: 'org.hamcrest', name: 'hamcrest-core', version: '1.2.1'
sharedTestCompile group: 'org.hamcrest', name: 'hamcrest-library', version: '1.2.1'
testCompile group: 'org.mockito', name: 'mockito-core', version: '1.9.0', {
exclude group: 'org.hamcrest', module: 'hamcrest-core'
}
}
task integrationTest(type: Test) {
description = 'Runs the integration tests.'
group = 'verification'
dependsOn integrationTestClasses
testClassesDir = sourceSets.integrationTest.output.classesDir
classpath = sourceSets.integrationTest.runtimeClasspath + sourceSets.main.runtimeClasspath
// if (project.name == 'core') classpath.each { println it } // uncomment to see what is on the classpath - not enough
}
tasks.withType(Test) {
useTestNG()
testLogging.showStandardStreams = true
}
check {
dependsOn = [test, integrationTest]
}
}
and build.gradle in module core:
dependencies {
def neo4jVersion = '1.8.M06'
compile project(':api')
compile group: 'org.neo4j', name: 'neo4j-kernel', version: neo4jVersion
compile group: 'org.neo4j', name: 'neo4j-lucene-index', version: neo4jVersion
integrationTestCompile group: 'org.neo4j', name: 'neo4j-kernel', version: neo4jVersion, classifier: 'tests'
}
There are the following problems: 1. gradle check -m :api:compileJava SKIPPED :api:compileGroovy SKIPPED :api:processResources SKIPPED :api:classes SKIPPED :api:jar SKIPPED :core:compileJava SKIPPED :core:compileGroovy SKIPPED :core:processResources SKIPPED :core:classes SKIPPED :core:compileIntegrationTestJava SKIPPED :core:compileIntegrationTestGroovy SKIPPED :core:processIntegrationTestResources SKIPPED :core:integrationTestClasses SKIPPED :core:integrationTest SKIPPED :core:compileTestJava SKIPPED :core:compileTestGroovy SKIPPED :core:processTestResources SKIPPED :core:testClasses SKIPPED :core:test SKIPPED :core:check SKIPPED
Gradle tries to call compileIntegrationTest before test, even though check dependsOn = [test, integrationTest] - seems like Gradle is not preserving the ordering I set? (Yes, I tried it without -m to make sure the above is really the task sequence I get in the end.).
- gradle integrationTest :api:compileJava UP-TO-DATE :api:compileGroovy UP-TO-DATE :api:processResources UP-TO-DATE :api:classes UP-TO-DATE :api:jar UP-TO-DATE :core:compileJava UP-TO-DATE :core:compileGroovy UP-TO-DATE :core:processResources UP-TO-DATE :core:classes UP-TO-DATE :core:compileIntegrationTestJava UP-TO-DATE :core:compileIntegrationTestGroovy startup failed: /home/wujek/projects/gradletest/core/src/integrationTest/groovy/test/neo4j/Neo4jNetworkTest.groovy: 34: unable to resolve class Neo4jNetwork
and a bunch of other compilation failures. The problem is: neither api.jar nor src/main/java nor src/main/groovy are on the classpath. When I uncomment the line in the integrationTest above to output the classpath, I get this:
/home/wujek/projects/gradletest/core/build/classes/integrationTest /home/wujek/projects/gradletest/core/build/resources/integrationTest /home/wujek/.gradle/caches/artifacts-13/filestore/org.codehaus.groovy/groovy/2.0.0/jar/e83becc219b228e3d0df011cee7c20d7406e9cbe/groovy-2.0.0.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.testng/testng/6.5.2/jar/5069d2e72356ed87645c5fc3622b0bbb5e0667c9/testng-6.5.2.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.hamcrest/hamcrest-core/1.2.1/jar/e89706d7a0641823a7d3f20c2b96272f622d155c/hamcrest-core-1.2.1.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.hamcrest/hamcrest-library/1.2.1/jar/b54856422a8b58f0fe61b3a762d024f5e6d0556d/hamcrest-library-1.2.1.jar /home/wujek/.gradle/caches/artifacts-13/filestore/antlr/antlr/2.7.7/jar/83cd2cd674a217ade95a4bb83a8a14f351f48bd0/antlr-2.7.7.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.ow2.asm/asm/4.0/jar/659add6efc75a4715d738e73f07505246edf4d66/asm-4.0.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.ow2.asm/asm-tree/4.0/jar/67bd266cd17adcee486b76952ece4cc85fe248b8/asm-tree-4.0.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.ow2.asm/asm-commons/4.0/jar/a839ec6737d2b5ba7d1878e1a596b8f58aa545d9/asm-commons-4.0.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.ow2.asm/asm-util/4.0/jar/d7a65f54cda284f9706a750c23d64830bb740c39/asm-util-4.0.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.ow2.asm/asm-analysis/4.0/jar/1c45d52b6f6c638db13cf3ac12adeb56b254cdd7/asm-analysis-4.0.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.beanshell/bsh/2.0b4/jar/a05f0a0feefa8d8467ac80e16e7de071489f0d9c/bsh-2.0b4.jar /home/wujek/.gradle/caches/artifacts-13/filestore/com.beust/jcommander/1.12/jar/7409692b48022f9eca7445861defbcdb9ee3c2a8/jcommander-1.12.jar /home/wujek/.gradle/caches/artifacts-13/filestore/org.yaml/snakeyaml/1.6/jar/a1e23e31c424d566ee27382e373d73a28fdabd88/snakeyaml-1.6.jar /home/wujek/projects/gradletest/core/build/classes/main /home/wujek/projects/gradletest/core/build/resources/main
Neither api.jar, nor neo4j-kernel-test.jar are on the classpath (although neo4j actually is there in the end, as I don’t get any compilation errors for its classes). The core module main classes seem to be on the classpath, but I get compilation errors saying they are not available (in the previous snippet).
Could I get some help with these 2 problems? I am obviously misconfiguring the classpath for the integrationTest task, and the unordered / alphabetically sorted dependency list seems to be a gradle problem?
wujek