Acccording to The Java Library Plugin,
using the api configuration on a dependency of a library with the java-library plugin should put that dependency into the classpath of a consumer of the library. However, that simply just does not work for me. In my consumer project, I use the implementation configuration to include my library, whilst my library has the api configuration to include its dependencies. However, the dependencies are simply not inside of the consumer’s shaded jar file that shades in the library. Does anyone know why this is? Do I have to take any additional steps to get this working?
I have tried this so far, to no avail:
Library Project:
dependencies {
api("my-library-dependency")
}
Consumer Project:
dependencies {
implementation("my-library")
}
tasks.withType<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar> {
dependencies {
include(dependency("my-library"))
}
}
In the decompiled jar file of my consumer project, I see no trace of the dependency of the library. It is like it is just not included at all. I can get it to work by doing this in my consumer project:
dependencies {
include(dependency("my-library"))
include(dependency("the-dependency-of-my-library-in-the-consumer-project"))
}
}
but this is redundant, and I feel as though I should not have to explicitly declare this. If I have multiple dependencies especially, this will end up being messy.
Slimified is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.