Hello,
I am building a new gradle multiproject project.
This multi project has the following structure.
Project A:
- SubProject AA
- api sourceSet
- main sourceSet
- SubProject AB
- api sourceSet
- main sourceSet
When I setup a buildSrc with a api-conventions.gradle file in which I define the following configurations :
configurations {
apiOutput
implementationElements {
// for running the 'jar' (main) variant is used, so we only modify that
// 'main' is already added by default
outgoing.artifact(jarApi)
}
apiElements {
// for compilation the 'classes' variant is used, so we only modify that
outgoing.variants['classes'].artifacts.clear() // remove 'main'
sourceSets.api.output.classesDirs.each {
outgoing.variants['classes'].artifact(it)
}
}
}
jar {
from sourceSets.api.java
from sourceSets.api.output
from sourceSets.main.java
from sourceSets.main.output
}
// Define API jar artifacts
artifacts {
apiOutput jarApi
}
Subproject AB depends on subproject AA.
I tested with both implementation project(path: ‘:AA’) and api project(path: ‘:AA’) it does not works, it only works if I specify configuration: ‘apiOutput’.
I would prefer that if I set a dependency to project AA, by default, only the output of API is used. Do you know why the configurations of implementationElements or apiElements does not work ?