Skip to content

Commit

Permalink
Update ProGuardMojo.java
Browse files Browse the repository at this point in the history
wvengen#211 allow to preserve the manifest file
  • Loading branch information
Bartimmermans committed Apr 5, 2022
1 parent 889aa6c commit f92c113
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,13 @@ public class ProGuardMojo extends AbstractMojo {
*/
private boolean appendClassifier;

/**
* Set to true to include META-INF/MANIFEST.MF file
*
* @parameter default-value="false"
*/
private boolean addManifest;

/**
* Set to true to include META-INF/maven/** maven descriptor
*
Expand Down Expand Up @@ -531,15 +538,19 @@ public void execute() throws MojoExecutionException, MojoFailureException {
File file = getClasspathElement(entry.getKey(), mavenProject);
inPath.add(file.toString());
StringBuilder filter = new StringBuilder(fileToString(file));
filter.append("(!META-INF/MANIFEST.MF");
List<String> filterList = new ArrayList<>();
if (!addManifest) {
filterList.add("!META-INF/MANIFEST.MF");
}
if (!addMavenDescriptor) {
filter.append(",");
filter.append("!META-INF/maven/**");
filterList.add("!META-INF/maven/**");
}
if (entry.getValue().filter != null) {
filter.append(",").append(entry.getValue().filter);
filterList.add(entry.getValue().filter);
}
if (filterList.size() > 0){
filter.append("(").append(String.join(",",filterList)).append( ")");
}
filter.append(")");
args.add("-injars");
args.add(filter.toString());
}
Expand Down

0 comments on commit f92c113

Please # to comment.