First posted here: http://stackoverflow.com/questions/19081423/attaching-a-source-dependency-to-a-dependency-with-classifiers
I have this dependency:
testCompile group:"org.apache.mrunit", name:"mrunit", version:"1.+", classifier:'hadoop2'
I’m also using the ‘eclipse’ plugin, but that dependency isn’t getting its sources attached. The sources are there in Maven Central, hiding under the “sources” classifier, so I tried adding this:
testCompile group:"org.apache.mrunit", name:"mrunit", version:"1.+", classifier:'sources'
But that didn’t solve my problem.
It’d be nice to have a way to specify the source dependency for a code dependency.
I agree. There should be a way to model this explicitly. Raised GRADLE-2911.
I am not able to get sources for my Ivy dependencies in Eclipse, which greatly diminishes the value of using Gradle to manage the project. Any guess on when this issue will this be addressed?
I think it should already work with recent Gradle versions (e.g. 1.12). If not, please explain your setup in detail.
// List the repositories we use for dependencies
repositories {
// Include project JARs
flatDir { dirs 'lib', 'libs' }
mavenCentral()
}
// List all Java-library dependencies
dependencies {
compile group: 'org.apache', name:'commons-math', version: '2.2'
compile group: 'com.google.common', name:'guava', version: '17.0'
testCompile group: 'junit', name:'junit', version: '4.11'
}
What’s that? I don’t see an Ivy repository here.
Sorry, it’s a private Ivy repository. Not sure if I’m allowed to give the URL. Also, we use a proxy to access it.
It’s OK if you show everything but the URL. Also, I’d need to know the names/paths of your Javadoc/sources artifacts (compared to the main artifacts), and if/how you represent them in the ivy.xml. If you follow the maven conventions (e.g. ‘foo.jar’, ‘foo-sources.jar’, ‘foo-javadoc.jar’, I think it should work out-of-the-box with recent Gradle versions. Last but not least, I’d need to know how you are integrating with Eclipse.
Thank you very much for helping me through this. Here is what I have (that is pertinent to this discussion), minus the actual URLs. I have no ivy.xml file. I had thought it would not be needed, since I’m using Gradle.
// Proxy configuration
System.properties['http.proxyHost'] = '...'
System.properties['http.proxyPort'] = '...'
// List the repositories we use for dependencies
repositories {
// Include project JARs
flatDir { dirs 'lib', 'libs' }
mavenCentral()
ivy {
name 'our-ivy-repo'
url '<our-ivy-repo>' // URL to our Ivy repository
credentials { .. }
layout 'pattern', { artifact '[organisation]/[module]/[revision]/[type]s/[artifact].[ext]' }
}
}
// List all Java-library dependencies
dependencies {
compile group: 'blah.foo.gee', name:'gee-common', version: '1.2.22'
}
You need to check which artifacts your Ivy repository contains for the ‘gee-common:1.2.22’ module. You should find at least an ivy.xml, main Jar, javadoc Jar, and sources Jar. Otherwise, there will be no way for Gradle to resolve these Jars. The next question to answer is whether and how the ivy.xml mentions the javadoc and sources Jars, and what the repository paths of these Jars is relative to the main Jar. The next question to answer is how exactly you are integrating with Eclipse.
This is what we have in the Ivy repository for the module I’m requesting: ivy.xml jars/ javadocs/ sources/
This doesn’t answer my questions.
Sorry, I will when I have a chance, thanks!
By the way, I’m just using the Gradle Eclipse plugin to generate the Eclipse project files.