This repository has been created as a reproduction case to support a Gradle forum question.
The crux of the question is:
Why doesn't Gradle download transitive dependencies when a file extension e.g.
@jaris specified on a dependency?
This is demonstrated as follows:
- Clone this repository.
- Run
./gradlew test. The task will fail with a compilation error becausejavaposse.jobdsl.dsl.JobManagementis not available on the test compilation classpath. - Uncomment line
59inbuild.gradle - Run
./gradlew testagain. This time compilation will succeed and theBasicSpectest will pass. - Help me understand why this happens?
javaposse.jobdsl.dsl.JobManagementresides in theorg.jenkins-ci.plugins:job-dsl-coredependency, which is a transitive dependency of theorg.jenkins-ci.plugins:job-dsldependency.- The
packagingelement in theorg.jenkins-ci.plugins:job-dslpom.xml is set tohpi. If we declare this dependency astestImplementation "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}"then Gradle will also download all of its transitive dependencies (which includejob-dsl-core) and will add them to the relevant classpath. - However, I specifically want the
jarartefact ofjob-dsl, as it contains classes that I want to use. When thehpiartefact gets pulled in those classes are unavailable to me. - I can obtain the
jarartefact ofjob-dslby specifying@jaras the extension. When I do this Gradle downloads thejarartefact, however it also then no longer downloads any of the transitive dependencies. - The only solution I can think of is to then explicitly depend on each of the, now absent, transitive dependencies. However this feels wrong and brittle.
- Question: Is there a way I can tell Gradle to download the
job-dsljarartefact and to also download all of its transitive dependencies?
Very grateful for any help on this one!
- The initial problem is demonstrated in commit ec26bbfcee8b8deac1ffee55b743ce8813d5ad22.
- The solution that I came up with in the end is in commit 147cb86cd2487b642275ac1d66174782ad8568e8. This was inspired from help received on the Gradle forum here