Sebastian Schuberth
06/20/2025, 1:57 PMTrevJonez
06/20/2025, 2:21 PMfun Project.addLibrary() {
val subproject = this
val aliasPrefix = subproject.path.let { path ->
if (path.count { it == ':' } > 1) {
path.split(':')
.dropLast(1)
.filter { it.isNotBlank() }
.joinToString(separator = "-", postfix = "-") { it.normalizeName() }
} else {
""
}
}
val aliasName = subproject.name.normalizeName()
library("$aliasPrefix$aliasName", subproject.group.toString(), subproject.name)
.versionRef("aetnahealth")
}
fun Project.processSubProjects() {
println("Processing subproject: ${this.path}")
this@processSubProjects.subprojects {
val subproject = this
val hasMavenPublish = subproject.plugins.hasPlugin("maven-publish")
if (!hasMavenPublish) {
subproject.processSubProjects()
} else {
subproject.addLibrary()
}
}
}
gradle.projectsEvaluated {
rootProject.processSubProjects()
}
TrevJonez
06/20/2025, 2:22 PMVampire
06/20/2025, 5:05 PMplugins
alone is bad already, accessing it on another project is super-bad. Same for the group
, don't reach into models of other projects.Thomas Broyer
06/20/2025, 5:20 PMTrevJonez
06/20/2025, 5:25 PMSebastian Schuberth
06/20/2025, 7:08 PMVampire
06/20/2025, 10:02 PMVampire
06/20/2025, 10:03 PMdoLast
or doFirst
action to the generateCatalogAsToml
task that verifies you did not forget to add any.Thomas Broyer
06/20/2025, 10:07 PMTrevJonez
06/20/2025, 10:08 PMisn't it the primary use-case that you want to publish a version-catalogbad assumption there I think. gradle has always been about building software well. toml is a relatively new QOL feature. we are just lucky enough to be living thru the growing pains.
TrevJonez
06/20/2025, 10:11 PMTrevJonez
06/20/2025, 10:11 PMVampire
06/20/2025, 10:13 PMFor a multi-project build, you'd more likely publish a platform than a version catalog.
Often both. The version catalog to get accessors for all modules without having to look up which modules exist. The platform to align versions of the modules. The later optimally properly modeled so that it happens auto-magically without the needed to manually use the platform.
Sebastian Schuberth
06/23/2025, 8:09 AMVampire
06/24/2025, 1:59 AMTrevJonez
06/24/2025, 2:05 AMI'm not an encyclopedia
^yet But yeah what he said I've not heard of one. Only toml I have imported was from the AWS kotlin SDK which is where I took strong inspiration from when setting up our version catalog artifact.