我正在使用 sbt-assembly 插件为我的 scala 项目构建一个 fat Jar。有没有一种方法可以在 jar list 中包含 git commit id,类似于 git-commit-id-plugin
为 maven 所做的事情。
谢谢
最佳答案
老问题,但我去...
你可以使用 sbt-git带有 sbt-assembly 的插件,用于在您的 MANIFEST.MF
文件中包含 git 信息。
要将信息添加到您的 MANIFEST.MF
文件中,您可以使用 packageOptions
sbt 键以这种方式:
import sbt.Package.ManifestAttributes
import com.typesafe.sbt.SbtGit.git
packageOptions := Seq(ManifestAttributes(("Repository-Commit", git.gitHeadCommit.value.get)))
请看这里的例子:spark-authorizer
此信息将存储在由 sbt-assembly 生成的 fat jar 中包含的 MANIFEST.MF
文件中:
Manifest-Version: 1.0
Implementation-Title: spark-authorizer
Repository-Commit: 12538262c1be14800eb820163de6c46cdbd69c99
Implementation-Version: 0.1.0-SNAPSHOT
Specification-Vendor: de.example.playground.spark.authorizer
Specification-Title: spark-authorizer
Implementation-Vendor-Id: de.example.playground.spark.authorizer
Specification-Version: 0.1.0-SNAPSHOT
Implementation-Vendor: de.example.playground.spark.authorizer
您可以向 packageOptions
添加任意数量的值。所有这些都将包含在 MANIFEST.MF 文件中。
关于sbt - 使用 sbt 在 fat jar list 中添加 git commit id,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51623091/