Closed tacascer closed 9 months ago
Snapshot is already added at the end?
$ ./gradlew printVersion
Starting a Gradle Daemon (subsequent builds will be faster)
> Task :printVersion
11.11.5-SNAPSHOT
Oh I meant when doing infoVersion
and semVersion
I guess turning something like 1.1.0-SNAPSHOT+052
into 1.1.0+052-SNAPSHOT
would violate SemVer syntax:
<version core> "-" <pre-release> "+" <build>
Yeah that is true
Unfortunately Maven version convention doesn't fully conform to semver
Maybe we can add a toggle for a "Maven style version" where the -SNAPSHOT
will be at the end?
The change for putting version at the end would only be needed when used by maven publish? So I guess you could do (in kotlin):
publishing {
repositories {
maven {
url = ...
}
}
publications {
create<MavenPublication>("my publication") {
version = semver.semVersion.toString().replace(Regex("^(.*?)(-SNAPSHOT)(.*)$"), "$1$3$2")
}
}
}
adding a flag the toInfoVersionString is possible I guess but I'm not sure how common it is to include commitcount and sha in published snapshots. I guess the publication would be done like above but instead
version = semver.semVersion.toInfoVersionString(preReleaseLast=true)
publishing {
repositories {
maven {
url = ...
}
}
publications {
create<MavenPublication>("my publication") {
version = semver.semVersion.toString().replace(Regex("^(.*?)(-SNAPSHOT)(.*)$"), "$1$3$2")
}
}
}
Oh that looks like a cool solution
The use case is common enough in our organization. We are publishing snapshots each PR, and those PRs would resolve to the same version if doing printVersion
. This leads to people not being able to uniquely identify their PRs, so some extra metadata would be helpful.
version = semver.semVersion.toInfoVersionString(preReleaseLast=true)
How do you feel about adding that flag?
I guess forcing developers to fully comply with semver is not a goal for this plugin so I added a appendPreReleaseLast parameter to toInfoVersionString
in version 0.7.0.
version = semver.semVersion.toInfoVersionString(shaLength = 7, appendPreReleaseLast = true)
This looks awesome! Thanks so much.
Hi there,
Maven repositories usually require that a snapshot version end in
-SNAPSHOT
. Is it possible to move-SNAPSHOT
to the end of the version string if it is included in the string?