使用sbt在胖子罐清单中添加git commit id

问题描述 投票:1回答:1

我正在使用sbt-assembly插件为我的scala项目构建一个胖jar。有没有一种方法可以在jar清单中包含git commit id,类似于git-commit-id-plugin对maven所做的事情。

谢谢

sbt sbt-assembly fatjar
1个回答
0
投票

老问题,但我要去...

您可以将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

此信息将存储在您的MANIFEST.MF文件中,该文件包含在sbt-assembly所生成的胖罐中:

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文件中。

© www.soinside.com 2019 - 2024. All rights reserved.