Skip to content

Commit 89d96cb

Browse files
committed
Add support for Java 9 multi release jars wvengen#61
- Always exclude META-INF/versions/** for library jars.
1 parent f0ec275 commit 89d96cb

File tree

1 file changed

+21
-19
lines changed

1 file changed

+21
-19
lines changed

src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,13 @@
6060

6161
public class ProGuardMojo extends AbstractMojo {
6262

63-
/**
63+
/**
64+
* Proguard doesn't support Java 9. It can hower work with multi version jars
65+
* we just need to ignore the higher versions.
66+
*/
67+
private static final String MULTI_VERSION_JAR_EXCLUSION = "(!META-INF/versions/**)";
68+
69+
/**
6470
* Set this to 'true' to bypass ProGuard processing entirely.
6571
*
6672
* @parameter property="proguard.skip"
@@ -475,12 +481,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
475481
// This may not be CompileArtifacts, maven 2.0.6 bug
476482
File file = getClasspathElement(getDependency(inc, mavenProject), mavenProject);
477483
inPath.add(file.toString());
478-
if(putLibraryJarsInTempDir){
479-
libraryJars.add(file);
480-
} else {
481-
args.add("-libraryjars");
482-
args.add(fileToString(file));
483-
}
484+
addLibraryJar(args, libraryJars, file);
484485
}
485486
}
486487
}
@@ -530,12 +531,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
530531
args.add(fileToString(file));
531532
} else {
532533
log.debug("--- ADD libraryjars:" + artifact.getArtifactId());
533-
if (putLibraryJarsInTempDir) {
534-
libraryJars.add(file);
535-
} else {
536-
args.add("-libraryjars");
537-
args.add(fileToString(file));
538-
}
534+
addLibraryJar(args, libraryJars, file);
539535
}
540536
}
541537
}
@@ -565,12 +561,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
565561

566562
if (libs != null) {
567563
for (String lib : libs) {
568-
if (putLibraryJarsInTempDir) {
569-
libraryJars.add(new File(lib));
570-
} else {
571-
args.add("-libraryjars");
572-
args.add(fileNameToString(lib));
573-
}
564+
addLibraryJar(args, libraryJars, new File(lib));
574565
}
575566
}
576567

@@ -691,6 +682,17 @@ public void execute() throws MojoExecutionException, MojoFailureException {
691682
}
692683
}
693684

685+
private void addLibraryJar(ArrayList<String> args, ArrayList<File> libraryJars, File file)
686+
{
687+
if (putLibraryJarsInTempDir) {
688+
libraryJars.add(file);
689+
} else {
690+
args.add("-libraryjars");
691+
args.add(fileToString(file));
692+
args.add(MULTI_VERSION_JAR_EXCLUSION);
693+
}
694+
}
695+
694696
private void attachTextFile(File theFile, String mainClassifier, String suffix) {
695697
final String classifier = (null == mainClassifier ? "" : mainClassifier+"-") + suffix;
696698
log.info("Attempting to attach "+suffix+" artifact");

0 commit comments

Comments
 (0)