1

I have a Java library built with gradle for which I would like to modify the repositories it reads from and publishes to, without changing it the original library files.

So, I created a new project library (lib-internal) which is just overriding the repositories and publishing options of the library that I don't want to modify (lib-open-source).
I could force lib-internal to use the source from lib-open-source, BUT I failed to copy its dependencies.

In my build.gradle of lib-internal, I have something like this copy the sources:

sourceSets.main.java.srcDirs = [project(':lib-open-source').projectDir.toString() + '/src/main/java']

But I am looking for something similar for its dependencies.
In short, I'm looking for the correct syntax of something like:

dependencies = project(':lib-open-source').getDependencies()

I also tried something with the configurations, as suggested by the help of the getDependencies() method but can't find the correct syntax.

configurations.add(project(':lib-open-source').configurations.compileClasspath)

If I copy the dependencies block of lib-open-source into lib-internal, it works as I want to, but I want to avoid this copy-paste.

Thank you!

87VN0
  • 775
  • 3
  • 10
  • would it be sufficient for you to have a task to that copy for you, and it will do that automatically with each call of the build task or any other ? if yes that's easily achievable. – George Nov 01 '22 at 12:13
  • @George, a task which copies the dependencies block? or a task that would copy the jars? I would like the first option, so that I could build/publish the lib-open-source "just like" if it were the original one. So far, I solved my problem by calling something like gradle :lib-open-source:build / gradle :lib-open-source:publish and removed the sourceSets block. But still, there must be a way to copy them! – 87VN0 Nov 07 '22 at 15:00
  • You're way seems legit , I would've suggested something like that. Make a custom task for you, and automatically call it whenever you trigger a build command ( for example), There might be a better solution but that what i was about to suggest for you – George Nov 07 '22 at 15:42

0 Answers0