如何使用sbt发布使用ProGuard jar进行模糊处理?

时间:2016-01-18 18:09:09

标签: sbt proguard sbt-proguard

我正在尝试使用sbt发布由ProGuard jar进行模糊处理。到目前为止,我有这个代码,但它没有将混淆的jar推入到sbt publish-local的本地ivy2仓库中:

artifact in (Proguard, ProguardKeys.proguard) ~= {
  art => art.copy(`classifier` = Some("proguard"))
}
addArtifact(Artifact("myJar", "jar", "jar"), assembly in ProguardKeys.proguard)
publishArtifact in ProguardKeys.proguard := true 

你以前做过这些事情还是有任何想法?

谢谢

1 个答案:

答案 0 :(得分:2)

这是诀窍:

// do not publish source, javadoc and default jar
publishArtifact in (Compile, packageBin) := false
publishArtifact in (Compile, packageDoc) := false
publishArtifact in (Compile, packageSrc) := false

// add the Proguard jar for publishing
addArtifact(artifact in (Compile, ProguardKeys.proguard), (ProguardKeys.proguard in Proguard) map { xs => xs.head })

使用此配置,我禁用发布源,javadoc和默认jar,并添加由Proguard生成的jar以进行发布。现在publish[Local]任务只发布pom和Proguard jar。