I created an application (on the command line) in Scala that I want to distribute as a standalone JAR. I build it with sbt:
import sbt._ class Project(info: ProjectInfo) extends DefaultProject(info) with ProguardProject { override def parallelExecution = true override def mainClass: Option[String] = // whatever override def libraryDependencies = Set( // whatever ) ++ super.libraryDependencies override def proguardOptions = List( "-keepclasseswithmembers public class * { public static void main(java.lang.String[]); }", "-dontoptimize", "-dontobfuscate", proguardKeepLimitedSerializability, proguardKeepAllScala, "-keep interface scala.ScalaObject" ) }
I can run my code using sbt run fine, and I can pack it and run ProGuard (I'm not interested in confusing - the project will be open source anyway), I just use it to create a standalone JAR). So, I end up with a .min.jar file created in target / scala_2.8.0 /
Here it gets complicated. If I run this JAR, I get:
Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for main manifest attributes
Well, I did not sign it.
So, I generate the signature key as follows:
keytool -keystore ~/.keystore -genkey -alias tom
And then, following the Java documentation, I try to sign a JAR:
jarsigner -signedjar [whatever].jar -keystore ~/.keystore target/scala_2.8.0/[whatever]-1.0.min.jar tom
This tells me:
Enter Passphrase for keystore: Warning: The signer certificate will expire within six months.
Good, thatβs good. Now of course it will work!
$ java -jar [whatever].jar Exception in thread "main" java.lang.SecurityException: Invalid signature file digest for Manifest main attributes
I donβt know where to start. I am relatively new to the Java platform.
java scala jar sbt proguard
Tom morris
source share