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

Commit

Permalink
Update manifest file creation
Browse files Browse the repository at this point in the history
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 1c91977
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
2 changes: 1 addition & 1 deletion META-INF/MANIFEST.MF → MANIFEST.MF.prototype
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 16 additions & 7 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1c91977

Please sign in to comment.