Skip to content

Commit 9958466

Browse files
colin-passiva
colin-passiv
authored and
a
committed
strip snapshot suffix safely (sbt#1004)
1 parent a0c74b4 commit 9958466

File tree

5 files changed

+35
-6
lines changed

5 files changed

+35
-6
lines changed

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

+1-6
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ object RpmPlugin extends AutoPlugin {
105105
packageArchitecture in Rpm := "noarch",
106106
rpmMetadata := RpmMetadata(
107107
(packageName in Rpm).value,
108-
if (isSnapshot.value) stripSnapshot((version in Rpm).value) else (version in Rpm).value,
108+
(version in Rpm).value.stripSuffix("-SNAPSHOT"),
109109
rpmRelease.value,
110110
rpmPrefix.value,
111111
(packageArchitecture in Rpm).value,
@@ -163,11 +163,6 @@ 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-
}
171166
}
172167

173168
object RpmDeployPlugin extends AutoPlugin {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
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+
version in Rpm := "1"
21+
22+
TaskKey[Unit]("check-snapshot") := {
23+
assert(rpmRelease.value == "SNAPSHOT", s"RPM has incorrect value ${rpmRelease.value}")
24+
assert(rpmMetadata.value.version == "1", s"RPM has incorrect value ${rpmMetadata.value.version}")
25+
assert((version in Rpm).value == "1", s"RPM has incorrect value ${(version in Rpm).value}")
26+
}
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!
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-1-SNAPSHOT.noarch.rpm
4+
5+
#Check release and version configured correctly
6+
> check-snapshot

0 commit comments

Comments
 (0)