How can I sign standalone ProGuard Scala JAR systems?

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.

+6
java scala jar sbt proguard
source share
2 answers

I don’t think you need ProGuard and sign up to create a separate bank. You can simply pack all the necessary classes and the META-INF directory with the corresponding class of classes and the main class in a zip file, rename it to jar and run it. See this tutorial .

Sorry, I did not answer your question, I just do not understand why you want to sign your bank.

+1
source share

I ran into the same problem, and it seems that the problem was that the signatures of the solar banks were added by proguard to the META-INF directory. I just added them to the filtered files:

 override def makeInJarFilter (file :String) = super.makeInJarFilter(file) + ",!**/SUN_MICR.RSA,!**/SUN_MICR.SF" 

and now it works great.

+1
source share

All Articles