亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

使用 SBT 從另一個 jar 中讀取 ManifestAttributes

使用 SBT 從另一個 jar 中讀取 ManifestAttributes

米琪卡哇伊 2022-07-27 09:53:36
我目前正在嘗試MANIFEST.MF在我的 build.sbt 中讀取先前創建的 jar 并將此清單文件的屬性用于packageOptions. 這樣做的原因是我正在使用sbt-osgi插件創建一個 jar,然后想使用sbt-assembly創建一個胖 jar ,但保留之前創建的MANIFEST.MF.到目前為止,這是我想出的:import java.io.InputStreamimport java.nio.file.StandardCopyOptionimport java.util.jar.JarFileimport java.util.zip.ZipEntryimport sbt.Package.ManifestAttributesimport scala.collection.JavaConverters._import scala.reflect.io.Directorylazy val readManifestFromOSGiBundle = taskKey[Seq[(String, String)]]("Reads the MANIFEST.MF of the jar built by the OSGi plugin")readManifestFromOSGiBundle in Compile := {  val uri = OsgiKeys.bundle.value  val jarFile = new JarFile(uri)  jarFile.getManifest.getMainAttributes.asScala.map(keyValue => (keyValue._1.toString, keyValue._2.toString)).toSeq}packageOptions := {  val manifestAttributes = readManifestFromOSGiBundle.value: Seq[(String, String)]  Seq(ManifestAttributes(manifestAttributes: _*))}清單屬性已正確讀取readManifestFromOSGiBundle,但不幸的是我無法弄清楚如何在我的packageOptions.
查看完整描述

1 回答

?
MMMHUHU

TA貢獻1834條經驗 獲得超8個贊

循環依賴是由調用OsgiKeys.bundle.valueinside引起的readManifestFromOSGiBundle。我用這條線替換artifactPath.in(packageBin).in(Compile).value了它,現在它可以工作了。



查看完整回答
反對 回復 2022-07-27
  • 1 回答
  • 0 關注
  • 117 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號