protected void signOrRenameJars ( ) throws MojoExecutionException { if ( sign != null ) { try { ClassLoader loader = getCompileClassLoader ( ) ; sign . init ( getWorkDirectory ( ) , getLog ( ) . isDebugEnabled ( ) , signTool , securityDispatcher , loader ) ; } catch ( MalformedURLException e ) { throw new MojoExecutionException ( "Could not create classloader" , e ) ; } if ( unsignAlreadySignedJars ) { removeExistingSignatures ( getLibDirectory ( ) ) ; } if ( isPack200 ( ) ) { //TODO tchemit use a temporary directory to pack-unpack // http://java.sun.com/j2se/1.5.0/docs/guide/deployment/deployment-guide/pack200.html // we need to pack then unpack the files before signing them unpackJars ( getLibDirectory ( ) ) ; // As out current Pack200 ant tasks don't give us the ability to use a temporary area for // creating those temporary packing, we have to delete the temporary files. ioUtil . deleteFiles ( getLibDirectory ( ) , unprocessedPack200FileFilter ) ; // specs says that one should do it twice when there are unsigned jars?? // Pack200.unpackJars( applicationDirectory, updatedPack200FileFilter ); } if ( MapUtils . isNotEmpty ( updateManifestEntries ) ) { updateManifestEntries ( getLibDirectory ( ) ) ; } int signedJars = signJars ( getLibDirectory ( ) ) ; if ( signedJars != getModifiedJnlpArtifacts ( ) . size ( ) ) { throw new IllegalStateException ( "The number of signed artifacts (" + signedJars + ") differ from the number of modified " + "artifacts (" + getModifiedJnlpArtifacts ( ) . size ( ) + "). Implementation error" ) ; } } else { makeUnprocessedFilesFinal ( getLibDirectory ( ) ) ; } if ( isPack200 ( ) ) { verboseLog ( "-- Pack jars" ) ; pack200Jars ( getLibDirectory ( ) , processedJarFileFilter ) ; } }
If sign is enabled sign the jars otherwise rename them into final jars