Dependencies missing from configurations - what am I doing wrong?

The Java plugin seems to be leaving out a few dependencies from various configurations. I first noticed this in a real project when my fatjar was missing some libraries but I can reproduce the problem in a new, empty directory.

Here are the full contents of my build.gradle:

apply plugin: "java" 

repositories {
    mavenCentral()
}

dependencies {
    compile 'org.apache.httpcomponents:httpcomponents-client:4.5',
            'org.apache.httpcomponents:httpcomponents-core:4.4.1',
            'cd.go.plugin:go-plugin-api:15.1.0',
            'com.google.code.gson:gson:2.3.1'

    testCompile 'junit:junit:4.10',
                'org.assertj:assertj-core:2.1.0',
                'org.powermock:powermock:1.6.2'
}

println("===============================")
println("compile dependencies:")
configurations.compile.each {
    println(it)
}
println("testCompile dependencies:")
configurations.testCompile.each {
    println(it)
}
println("===============================")

And here is the relevant command line output (slighty massaged for readability):

MacBook-Pro:temp $ gradle clean

===============================
compile dependencies:
~/.gradle/caches/modules-2/files-2.1/cd.go.plugin/go-plugin-api/15.1.0/…/go-plugin-api-15.1.0.jar
~/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.3.1/…/gson-2.3.1.jar

testCompile dependencies:
~/.gradle/caches/modules-2/files-2.1/cd.go.plugin/go-plugin-api/15.1.0/…/go-plugin-api-15.1.0.jar
~/.gradle/caches/modules-2/files-2.1/com.google.code.gson/gson/2.3.1/…/gson-2.3.1.jar
~/.gradle/caches/modules-2/files-2.1/junit/junit/4.10/…/junit-4.10.jar
~/.gradle/caches/modules-2/files-2.1/org.assertj/assertj-core/2.1.0/…/assertj-core-2.1.0.jar
~/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.1/…/hamcrest-core-1.1.jar

I would expect httpcomponents client and core to appear in the compile configuration and powermock to appear in the testCompile configuration.

When I run gradle dependencies , I see all the expected libraries in the right configuration classpaths, but gradle compileJava fails because of the missing dependencies (in the original project, not the empty directory). I can see the pom files for the missing libraries, but NOT the jar files, in ~/.gradle. I have tried blowing away ~/.gradle and ~/.m2, to no effect.

Am I using the Java plugin incorrectly? Any help would be appreciated.

I am using Gradle 2.4 with Java 7 on OSX Yosemite.

the http components client and httpcomponents core libraries are marked as packaging pom in the according pom file. That’s why gradle doesn’t resolve any artifacts for those libraries.

double check: https://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-core/4.4.1/httpcomponents-core-4.4.1.pom

and:
https://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-client/4.5/httpcomponents-client-4.5.pom

Thank you, that explains the contents of ~/.gradle.

But it doesn’t solve my main problem, which is that the libraries are not present in the Java plugin dependency configurations. I’m not even able to compile.

If you follow the guidance from @Rene and check those POM files, you’ll see a list of modules. Those submodules contain the artifacts that you might need to compile.

You’re likely looking for

'org.apache.httpcomponents:httpclient:4.5'
'org.apache.httpcomponents:httpcore:4.4.1'

instead of

'org.apache.httpcomponents:httpcomponents-client:4.5'
'org.apache.httpcomponents:httpcomponents-core:4.4.1'

You might also need an additional dependency if you are using something besides what is contained the main httpclient and httpcore JAR files.

1 Like

Ahhh. Thank you so much @Rene and @jjustinic.