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)?
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With