Multipul artifacts

I have a project that creates two jar files. One that contains the classes of the main sourceset and the other the classes of the test sourceset. I want to upload those artifacts to a maven repro. Then in another project I want to add an dependency on the jar with the test classes. Is this posible and if so, how to do this?

Hello Evert,

The easiest way is to add your test-jar to the archives configuration using the artifacts closure:

artifacts {
    archives testJar
}

In your definition of the testjar task ensure that you defined a classifier for the jar:

task testJar(type:Jar){
    classifier 'tests'
 from sourceSets.test.classes
}

Running the uploadArchives task now should upload two artifacts to your remote repo.

To reference the testjar in another project you just need to declare it in the dependency section:

dependencies{
     testCompile "org.acme:yourProject:1.0-SNAPSHOT:tests"
  }

regards, René