Gradle ignoring 'classifier' for 'tests' jar?

Hi. I am having problems with gradle ignoring my classifier: ‘tests’. Here is the build script:

apply plugin: ‘java’

repositories {

mavenCentral() } dependencies {

//compile group: ‘org.neo4j’, name: ‘neo4j-kernel’, version: ‘1.8.M05’

testCompile group: ‘org.neo4j’, name: ‘neo4j-kernel’, version: ‘1.8.M05’, classifier: ‘tests’ }

And here the output of the ‘dependencies’ task (trimmed to test-related): testCompile - Classpath for compiling the test sources. — org.neo4j:neo4j-kernel:1.8.M05 [default]

— org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1 [compile,master,runtime]

testRuntime - Classpath for running the compiled test classes. — org.neo4j:neo4j-kernel:1.8.M05 [default]

— org.apache.geronimo.specs:geronimo-jta_1.1_spec:1.1.1 [compile,master,runtime]

As you see, it depends on the neo4j artifact without the classifier, which is wrong in this case. The jar file in maven central exists ;d and has this URL: http://search.maven.org/remotecontent?filepath=org/neo4j/neo4j-kernel/1.8.M05/neo4j-kernel-1.8.M05-tests.jar

I am using gradle 1.0.

How to express a testCompile dependency on a test jar?

wujek

I think it’s just a(nother) limitation of the ‘gradle dependencies’ output. If you print out the files on the ‘testCompile’ configuration, you’ll see that ‘neo4j-kernel-1.8.M05-tests.jar’ is present.

PS: Please use HTML code tags for all code and other output.

Sorry about the code tags.

Ok, I just ignored the errors of my IDEA and wrote the code, and it does compile and run fine, thanks for the tip. Should a bug be issued for that? This should probably be fixed, as it is really confusing. Now it’s time to ask the IntelliJ guys why IDEA is not comfortable with classifiers - maybe they are using the output of dependencies somehow?

Not sure. I recommend to file an IDEA issue. I’ve filed GRADLE-2381 for the ‘gradle dependencies’ issue.

I filed an issue for IDEA. Will see what they say. Thanks for your help.

Hi to all, I have a problem with the same dependency (neo4j-kernel classified tests).

testCompile group: 'org.neo4j', name: 'neo4j-kernel', version: '2.0.1', classifier: 'tests'

but i receive the following error message:

* What went wrong:
Could not resolve all dependencies for configuration ':reactive-api:testCompile'.
> Could not download artifact 'org.neo4j:neo4j-kernel:2.0.1:neo4j-kernel-tests.jar'
   > Artifact 'org.neo4j:neo4j-kernel:2.0.1:neo4j-kernel-tests.jar' not found.

I use Gradle 1.11 and JDK 1.7

Thanks in advance --Marino

Works for me. Did you declare a repository?

Hi Peter, thanks for your reply. I declare the repository into root project:

/**
     * ..:: subprojects ::..
     */
    subprojects {
        apply plugin: 'groovy'
        apply plugin: 'scct'
        apply plugin: 'sonar'
          sourceCompatibility = 1.7
        targetCompatibility = 1.7
          repositories {
            mavenLocal()
            mavenCentral()
              maven { url "http://oss.sonatype.org/content/repositories/releases" }
         maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
         maven { url "http://repo.anormcypher.org/" }
         maven { url "http://repo.typesafe.com/typesafe/releases/" }
         maven { url "http://m2.neo4j.org/content/repositories/releases/" }
         maven { url 'http://conjars.org/repo/' }
         maven { url 'http://clojars.org/repo/' }
         maven { url 'http://maven.twttr.com/' }
        }
  ....

And, in a subproject I use the dependency (all other Neo4j dependencies work correctly):

configurations {
     testAgent
     //testAgent.extendsFrom testRuntime
       provided
     testProvided.extendsFrom provided
    }
      sourceSets {
     main {
      compileClasspath += configurations.provided
     }
    }
      idea {
     module {
      scopes.PROVIDED.plus += configurations.provided
     }
    }
      compileScala {
     scalaCompileOptions.with {
      additionalParameters = [ "-Ywarn-dead-code", "-target:jvm-1.7" ]
     }
    }
      compileTestScala {
     scalaCompileOptions.with {
      additionalParameters = [ "-Yrangepos", "-Ywarn-dead-code" ]
     }
    }
      /**
     * ..:: dependencies ::..
     */
    dependencies {
          compile "com.typesafe.akka:akka-zeromq_2.10:$versions.akka"
        compile group: 'org.codehaus.groovy', name:'groovy-all', version: '2.+'
       provided "org.neo4j:neo4j-kernel:2.0.1"
          testCompile 'junit:junit:4.11',
//
            'org.testng:testng:6.4',
                    'org.scalacheck:scalacheck_2.10:1.11.3',
                    'org.scalamock:scalamock_2.10:3.0.1',
                    'org.scalatest:scalatest_2.10:2.1.0',
                    "com.typesafe.akka:akka-testkit_2.10:$versions.akka"
          testCompile group: 'org.neo4j', name: 'neo4j-kernel', version: '2.0.1', classifier: 'tests'
                   /* Akka profiling configuration */
        testRuntime "com.typesafe.atmos:atmos-event_2.10:$versions.atmos",
                    "com.typesafe.atmos:atmos-trace_2.10:$versions.atmos",
                    "com.typesafe.atmos:trace-akka-2.2.1_2.10:$versions.atmos"
                 /* Akka profiling configuration */
        testAgent "org.aspectj:aspectjweaver:1.7.2"
    }

I recommend to try and reproduce this in a small self-contained build, to rule out that it’s some problem with your production build.

You’re right! I have tried a project from scratch and it works.

I have changed the default order:

mavenCentral()
            mavenLocal()

to:

mavenLocal()
            mavenCentral()

in my scratch project and so does not work. Ok, I reproduced the error, but it isn’t clear why.

I will read the documentation.

Sorry! Thanks for your attention.

Note that the only good reason for using ‘mavenLocal’ is for exchanging artifacts with local Maven builds. Otherwise it only has drawbacks (slower dependency resolution, less repeatable builds). That said, the order shouldn’t matter, and recent Gradle versions have improved in this regard. Perhaps check which neo4j-kernel files are in the local repository (POM, main Jar, classifier Jar, etc.).

Thanks, I will investigate.