Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative to SNAPSHOT for non release versions #327

Closed
tmvlpl opened this issue Feb 8, 2020 · 5 comments
Closed

Alternative to SNAPSHOT for non release versions #327

tmvlpl opened this issue Feb 8, 2020 · 5 comments

Comments

@tmvlpl
Copy link

tmvlpl commented Feb 8, 2020

While marking non release version with SNAPSHOT is great for Java libs, there are other usecases where a generated "fixed develop prerelease version" is better suited.
What about an alternative mode to the SNAPSHOT suffix, that automatically appends a semantic version prerelease marker to the upcoming version? Something like 1.2.3-dev.4, where 4 is the number of commits since the last tag. The used prerelease marker should be configurable and special care must be taken in case the current/next version already is a prerelease (like a release candidate).
I'd be happy to give the implementation a shot and provide a PR.

@KJoyner
Copy link

KJoyner commented Jun 19, 2020

I achieved this a bit different. It required me adding capability to excludeSnapshot (opposite of forceSnapshot). I was trying to achieve a version that looked like major.minor.patch.buildNum when buildNum was defined (which we defined when building on Jenkins). If there is interest in adding this capability, I can provide a PR.

With the excludeSnapshot option in place, I added the following to my build.gradle:

////////////////////////////////////////////////////////////////////////////////////////////////////
// Determine version.
//
// If property BUILD_NUMBER is set (expected to be set on a Jenkins build server),
// then the version number will be in the format major.minor.patch.buildNumber. The
// major.minor.patch is derived from a git tag.
//
// If BUILD_NUMBER is not set, then the version number will be in the the following format:
// major.minor.patch-SNAPSHOT. Again, major.minor.patch is derived from a git tag.
////////////////////////////////////////////////////////////////////////////////////////////////////

String buildVersion(version, position, project) {
String bVersion = version
if (project.hasProperty("BUILD_NUMBER"))
bVersion = bVersion + "." + BUILD_NUMBER
return bVersion
}

scmVersion.ext.hasBuildNumber = hasProperty("BUILD_NUMBER")
scmVersion {
excludeSnapshot = ext.hasBuildNumber
forceSnapshot = !ext.hasBuildNumber

nextVersion {
suffix = "start"
separator = "-"
}
versionCreator { version, position -> buildVersion(version, position, project) }
}
version = scmVersion.version

@bgalek
Copy link
Member

bgalek commented Jun 17, 2021

expect this feature in the next release ;)

@bgalek
Copy link
Member

bgalek commented Jun 28, 2021

merged!

@bgalek bgalek closed this as completed Jun 28, 2021
@tmvlpl
Copy link
Author

tmvlpl commented Jun 28, 2021

That looks great! Thanks a lot, I'll check it out immediately.

@bgalek
Copy link
Member

bgalek commented Jun 28, 2021

@tmvlpl try out latest version ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants