Gradle classifiers

Hi folks,

I have the following configuration:

//...
 configurations {
       tests
       published.extendsFrom tests, archives
   }
       dependencies {
       compile compileDependencies
       testCompile testDependencies
       clover 'com.cenqua.clover:clover:3.1.2'
   }
   task testArchive(type: Jar, dependsOn: testClasses) {
       classifier = "tests"
       from sourceSets.test.output
   }
   artifacts {
       archives testArchive
       tests testArchive
   }
     install {
       configuration = configurations.published
   }
}

for a project:

group: com.mytest
 artifact: test-project
 version: 1.0.0-SNAPSHOT

Running “gradle clean install” generates the following artifacts in my repository:

~/.m2/repository/com/mytest/test-project/1.0.0-SNAPSHOT/test-project-1.0.0-SNAPSHOT.jar
 ~/.m2/repository/com/mytest/test-project/1.0.0-SNAPSHOT/test-project-1.0.0-SNAPSHOT-tests.jar

which looks correct.

When I declare a dependency on those coordinates from another project as follows:

testCompile group: "com.mytest", name: "test-project", version:"1.0.0-SNAPSHOT", classifier: "tests"

I get the following output:

Could not resolve all dependencies for configuration ':otherproject'.
 Artifact 'com.mytest:test-project:1.0.0-SNAPSHOT:tests@jar' not found.

I notice that the Maven metadata for test-project doesn’t contain all of the same data that it does when the project is

built by Maven, but even builing and deploying test-project doesn’t make fix the problem. I’ve tried other formats like:

testCompile "com.mytest:test-project:1.0.0-SNAPSHOT:tests"

to no avail. Am I missing something obvious?

I’m running Gradle 1.4 on JDK 1.7 on Mac OSX

Thanks!

Joe

Hi Joe,

Dependencies between projects are different in Gradle. The following previous post should help you out:

http://forums.gradle.org/gradle/topics/how_do_i_declare_a_dependency_on_a_modules_test_code

I’m having a similar issue.

testCompile group: ‘org.apache.sling’, name: ‘org.apache.sling.launchpad’, version:‘7-SNAPSHOT’, classifier:‘standalone’

gives this error:

Could not find org.apache.sling:org.apache.sling.launchpad:7-SNAPSHOT.

Required by:

com.snidigital.wcm.platform.test:wcm-platform-test-sling-example:1.0-SNAPSHOT

Although I have verified that the file ‘org.apache.sling.launchpad-7-SNAPSHOT-standalone.jar’ exists in my local m2 repository at directory \org\apache\sling\org.apache.sling.launchpad\7-SNAPSHOT.

Make sure that you have a ‘mavenLocal()’ repository declared. If that doesn’t help, try with the latest Gradle version, as handling of Maven local has recently been improved. I don’t think your problem is caused by the classifier.

Yea, I had mavenLocal() declared in my repositories, but it wasn’t working. I had to actually include the file path to my local repo to get it to work. But yea, it wasn’t related to the classifier.