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.