I am developing a sub-project that is a part of the huge multi-project Gradle build. I need some Java classes from these other sub-projects, but I do not need any dependencies they drag in because some libraries I use require different versions of these.
I initially configured the needed subprojects as
compile project(':other_needed_sub_project')
however in this case gradle eclipse
task adds projects to the project tree. They dependencies appear on the class path, causing my application to pick the wrong versions. In Eclipse, included projects seem having priority over specified libraries.
As a working solution, I currently build jars of the required sub-projects with existing Maven build and then use
compile files('../other_needed_sub_project/target/dist/other_needed_sub_project.jar')
that is exactly that I need - no libs attached. However this means that I must run a different build before building my subproject with Gradle.
Could Gradle build the needed sub-projects and then only add references to they final jars in my Eclipse configuration?
You could exclude all transitive dependencies of a dependency:
Or you could, but I do certainly not recommend this exclude every dependency by hand like this: