I have a case in which the sources for a dependency are not in jcenter/maven. How can I compile that dependency from a global repository but add the sources manually from a local file?
Specifically, this happens with Hibernate and the library antlr-2.7.7.jar. This library has no sources in jcenter or maven and I would like to add them manually. How can I do this?
And a command gradle --daemon cleanEclipse eclipse generates .classpath file as follows.
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<!-- eclipse task generates bin as output path, but it is changed to out -->
<classpathentry kind="output" path="out"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<!-- javadocpath attribute is not created by default, but it is added -->
<classpathentry
sourcepath="/Users/name/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/a6c3/junit-4.12-sources.jar"
kind="lib"
path="/Users/name/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/2973/junit-4.12.jar"
javadocpath="/Users/name/.gradle/caches/modules-2/files-2.1/junit/junit/4.12/941a/junit-4.12-javadoc.jar"/>
<classpathentry
sourcepath="/Users/name/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/1dc3/hamcrest-core-1.3-sources.jar"
kind="lib"
path="/Users/name/.gradle/caches/modules-2/files-2.1/org.hamcrest/hamcrest-core/1.3/42a2/hamcrest-core-1.3.jar"/>
</classpath>
(for making it to easy to read, I inserted indentation in each attributes, and shorten hash code.)
The Tooling API is decoupled from the XML files that are generated via āgradlew eclipseā. There is currently no way to attach custom sources such that the Tooling API picks them up. As consequences, Buildship does not see these sources neither.
This issue has been reported before and is likely to be tackled in the near future.
A year and half later Itās a little past the ānear futureā that you mentioned. Any hope of getting this working? I am stuck with some local file dependencies and would really love to have the tooling properly support it. Thanks!
I think gradle can reference a single dependecy from multiple repositories (ie jar from one repo and sources from another) but Iām not 100% sure⦠you could try:
repositories {
maven {
// get the main jars (classes) from here
url 'http://main/maven/repo'
}
maven {
// get the sources from here (local directory)
url uri('localrepo')
}
}
Then you could store the sources using maven directory conventions
eg: projectRoot/localrepo/${group}/${artifact}/${version}/${artifact}-${version}-sources.jar