Open lexxy23 opened 5 years ago
Didn't tried it out it kts build files yet but makes sense to add it to the README.
I was trying to do the same thing. Got so far as to configure git. But simply using
git {...}
inside release
doesn't work.
What is the workaround?
the only existing workaround is to separate release {}
section into other groovy build script file
plugins {
id 'net.researchgate.release' version '2.6.0'
}
apply(from = "release.gradle")
release {
git {
// ...
}
}
Another workaround is to invoke groovy dynamic method reception directly:
release {
with (propertyMissing("git") as GitAdapter.GitConfig) {
requireBranch = """master|develop|release\/.+"""
}
}
Building on top of Alex's tip, you can use this snippet to create a DSL:
fun ReleaseExtension.git(configureFn : GitAdapter.GitConfig.() -> Unit) {
(propertyMissing("git") as GitAdapter.GitConfig).configureFn()
}
Now you can use release { git {} }
in kotlin just as you would in groovy.
Instead of propertyMissing
which tightly couples to implementation details, you can also use getProperty
.
I had
release {
val gitConfig = getProperty("git") as GitConfig
gitConfig.signTag = true
}
or
release {
(getProperty("git") as GitConfig).apply {
signTag = true
}
}
before I switched to
fun ReleaseExtension.git(configure: GitConfig.() -> Unit) = (getProperty("git") as GitConfig).configure()
Finally, none of the workarounds to configure Git Adapter attributes is necessary anymore with the release of plugin version 3.0.0.
According to the Kotlin DSL documentation this is all that's needed to configure Git Adapter attributes:
configure<ReleaseExtension> {
with(git) {
requireBranch = "master"
}
}
Ticket can thus be closed.
The documentation and way the plugin currently works is optimized only for Groovy. Can you show or state how I can make this plugin works using a kotlin build script (build.gradle.kts)?
Just to be sure: this is not a bug but some kind of documentation request.