I have a big gradle multi-project and few of the projects do not produce a jar file deliberately - tasks.withType(Jar) { enabled = false }
We have been using the java-library
plugin for these projects in order for their consumer’s to consume the java classes (instead of jar) as explained here: The Java Library Plugin
This works fine and all projects compile successfully.
The implementation configuration however of the consumer’ projects always shows a reference to the jar file, which does not exist.
This pollutes the classpath entries and confuses.
Is there a proper way to solve this problem - either somehow remove the jar file reference or use the plugins in some other (better) way?
Producer project that does not produce a jar file:
apply plugin: 'java-library'
sourceSets {
main {
java {
srcDirs = ['src']
}
}
}
tasks.withType(Jar) { enabled = false }
println("$project.name configurations.compileClasspath.asPath entries: " + configurations.compileClasspath.asPath)
Consumer project that consumes the classes of the producer project:
apply plugin: 'java'
sourceSets {
main {
java {
srcDirs = ['src']
}
}
}
configurations {
implementation {
canBeResolved(true)
}
}
dependencies {
implementation project(":vehicle")
}
println("===========================================")
//why I get vehicle-0.0.0-v0001.jar in implementation entries since jar is disabled
//pollutes the classpath entries and confuses.
//Can I remove it somehow?
println("implementation entries: " + configurations.implementation.asPath)
println("sourceSets compileClasspath entries: " + sourceSets.main.compileClasspath.asPath)
println("===========================================")
Attaching a repro in:
sample.zip (77.8 KB)