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

Commit

Permalink
Browse files Browse the repository at this point in the history
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 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
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2 Bundle-ManifestVersion: 2
Bundle-Name: Scala Refactoring Bundle-Name: Scala Refactoring
Bundle-SymbolicName: org.scala-refactoring.library 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", Require-Bundle: org.junit;bundle-version="4.11.0",
org.scala-lang.scala-library org.scala-lang.scala-library
Export-Package: scala.tools.refactoring,scala.tools.refactoring.analys Export-Package: scala.tools.refactoring,scala.tools.refactoring.analys
Expand Down
23 changes: 16 additions & 7 deletions build.sbt
Expand Up @@ -107,20 +107,29 @@ credentials ++= {
} }


// sbt doesn't automatically load the content of the MANIFST.MF file, therefore // 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 // 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 // MANIFEST.MF is `version.qualifier`, which means that we have to replace
// with a unique identifier otherwise OSGi can't find out which nightly build // `version` by the actual version and `qualifier` with a unique identifier
// is newest and therefore not all caches are updated with the correct version // otherwise OSGi can't find out which nightly build is newest and therefore
// of a nightly. // not all caches are updated with the correct version of a nightly.
packageOptions in Compile in packageBin += { 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 manifest = new java.util.jar.Manifest(in)
val attr = manifest.getMainAttributes val attr = manifest.getMainAttributes
val key = "Bundle-Version" val key = "Bundle-Version"
val versionSuffix = scalaBinaryVersion.value.replace('.', '_') 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 date = new java.text.SimpleDateFormat("yyyyMMddHHmm").format(new java.util.Date)
val sha = "git rev-parse --short HEAD".!!.trim 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 manifest
} }
Package.JarManifest(m) Package.JarManifest(m)
Expand Down

0 comments on commit 1c91977

Please sign in to comment.