Skip to content

Commit

Permalink
Merge pull request #296 from FibreFoX/bugfix_issue291
Browse files Browse the repository at this point in the history
fixes issue #291
  • Loading branch information
FibreFoX committed Jun 28, 2017
2 parents 13a5087 + abc46f0 commit 6bbb98a
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 7 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>com.zenjava</groupId>
<artifactId>javafx-maven-plugin</artifactId>
<version>8.8.4-SNAPSHOT</version>
<version>8.9.0-SNAPSHOT</version>

<packaging>maven-plugin</packaging>

Expand Down
53 changes: 47 additions & 6 deletions src/main/java/com/zenjava/javafx/maven/plugin/NativeMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -403,11 +403,21 @@ public class NativeMojo extends AbstractJfxToolsMojo {
protected boolean onlyCustomBundlers = false;

/**
* If you don't want to create a JNLP-bundle, set this to true to avoid that ugly warning
* in the build-log.
*
* @parameter property="jfx.skipJNLP" default-value=false
*/
protected boolean skipJNLP = false;

/**
* Most bundlers do not like dashes or anything than digits and dots as version number,
* therefor we remove all "non-digit"- and "non-dot"-chars. Most use-case is when having
* some "1.0.0-SNAPSHOT" as version-string. If you do know what you are doing, you can set
* this to true for skipping the removal of the "evil" chars.
*
* @since 8.8.0
*
* @parameter property="jfx.skipNativeVersionNumberSanitizing" default-value=false
*/
protected boolean skipNativeVersionNumberSanitizing = false;
Expand All @@ -430,6 +440,20 @@ public class NativeMojo extends AbstractJfxToolsMojo {
*/
protected boolean skipMainClassScanning = false;

/**
* Set this to true to disable the file-existence check on the keystore.
*
* @parameter property="jfx.skipKeyStoreChecking"
*/
protected boolean skipKeyStoreChecking = false;

/**
* Set this to true to remove "-keypass"-part while signing via jarsigner.
*
* @parameter property="jfx.skipKeypassWhileSigning"
*/
protected boolean skipKeypassWhileSigning = false;

protected Workarounds workarounds = null;

private static final String CFG_WORKAROUND_MARKER = "cfgWorkaroundMarker";
Expand Down Expand Up @@ -999,8 +1023,12 @@ private void signJarFiles() throws MojoFailureException, PackagerException, Mojo
}

private void checkSigningConfiguration() throws MojoFailureException {
if( !keyStore.exists() ){
throw new MojoFailureException("Keystore does not exist, use 'jfx:generate-key-store' command to make one (expected at: " + keyStore + ")");
if( skipKeyStoreChecking ){
getLog().info("Skipped checking if keystore exists.");
} else {
if( !keyStore.exists() ){
throw new MojoFailureException("Keystore does not exist, use 'jfx:generate-key-store' command to make one (expected at: " + keyStore + ")");
}
}

if( keyStoreAlias == null || keyStoreAlias.isEmpty() ){
Expand All @@ -1020,16 +1048,29 @@ private void checkSigningConfiguration() throws MojoFailureException {
private void signJar(File jarFile) throws MojoExecutionException {
List<String> command = new ArrayList<>();
command.add(getEnvironmentRelativeExecutablePath() + "jarsigner");

// check is required for non-file keystores, see #291
AtomicBoolean containsKeystore = new AtomicBoolean(false);

Optional.ofNullable(additionalJarsignerParameters).ifPresent(jarsignerParameters -> {
containsKeystore.set(jarsignerParameters.stream().filter(jarsignerParameter -> "-keystore".equalsIgnoreCase(jarsignerParameter.trim())).count() > 0);
command.addAll(jarsignerParameters);
});
command.add("-strict");
command.add("-keystore");
command.add(keyStore.getAbsolutePath());

if( !containsKeystore.get() ){
command.add("-keystore");
// might be null, because check might be skipped
if( keyStore != null ){
command.add(keyStore.getAbsolutePath());
}
}
command.add("-storepass");
command.add(keyStorePassword);
command.add("-keypass");
command.add(keyPassword);
if( !skipKeypassWhileSigning ){
command.add("-keypass");
command.add(keyPassword);
}
command.add(jarFile.getAbsolutePath());
command.add(keyStoreAlias);

Expand Down

0 comments on commit 6bbb98a

Please sign in to comment.