Permalink
Browse files

Merge pull request #145 from indrajitr/jar-manifests

Add the standard main manifest attributes with packageOptions
  • Loading branch information...
2 parents 10aa2d6 + 952089b commit db14184d8654d1dc6c6fa83c8cf056d43cd47720 @harrah committed Aug 8, 2011
Showing with 18 additions and 3 deletions.
  1. +3 −1 main/Defaults.scala
  2. +15 −2 main/actions/Package.scala
View
4 main/Defaults.scala
@@ -310,7 +310,9 @@ object Defaults extends BuildCommon
artifactName in GlobalScope :== ( Artifact.artifactName _ )
)
lazy val packageConfig: Seq[Setting[_]] = Seq(
- packageOptions in packageBin <<= (packageOptions, mainClass in packageBin) map { _ ++ _.map(Package.MainClass.apply).toList }
+ packageOptions in packageBin <<= (packageOptions, mainClass in packageBin, name, version, homepage, organization, organizationName) map { (p, main, name, ver, h, org, orgName) =>
+ p ++ main.map(Package.MainClass.apply) :+ Package.addSpecManifestAttributes(name, ver, orgName) :+ Package.addImplManifestAttributes(name, ver, h, org, orgName) },
+ packageOptions in packageSrc <<= (packageOptions, name, version, organizationName) map { _ :+ Package.addSpecManifestAttributes(_, _, _) }
) ++
packageTasks(packageBin, packageBinTask) ++
packageTasks(packageSrc, packageSrcTask) ++
View
17 main/actions/Package.scala
@@ -51,10 +51,9 @@ object Package
final class Configuration(val sources: Seq[(File, String)], val jar: File, val options: Seq[PackageOption])
def apply(conf: Configuration, cacheFile: File, log: Logger)
{
- import conf._
val manifest = new Manifest
val main = manifest.getMainAttributes
- for(option <- options)
+ for(option <- conf.options)
{
option match
{
@@ -86,6 +85,20 @@ object Package
if(main.getValue(version) eq null)
main.put(version, "1.0")
}
+ def addSpecManifestAttributes(name: String, version: String, orgName: String): PackageOption =
+ {
+ import Attributes.Name._
+ val attribKeys = Seq(SPECIFICATION_TITLE, SPECIFICATION_VERSION, SPECIFICATION_VENDOR)
+ val attribVals = Seq(name, version, orgName)
+ ManifestAttributes(attribKeys zip attribVals : _*)
+ }
+ def addImplManifestAttributes(name: String, version: String, homepage: Option[java.net.URL], org: String, orgName: String): PackageOption =
+ {
+ import Attributes.Name._
+ val attribKeys = Seq(IMPLEMENTATION_TITLE, IMPLEMENTATION_VERSION, IMPLEMENTATION_VENDOR, IMPLEMENTATION_VENDOR_ID)
+ val attribVals = Seq(name, version, orgName, org)
+ ManifestAttributes((attribKeys zip attribVals) ++ { homepage map(h => (IMPLEMENTATION_URL, h.toString)) } : _*)
+ }
def makeJar(sources: Seq[(File, String)], jar: File, manifest: Manifest, log: Logger)
{
log.info("Packaging " + jar.getAbsolutePath + " ...")

0 comments on commit db14184

Please sign in to comment.