Skip to content

Commit 09e7334

Browse files
committed
Use SNAPSHOT for release when snapshot version
1 parent 2e8de40 commit 09e7334

File tree

5 files changed

+33
-3
lines changed

5 files changed

+33
-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
@@ -59,11 +59,16 @@ object RpmPlugin extends AutoPlugin {
5959

6060
}
6161

62+
private def stripSnapshot(version: String): String = {
63+
val suffixPosition = version.indexOf("-SNAPSHOT")
64+
version.slice(0, suffixPosition)
65+
}
66+
6267
override def projectConfigurations: Seq[Configuration] = Seq(Rpm)
6368

6469
override lazy val projectSettings = Seq(
6570
rpmOs := "Linux", // TODO - default to something else?
66-
rpmRelease := "1",
71+
rpmRelease := (if (isSnapshot.value) "SNAPSHOT" else "1"),
6772
rpmPrefix := None,
6873
rpmVendor := "", // TODO - Maybe pull in organization?
6974
rpmLicense := None,
@@ -105,7 +110,7 @@ object RpmPlugin extends AutoPlugin {
105110
packageArchitecture in Rpm := "noarch",
106111
rpmMetadata := RpmMetadata(
107112
(packageName in Rpm).value,
108-
(version in Rpm).value,
113+
if (isSnapshot.value) stripSnapshot((version in Rpm).value) else (version in Rpm).value,
109114
rpmRelease.value,
110115
rpmPrefix.value,
111116
(packageArchitecture in Rpm).value,
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
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+
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

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Run the debian packaging.
2+
> rpm:package-bin
3+
$ exists target/rpm/RPMS/noarch/rpm-test-0.1.0-SNAPSHOT.noarch.rpm

0 commit comments

Comments
 (0)