stemkev
(kevin.stembridge.dev)
February 2, 2014, 8:29pm
1
I have a multi-project build and projectB needs to reference the test jar produced projectA.
I have the following in projectA’s build script to publish the test jar.
task jarTests(type: Jar, dependsOn: testClasses) {
classifier = 'tests'
from sourceSets.test.output
}
artifacts {
archives jarTests
}
What do I need to put in projectB’s build script in order to add projectA’s test jar to its testCompile configuration?
stigkj
(Stig Kleppe-Jørgensen)
February 2, 2014, 10:41pm
2
testCompile project(path: ‘:projectA’, configuration: ‘tests’)
quidryan
(Justin Ryan)
February 3, 2014, 3:30am
3
In Stig’s example, you would need a the tests configuration to extends the testRuntime configuration. And would have to have to the add the archive to that confs. E.g.
task jarTests(type: Jar, dependsOn: testClasses) {
classifier = 'tests'
from sourceSets.test.output
}
configurations {
tests {
dependsOn testCompile
}
}
artifacts {
tests jarTests
}
I tried to encapsulate this in the nebula-test-jar plugin: https://github.com/nebula-plugins/nebula-publishing-plugin/blob/master/src/main/groovy/nebula/plugin/publishing/NebulaTestJarPlugin.groovy
stemkev
(kevin.stembridge.dev)
February 15, 2014, 3:49pm
4
Thanks Stig and Justin.
Justin, the description in your answer was correct but the snippet wasn’t quite right. Here is what I ended up with based on your example:
task jarTests(type: Jar, dependsOn: testClasses) {
classifier = 'tests'
from sourceSets.test.output
}
configurations {
tests {
extendsFrom testRuntime
}
}
artifacts {
tests jarTests
}