Slackbot
10/27/2022, 6:51 AMJendrik Johannes
10/27/2022, 7:03 AMconfigurations {
myConfigurationConsume {
canBeConsumed = false
canBeResolved = true
}
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("my-usage"))
}
}
rootProject.subprojects.forEach(pr ->
myConfigurationConsume project(pr.path)
)
And on the producer side you declare the attribute as well:
configurations {
myConfiguration {
canBeConsumed = true
canBeResolved = false
}
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("my-usage"))
}
...
}
Then when you resolve, you filter out the projects that fail to resolve because they do not have "myConfiguration" by using a lenient artifact view:
myConfigurationConsume.incoming.artifactView { lenient(true) }.filesJendrik Johannes
10/27/2022, 7:04 AMsubprojects.forEach loop completely. If you have something like an "app" project, which already has dependencies to all your projects (e.g. on the runtimeClasspath) you could put the myConfigurationConsume there and then let it extend implementation . Then it automatically has all your subprojects.
That's how I do it with collecting the source code of all projects in this example:
https://github.com/jjohannes/understanding-gradle/blob/main/13_Aggregating_Custom_[…]gic/java-plugins/src/main/kotlin/my-java-application.gradle.ktsJendrik Johannes
10/27/2022, 7:04 AMMarkus Maier
10/27/2022, 7:35 AMJendrik Johannes
10/27/2022, 8:59 AMJendrik Johannes
10/27/2022, 9:01 AMJendrik Johannes
10/27/2022, 9:02 AMJendrik Johannes
10/27/2022, 9:02 AMMarkus Maier
10/27/2022, 9:15 AMJendrik Johannes
10/27/2022, 9:16 AMMarkus Maier
10/27/2022, 10:07 AM