Permalink
Browse files

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.
  • Loading branch information...
kiritsuku committed Oct 29, 2017
1 parent d321a80 commit 1c919778b9061f98f2d8cd178627f9f240fa9b26
Showing with 17 additions and 8 deletions.
  1. +1 −1 META-INF/MANIFEST.MF → MANIFEST.MF.prototype
  2. +16 −7 build.sbt
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Scala Refactoring
Bundle-SymbolicName: org.scala-refactoring.library
Bundle-Version: 0.14.0.qualifier
Bundle-Version: version.qualifier
Require-Bundle: org.junit;bundle-version="4.11.0",
org.scala-lang.scala-library
Export-Package: scala.tools.refactoring,scala.tools.refactoring.analys
@@ -107,20 +107,29 @@ credentials ++= {
}

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

0 comments on commit 1c91977

Please sign in to comment.