Gradle 5.6.4. I have source code of the library I want to add as a dependency to my project. I already know that I can compile it into jar with .class files and then write dependencies{ compile files('libs/mylibrary-compiled.jar') }
, but I do not want to lose comments, variable names, etc. Sadly writing the same thing for a jar file consisting of .java files does not work - packages are imported, but classes are not.
I think copy-pasting the sources right into src/main/java directory is an option too but I want to keep my code separate from libraries... So is it possible with gradle?
Asked
Active
Viewed 335 times
0

Fizz Areh
- 87
- 7
-
You have sources for something that is not already available as a package? Would creating your own artifact which you then use, be an option? – Thorbjørn Ravn Andersen Jul 20 '22 at 20:04
-
@ThorbjørnRavnAndersen I think creating an artifact = compiling, no? I don't really want to compile because then I will not be able to see the sources in IntelliJ, I will only see a decompilation of .class files. – Fizz Areh Jul 20 '22 at 20:20
-
I am not sure if you understand how compilation works. You can tell your ide that a given jar file has sources in your zip file, will that do? – Thorbjørn Ravn Andersen Jul 20 '22 at 20:45
-
Answers from this question should help you: https://stackoverflow.com/questions/11474729/how-to-build-sources-jar-with-gradle? – ciech Jul 20 '22 at 21:24
-
@ciech The person who asked this question knows how to add resutling mylibrary-sources.jar into project but I don't... – Fizz Areh Jul 21 '22 at 07:31
-
@ThorbjørnRavnAndersen I would prefer adding a library using Gradle and not IDE but at this point I can't even figure out the IDE way – Fizz Areh Jul 21 '22 at 07:31