Skip to content

Commit 8f5137c

Browse files
keirlawsonmuuki88
authored andcommitted
Use SNAPSHOT for release when snapshot version
1 parent f7e7b08 commit 8f5137c

File tree

5 files changed

+40
-3
lines changed

5 files changed

+40
-3
lines changed

src/main/scala/com/typesafe/sbt/packager/rpm/RpmPlugin.scala

+8-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.typesafe.sbt.packager.rpm
22

33
import sbt._
4-
import sbt.Keys.{name, packageBin, sourceDirectory, streams, target, version}
4+
import sbt.Keys.{name, packageBin, sourceDirectory, streams, target, version, isSnapshot}
55
import java.nio.charset.Charset
66

77
import com.typesafe.sbt.SbtNativePackager.Linux
@@ -63,7 +63,7 @@ object RpmPlugin extends AutoPlugin {
6363

6464
override lazy val projectSettings = Seq(
6565
rpmOs := "Linux", // TODO - default to something else?
66-
rpmRelease := "1",
66+
rpmRelease := (if (isSnapshot.value) "SNAPSHOT" else "1"),
6767
rpmPrefix := None,
6868
rpmVendor := "", // TODO - Maybe pull in organization?
6969
rpmLicense := None,
@@ -105,7 +105,7 @@ object RpmPlugin extends AutoPlugin {
105105
packageArchitecture in Rpm := "noarch",
106106
rpmMetadata := RpmMetadata(
107107
(packageName in Rpm).value,
108-
(version in Rpm).value,
108+
if (isSnapshot.value) stripSnapshot((version in Rpm).value) else (version in Rpm).value,
109109
rpmRelease.value,
110110
rpmPrefix.value,
111111
(packageArchitecture in Rpm).value,
@@ -163,6 +163,11 @@ object RpmPlugin extends AutoPlugin {
163163
}
164164
}
165165
)
166+
167+
def stripSnapshot(version: String): String = {
168+
val suffixPosition = version.indexOf("-SNAPSHOT")
169+
version.slice(0, suffixPosition)
170+
}
166171
}
167172

168173
object RpmDeployPlugin extends AutoPlugin {
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
enablePlugins(RpmPlugin)
2+
3+
name := "rpm-test"
4+
5+
version := "0.1.0-SNAPSHOT"
6+
7+
maintainer := "Keir Lawson <[email protected]>"
8+
9+
packageSummary := "Snapshot test rpm package"
10+
11+
packageDescription := """A fun package description of our software,
12+
with multiple lines."""
13+
14+
rpmVendor := "typesafe"
15+
16+
rpmUrl := Some("http://github.com/sbt/sbt-native-packager")
17+
18+
rpmLicense := Some("BSD")
19+
20+
TaskKey[Unit]("check-snapshot") := {
21+
assert(rpmRelease.value == "SNAPSHOT", s"RPM has incorrect value ${rpmRelease.value}")
22+
assert(rpmMetadata.value.version == "0.1.0", s"RPM has incorrect value ${rpmMetadata.value.version}")
23+
}
24+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % sys.props("project.version"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Test configuration file!

src/sbt-test/rpm/snapshot-rpm/test

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Run the debian packaging.
2+
> rpm:package-bin
3+
$ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-SNAPSHOT.noarch.rpm
4+
5+
#Check release and version configured correctly
6+
> check-snapshot

0 commit comments

Comments
 (0)