Skip to content

Commit 849d9bc

Browse files
committed
Update manifest file creation
Since it is annoying to update both the sbt version and the manifest version, the manifest version is now updated automatically.
1 parent 80867b8 commit 849d9bc

File tree

2 files changed

+32
-7
lines changed

2 files changed

+32
-7
lines changed

MANIFEST.MF.prototype

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Manifest-Version: 1.0
2+
Bundle-ManifestVersion: 2
3+
Bundle-Name: Scalariform
4+
Bundle-SymbolicName: scalariform
5+
Bundle-Version: version.qualifier
6+
Require-Bundle: org.scala-lang.scala-library,
7+
org.scala-lang.modules.scala-xml
8+
Bundle-ClassPath: .
9+
Export-Package: scalariform,
10+
scalariform.astselect,
11+
scalariform.formatter,
12+
scalariform.formatter.preferences,
13+
scalariform.lexer,
14+
scalariform.parser,
15+
scalariform.utils
16+
Bundle-RequiredExecutionEnvironment: JavaSE-1.6

build.sbt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -91,20 +91,29 @@ lazy val scalariform = (project
9191
libraryDependencies ++= scala2_11Dependencies.value,
9292
libraryDependencies += "org.scalatest" %% "scalatest" % "3.0.1" % "test",
9393
// sbt doesn't automatically load the content of the MANIFST.MF file, therefore
94-
// we have to do it here by ourselves Furthermore, the version format in the
95-
// MANIFEST.MF is `x.y.z.qualifier` but we need to replace the `qualifier` part
96-
// with a unique identifier otherwise OSGi can't find out which nightly build
97-
// is newest and therefore not all caches are updated with the correct version
98-
// of a nightly.
94+
// we have to do it here by ourselves. Furthermore, the version format in the
95+
// MANIFEST.MF is `version.qualifier`, which means that we have to replace
96+
// `version` by the actual version and `qualifier` with a unique identifier
97+
// otherwise OSGi can't find out which nightly build is newest and therefore
98+
// not all caches are updated with the correct version of a nightly.
9999
packageOptions in Compile in packageBin += {
100-
val m = Using.fileInputStream(file("scalariform/META-INF/MANIFEST.MF")) { in =>
100+
val m = Using.fileInputStream(new java.io.File("MANIFEST.MF.prototype")) { in =>
101101
val manifest = new java.util.jar.Manifest(in)
102102
val attr = manifest.getMainAttributes
103103
val key = "Bundle-Version"
104104
val versionSuffix = scalaBinaryVersion.value.replace('.', '_')
105+
// get the version but get rid of "-SNAPSHOT" suffix if it exists
106+
val v = {
107+
val v = version.value
108+
val i = v.lastIndexOf('-')
109+
if (i > 0)
110+
v.substring(0, i)
111+
else
112+
v
113+
}
105114
val date = new java.text.SimpleDateFormat("yyyyMMddHHmm").format(new java.util.Date)
106115
val sha = "git rev-parse --short HEAD".!!.trim
107-
attr.putValue(key, attr.getValue(key).replace("qualifier", s"$versionSuffix-$date-$sha"))
116+
attr.putValue(key, attr.getValue(key).replace("version.qualifier", s"$v.$versionSuffix-$date-$sha"))
108117
manifest
109118
}
110119
Package.JarManifest(m)

0 commit comments

Comments
 (0)