I need to deploy 4 jars from each of my projects: the binary and source jars from the “main” sourceSet, and the binary and source jars from the “test” set. I currently have this set up as follows:
task jarTests(type: Jar, dependsOn: testClasses) {
appendix = ‘tests’
from sourceSets.test.output
}
task jarSources(type: Jar) {
classifier = ‘sources’
from sourceSets.main.allSource
}
task jarTestSources(type: Jar) {
classifier = ‘sources’
appendix = ‘tests’
from sourceSets.test.allSource
}
artifacts {
archives jarTests
archives jarSources
archives jarTestSources
}
My Ivy artifactPattern is ‘…/[organization]/[module]/[revision]/[artifact]-revision.[ext]’
Let’s assume the organization is Foo, the project is MyProject, and the version is 1.0.1. When I run “gradle upload” from the myproject directory, Gradle creates: *
…/foo/myproject/myproject-1.0.1.jar *
…/foo/myproject/myproject-1.0.1-sources.jar *
…/foo/myproject/myproject-tests-1.0.1.jar *
…/foo/myproject/myproject-tests-1.0.1-sources.jar
Unfortunately, when I try to use the myproject-tests artifact from another project, Ivy can’t find it (since it’s not in foo/myproject-tests, it’s in foo/myproject). My dependencies line looks like:
testCompile group: ‘foo’, name: ‘foo-tests’, version: ‘1.0.1’
I can sort of fix it by changing the Ivy pattern from …/[organization]/[module]/… to …/[organization]/[artifact]/…, but that just seems hackish (not to mention messing up ivy.xml).
What is the right way to do this?