【发布时间】:2019-01-08 10:09:32
【问题描述】:
我正在使用 sbt-assembly 插件为我的 scala 项目构建一个胖 Jar。有没有办法可以在 jar 清单中包含 git commit id,类似于 git-commit-id-plugin 为 maven 所做的事情。
谢谢
【问题讨论】:
标签: sbt sbt-assembly fatjar
我正在使用 sbt-assembly 插件为我的 scala 项目构建一个胖 Jar。有没有办法可以在 jar 清单中包含 git commit id,类似于 git-commit-id-plugin 为 maven 所做的事情。
谢谢
【问题讨论】:
标签: sbt sbt-assembly fatjar
老问题,但我去...
您可以使用带有 sbt-assembly 的 sbt-git 插件在您的 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
此信息将存储在您的 MANIFEST.MF 文件中,该文件包含在 sbt-assembly 生成的 fat jar 中:
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 文件中。
【讨论】: