使用Build.scala向MANIFEST.MF添加自定义键值对似乎不起作用。这是我的代码:
import sbt._
import Keys._
import java.util.Date
object Build extends Build {
packageOptions in (Compile, packageBin) +=
Package.ManifestAttributes( "Build" -> "true" )
}
当我添加:
packageOptions in (Compile, packageBin) +=
Package.ManifestAttributes( "Sign" -> "true" )
到我的build.sbt然后只有Sign
到达我的MANIFEST.MF。有什么想法吗?
答案 0 :(得分:7)
我想你可能想要这样的东西(注意manifestSettings
添加到项目的设置中。)
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: _*)
}
然后你应该能够调用package
并拥有一个带有额外清单条目的jar。
要获得("Buid" -> <current time>)
,manifestSettings
应为
lazy val manifestSettings = Seq(
packageOptions in (Compile, packageBin) +=
Package.ManifestAttributes( "Build" -> new Date().toString() )
)