我目前正在嘗試MANIFEST.MF在我的 build.sbt 中讀取先前創(chuàng)建的 jar 并將此清單文件的屬性用于packageOptions. 這樣做的原因是我正在使用sbt-osgi插件創(chuàng)建一個(gè) jar,然后想使用sbt-assembly創(chuàng)建一個(gè)胖 jar ,但保留之前創(chuàng)建的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,但不幸的是我無(wú)法弄清楚如何在我的packageOptions.
1 回答
MMMHUHU
TA貢獻(xiàn)1834條經(jīng)驗(yàn) 獲得超8個(gè)贊
循環(huán)依賴是由調(diào)用OsgiKeys.bundle.valueinside引起的readManifestFromOSGiBundle。我用這條線替換artifactPath.in(packageBin).in(Compile).value了它,現(xiàn)在它可以工作了。
添加回答
舉報(bào)
0/150
提交
取消
