Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can the Gradle Eclipse Plugin attach source jar files to local jar dependencies

Tags:

eclipse

gradle

If I have maven dependency in Gradle then the eclipse plugin will automatically download the source jar file if there is one and attach it in the generated eclipse ".classpath" file.

Is is possible to get a similar behaviour for local file depencies (that I have the source jar of)?

like image 759
Stefan Feuerhahn Avatar asked Aug 01 '13 06:08

Stefan Feuerhahn


People also ask

Can I manually add JAR files to Gradle?

Local JARs Before we begin explaining the process of adding local JAR files to Gradle, it's good to mention that it is not recommended to manually add the dependencies that are available in the public repositories. One of the most important reasons why build systems like Gradle exist is to do this sort of thing automatically.

What is the Eclipse plugin for Gradle?

The Eclipse plugins provide objects modeling the sections of the Eclipse files that are generated by Gradle. The generation lifecycle is as follows: The file is read; or a default version provided by Gradle is used if it does not exist.

What is the use of Gradle file tree?

File Tree We can tell Gradle to look for all JAR files in a certain directory without narrowing down the names. This can be useful if we cannot, or don't want to, place certain files in a repository.

What is the generation lifecycle for Gradle plugins?

Hooking into the generation lifecycle. The Eclipse plugins provide objects modeling the sections of the Eclipse files that are generated by Gradle. The generation lifecycle is as follows: The file is read; or a default version provided by Gradle is used if it does not exist.


1 Answers

When using a flatDir repository, the Eclipse plugin should attach any source jars as long as they are in the same location as the dependency jar (with the same name followed by either -src or -sources).

Say you have a local jar called dependency.jar at location x/y/z. If you put the sources jar in the same location and call it dependency-sources or dependency-src, it will be attached.

Please note that this only works for flatDir repositories and not for plain file dependencies.

like image 59
Ben Green Avatar answered Sep 23 '22 02:09

Ben Green