Get computed version
Closed this issue ยท 12 comments
Hello.
If would be great if this plugin will provide a method to get computed "version" as gradle-git-version-calculator does.
I use this version to set some manifest properties.
Actually there is a gradle task already gradle :version -q
How it can be used inside gradle file?
In current gradle-file I can calculate version, pass it to version
project-property
https://github.com/1c-syntax/bsl-language-server/blob/3feb71eb65613faa697a1b4736a22ae9fee136b5/build.gradle.kts#L22
and use it after, at jar-task:
With your plugin archiveVersion.get()
is null
. project.version
is deprecated and leads to archiveVersion
also
That's an interesting problem. I think I understand why it behaves like this, however I think I need to do a little refactoring to make this work.
I will do so after my vacation in mid december .
Ok, thank you!
hi, before i create a new ticket, my propsal is maybe also relevant here, the final version is only available after the project evaluation, i had to move my repository config in this block to get the right repo selected (based on the version, which contains "-SNAPSHOT" in my case, if build from a branch)
if i do it outside the afterEvaluate
block the version is not set
Kotlin DSL:
project.afterEvaluate {
configure<PublishingExtension> {
repositories {
maven {
val releaseRepositoryUrl = uri("https://artifact-manager-url/repositories/releases")
val snapshotRepositoryUrl = uri("https://artifact-manager-url/repositories/snapshots")
url = if (version.toString().endsWith("-SNAPSHOT")) snapshotRepositoryUrl else releaseRepositoryUrl
credentials {
username = System.getenv("ARTIFACT_MANAGER_USERNAME")
password = System.getenv("ARTIFACT_MANAGER_PASSWORD")
}
}
}
}
}
I've implement a solution, however it is a breaking change.
From my perspective there is no better solution possible. I also played with mixin on root project, but that causes a kinda quirky configuration.
I came up with the following solution.
...
version = '1.0.0-SNAPSHOT'
gitVersioning.apply {
branch {
pattern = 'master'
versionFormat = 'master-SNAPSHOT'
}
}
...
I've just release version 2.1.0
it uses following syntax now
version = '1.0.0-SNAPSHOT'
gitVersioning.apply {
branch {
pattern = 'master'
versionFormat = 'master-SNAPSHOT'
}
}
kotlin dsl snippet:
gitVersioning.apply(closureOf<GitVersioningPluginConfig> {
preferTags = true
branchVersionDescription(closureOf<VersionDescription> {
pattern = "^(?!v[0-9]+).*"
versionFormat = "\${branch}-\${commit.short}"
})
tag(closureOf<VersionDescription>{
pattern = "v(?<tagVersion>[0-9].*)"
versionFormat = "\${tagVersion}"
})
commit(closureOf<CommitVersionDescription>{
versionFormat = "\${commit.short}"
})
})
Thanks, everithing works fine (except changed branch
config and closureOf<GitVersioningPluginConfig>
part)
Oh damn it.I will fix it tomorrow.
should be fixed now in version 2.1.1