Comments (15)
@dwijnand What Maven does is incrementing the suffix, -1, -2, ... to create unique SNAPSHOT versions. To do so we need to check the existing versions in the snapshot repository. But here, I think this is overkill as a feature of sbt-dynver.
OK. I'll check the code how can we add dynverUseSonatypeSnapshotVersion option.
from sbt-dynver.
@xerial I've used a slight variation of your code:
def versionFmt(out: sbtdynver.GitDescribeOutput): String = {
val prefix = out.ref.dropV.value
val rev = out.commitSuffix.mkString("+", "-", "")
val dirty = out.dirtySuffix.value
val ver = (rev, dirty) match {
case ("", "") =>
prefix
case (_, _) =>
// (version)+(distance)-(rev)
prefix + rev
}
val dynamicVersion = if (out.hasNoTags()) s"0.0.0-${out.version}" else ver
val isSnapshot = out.isSnapshot() || out.hasNoTags()
if (isSnapshot) s"$dynamicVersion-SNAPSHOT" else dynamicVersion
}
This doesn't rely on an environment variable to figure out if something is a release or a snapshot.
I'm going to test this a little more, but I think it could be the basis for the sonatype mode.
from sbt-dynver.
Publishing to Sonatype staging repository works:
[info] published airframe-log_2.12 to https://oss.sonatype.org/service/local/staging/deploy/maven2/org/wvlet/airframe/airframe-log_2.12/0.33.1+2-338015a5/airframe-log_2.12-0.33.1+2-338015a5.pom
from sbt-dynver.
A workaround I found is, appending -SNAPSHOT
to the version string:
def versionFmt(out: sbtdynver.GitDescribeOutput): String = {
val prefix = out.ref.dropV.value
val suffix = out.commitSuffix.mkString("-", "-", "") + out.dirtySuffix.dropPlus.mkString("-", "")
if(!suffix.isEmpty) {
prefix + suffix + "-SNAPSHOT"
}
else {
prefix
}
}
from sbt-dynver.
According to Sonatype blog, the version file pattern is like this:
Pattern VERSION_FILE_PATTERN = Pattern.compile("^(.*)-([0-9]{8}.[0-9]{6})-([0-9]+)$" );
http://blog.sonatype.com/2008/05/maven-code-how-to-detect-if-you-have-a-snapshot-version/
from sbt-dynver.
My current solution is like this:
https://github.com/wvlet/airframe/blob/58edb799062387d28e5940d7075c6e2c8e008e88/build.sbt#L19-L42
- publish a sonatype friendly version (with -SNAPSHOT suffix) for each master commit to Sonatype snapshot repository.
- For git tag release, switch the behavior using an environment variable (RELEASE=true) then use the default dynver string to use Sonatype releases repo.
It would be great if sbt-dynvar can generate sonatype-friendly version string by some setting. Do you accept such an PR?
from sbt-dynver.
Hey @xerial,
Thanks for opening the issue.
Given Sonatype's importance I think it would be good to make this use case work better out the box. The devil (as they say) is in the detail.
One (possibly ideal) idea would be to define whether or not the version contains -SNAPSHOT in terms of publishTo
being or not being set to Sonatype snapshots, but I fear that that might lead into an infinite loop as it's very common to have if (isSnapshot.value)
or if (version.value endsWith "-SNAPSHOT")
.
So perhaps we could just have a setting (i.e a SettingKey[Boolean]
) that you can use to opt-in to Sonatype-friendly versions.
If we can't find a good solution there we can always resort to detailing Sonatype's expectations about version strings in the README..
from sbt-dynver.
We can also use datetime string like 20180104.091410-1
as well for Sonatype snapshot repo.
My idea is:
- Extend dynver to use DateTime instead of Date to produce date + time (hh:mm:ss) string
- (A) Add
dynverUseSonatypeSnapshotVersion := true
option
Then we can produce versions like this:
dynver | version when (A) is true | isSnapshot | publishTo |
---|---|---|---|
0.1 | 0.1 | false | Sonatype Staging |
0.1+5+0123abc | 0.1+5-0123abc-SNAPSHOT | true | Sonatype Snapshot |
0.1+5+0123abc-20180104-0914 | 0.1+5-0123abc-20180104.091410-1 | true | Sonatype Snapshot |
@dwijnand If this is OK, I'll create a PR for this change.
from sbt-dynver.
Speaking of -SNAPSHOT things it might be good to also consider #52 when we do this change..
from sbt-dynver.
For #52,
Instead of using 0000000 (+0 commit), we should use the actual revision like:
1.0.0+0-xxxxxxx-20140707-1030
This is more informative to tell which git revision is used.
In this regard, 0.1+5-0123abc-SNAPSHOT
also should have a timestamp, instead of -SNAPSHOT. For example:
0.1+5-0123abc-20180104.0914-0
We can use suffix -0
for distinguishing committed (-0) and non-committed (-1) timestamps.
from sbt-dynver.
For #52,
Instead of using 0000000 (+0 commit), we should use the actual revision like:1.0.0+0-xxxxxxx-20140707-1030
This is more informative to tell which git revision is used.
Oh yes of course! Good idea.
In this regard,
0.1+5-0123abc-SNAPSHOT
also should have a timestamp, instead of -SNAPSHOT. For example:
0.1+5-0123abc-20180104.0914-0
We can use suffix
-0
for distinguishing committed (-0) and non-committed (-1) timestamps.
I think that's something that Maven repositories already do? I remember someone explaining that, but I never looked into it.
from sbt-dynver.
Is there an update on this? I would love this feature.
from sbt-dynver.
@leonardehrenfried I couldn't find a time for making a PR, but I guess the change would be simple.
from sbt-dynver.
This has probably been accidentally closed but is actually not resolved.
#64 fixes it though.
from sbt-dynver.
hehe
from sbt-dynver.
Related Issues (20)
- What is the best way to prepend a dependency version number in front of the version ? HOT 4
- Allow getting full Git commit hash HOT 1
- Better support for meaningful SemVer-compliant versions HOT 3
- Default version pattern leads to conflicting versions HOT 7
- Possible to use with sbt-native-packager?
- Move to sbt org? HOT 3
- Config to automatically increment to next major, minor or patch version HOT 7
- Can't override `isVersionStable`
- Breaks with SHA longer than 8
- Should this plugin only be enabled on CI environment? HOT 1
- Selects wrong version if multiple lightweight tags point to the same commit HOT 1
- Artefacts not available HOT 10
- Admin stuff HOT 2
- Release 5.0.0 HOT 2
- dynverAssertTagVersion throws NullPointerException
- Support peeking at remote history / tags? HOT 1
- Task for printing out dynver for arbitrary commit
- Add setting/ability to use basic snapshot versioning with the hash.
- -rcX Tag suffix ignored HOT 1
- make behaviour configurable so that `previousStableVersion` can ignore M0/RC0 versions
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sbt-dynver.