Javi
05/08/2026, 12:35 PM@Builder pattern in DCL cannot chain two function calls?
I am able to do
foo = bar
.baz(...)
But if I do
foo = bar
.baz(...)
.quux(...)
it fails with ValueFactoryCallWithComplexReceiverPaul Merlin
05/08/2026, 12:37 PMJavi
05/08/2026, 12:40 PM@Builder and how it looks like as I am mostly doing "blind" development.
So I do not understand if I am using the right tool (@Builder) or I just have to go with a different tool.Paul Merlin
05/08/2026, 12:41 PMJavi
05/08/2026, 12:44 PMmapVersion {
major = 2
minor = 3.
...
}
And I was trying to see
mappedVersion = currentVersion
.major(2)
.minor(1)Paul Merlin
05/08/2026, 12:44 PMPaul Merlin
05/08/2026, 12:48 PMJavi
05/08/2026, 12:55 PMPaul Merlin
05/08/2026, 12:55 PMJavi
05/08/2026, 1:02 PMmapVersion {
if (tagPrefix == "v" && stage == "dev")
metadata = kotlinVersion()
}
I can do something like
mapVersion {
metadata = kotlinVersion()
onlyIf {
tagPrefix = "v"
stage == "dev"
}
}
But that would lead to support only && condition. I can have a list of && conditions and another one for || conditions, but that becomes really tedious.
It is a real escenario in all my repositories that work with compiler/ksp plugins and they do not have an included build to hide this logic under the hood.
So I would like to find a way to model this in DCL.Javi
05/08/2026, 1:05 PMmappedVersion = currentVersion
.major(2)
.minor(1)
.onlyIf {
tagPrefix("v") or stage("dev")
}
That supposing infix would work.Paul Merlin
05/08/2026, 1:17 PMPaul Merlin
05/08/2026, 1:18 PMJavi
05/08/2026, 1:20 PMJavi
05/08/2026, 1:21 PMonlyIf, but I do not remember which was thoJavi
05/08/2026, 1:21 PMPaul Merlin
05/08/2026, 1:22 PMonlyIf {}. There is also the signing plugin that has one. But this is because its interaction with other plugins is porely modeled.Paul Merlin
05/08/2026, 1:22 PMJavi
05/09/2026, 1:39 PM// Kotlin
semver {
tagPrefix = "p"
mapVersions {
mapVersion { // without qualifier, matches all versions
}
mapVersion("kotlin") { // Extend SemverDefinition, matches only versions with "kotlin" qualifier, priority over the previous one if matches
metadata = gradleProperty("kotlinVersion")
// or metadata = environmentVariable("KOTLIN_VERSION")
// or metadata = "1.5.0" // hardcoded value
// or metadata = property("kotlinVersion") // gradle property > environment variable
conditions {
condition(Condition.MetadataIsPresent) // condition enum
condition(Condition.RequestedTagPrefixMatches())
}
snapshotRules {
rule("kotlin-dev") { // if matches, the version is considered a snapshot
contains("kotlin-dev") // multiple ways to create this rule, from simple string match to regex
contains("another-string")
matches {
pattern("(0|[1-9]\\d*)\\.(0|[1-9]\\d*)\\.(0|[1-9]\\d*)-dev-(0|[1-9]\\d*)")
pattern("another-regex")
}
}
}
}
}
}