Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin locks jar files #45

Open
wmarkow opened this issue Dec 1, 2016 · 0 comments
Open

Plugin locks jar files #45

wmarkow opened this issue Dec 1, 2016 · 0 comments

Comments

@wmarkow
Copy link

wmarkow commented Dec 1, 2016

I have a build organized in the way that a webstart-maven-plugin is used to create a webstart distribution only. Jars are signed later by maven-jarsigner-plugin. By default maven-jarsigner-plugin tries to sign the main artifact as well but it fails because main jar file looks locked:

[DEBUG] Processing C:\workspace\sample\target\sample-0.0.1-SNAPSHOT.jar
[DEBUG] cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_65\jre\..\bin\jarsigner.exe" -keystore C:\workspace\sample/etc/webstart/devstore.jks -storepass ***** C:\workspace\sample\target\sample-0.0.1-SNAPSHOT.jar dev"
[DEBUG] Executing: cmd.exe /X /C ""C:\Program Files\Java\jdk1.8.0_65\jre\..\bin\jarsigner.exe" -keystore C:\workspace\sample/etc/webstart/devstore.jks -storepass ***** C:\workspace\sample\target\sample-0.0.1-SNAPSHOT.jar dev"
[DEBUG] jarsigner: attempt to rename C:\workspace\sample\target\sample-0.0.1-SNAPSHOT.jar to C:\workspace\sample\target\sample-0.0.1-SNAPSHOT.jar.orig failed

I have track down that this lock is because of URLClassLoader instance created in org.codehaus.mojo.webstart.util.DefaultArtifactUtil.artifactContainsClass(Artifact, String) method.
This piece of code below fixes the problem but is Java 1.7+ specific:

@Override
public boolean artifactContainsClass( Artifact artifact, final String mainClass )
            throws MojoExecutionException
{
  ...
  URLClassLoader cl = new java.net.URLClassLoader( new URL[] { url } );
  ...
  // close the class loader
  try
  {
    cl.close();
  }
  catch( IOException e )
  {
    getLogger().warn( e.getMessage() );
  }
...
}

As a workaround I have configured the maven-jarsigner-plugin to not to sign the main artifact; it only signs the webstart distribution.

I'm using the 1.0-beta-7 version of the plugin. This version locks the jars. I have tested the 1.0.0-SNAPSHOT version as well which also locks the jars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant