How to add custom lines to MANIFEST.MF?
Asked Answered
P

1

5

Adding custom key-value-pairs to the MANIFEST.MF using Build.scala seems not to work. Here is my code:

import sbt._
import Keys._
import java.util.Date

object Build extends Build {

  packageOptions in (Compile, packageBin) +=
    Package.ManifestAttributes( "Build" -> "true" )

}

When I add:

packageOptions in (Compile, packageBin) +=
  Package.ManifestAttributes( "Sign" -> "true" )

To my build.sbt then only Sign reaches my MANIFEST.MF. Any thoughts?

Piccoloist answered 8/5, 2014 at 15:46 Comment(0)
O
7

I think you may want something like this (note the manifestSettings added to the settings of the project).

import sbt._
import Keys._
import java.util.Date
import sbt.Package.ManifestAttributes

object MyBuild extends Build {

  lazy val manifestSettings = Seq(
    packageOptions in (Compile, packageBin) += 
         Package.ManifestAttributes( "Build" -> "true" )
  )

  lazy val root = Project(id = "root", base = file(".")).settings(manifestSettings: _*)

}

Then you should be able to call package and have the a jar with the extra manifest entry.

Edit

To get the ("Buid" -> <current time>) the manifestSettings should be

lazy val manifestSettings = Seq(
  packageOptions in (Compile, packageBin) += 
           Package.ManifestAttributes( "Build" -> new Date().toString() )
)
Obligor answered 8/5, 2014 at 20:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.