Skip to content
This repository was archived by the owner on Sep 3, 2020. It is now read-only.

Commit 1c91977

Browse files
committed
Update manifest file creation
It is annoying to update both the sbt version and the manifest version, therefore the manifest version is now updated automatically.
1 parent d321a80 commit 1c91977

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Scala Refactoring
44
Bundle-SymbolicName: org.scala-refactoring.library
5-
Bundle-Version: 0.14.0.qualifier
5+
Bundle-Version: version.qualifier
66
Require-Bundle: org.junit;bundle-version="4.11.0",
77
org.scala-lang.scala-library
88
Export-Package: scala.tools.refactoring,scala.tools.refactoring.analys

build.sbt

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,29 @@ credentials ++= {
107107
}
108108

109109
// sbt doesn't automatically load the content of the MANIFST.MF file, therefore
110-
// we have to do it here by ourselves Furthermore, the version format in the
111-
// MANIFEST.MF is `x.y.z.qualifier` but we need to replace the `qualifier` part
112-
// with a unique identifier otherwise OSGi can't find out which nightly build
113-
// is newest and therefore not all caches are updated with the correct version
114-
// of a nightly.
110+
// we have to do it here by ourselves. Furthermore, the version format in the
111+
// MANIFEST.MF is `version.qualifier`, which means that we have to replace
112+
// `version` by the actual version and `qualifier` with a unique identifier
113+
// otherwise OSGi can't find out which nightly build is newest and therefore
114+
// not all caches are updated with the correct version of a nightly.
115115
packageOptions in Compile in packageBin += {
116-
val m = Using.fileInputStream(new java.io.File("META-INF/MANIFEST.MF")) { in =>
116+
val m = Using.fileInputStream(new java.io.File("MANIFEST.MF.prototype")) { in =>
117117
val manifest = new java.util.jar.Manifest(in)
118118
val attr = manifest.getMainAttributes
119119
val key = "Bundle-Version"
120120
val versionSuffix = scalaBinaryVersion.value.replace('.', '_')
121+
// get the version but get rid of "-SNAPSHOT" suffix if it exists
122+
val v = {
123+
val v = version.value
124+
val i = v.lastIndexOf('-')
125+
if (i > 0)
126+
v.substring(0, i)
127+
else
128+
v
129+
}
121130
val date = new java.text.SimpleDateFormat("yyyyMMddHHmm").format(new java.util.Date)
122131
val sha = "git rev-parse --short HEAD".!!.trim
123-
attr.putValue(key, attr.getValue(key).replace("qualifier", s"$versionSuffix-$date-$sha"))
132+
attr.putValue(key, attr.getValue(key).replace("version.qualifier", s"$v.$versionSuffix-$date-$sha"))
124133
manifest
125134
}
126135
Package.JarManifest(m)

0 commit comments

Comments
 (0)