|
60 | 60 |
|
61 | 61 | public class ProGuardMojo extends AbstractMojo {
|
62 | 62 |
|
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 | + /** |
64 | 70 | * Set this to 'true' to bypass ProGuard processing entirely.
|
65 | 71 | *
|
66 | 72 | * @parameter property="proguard.skip"
|
@@ -475,12 +481,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
|
475 | 481 | // This may not be CompileArtifacts, maven 2.0.6 bug
|
476 | 482 | File file = getClasspathElement(getDependency(inc, mavenProject), mavenProject);
|
477 | 483 | 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); |
484 | 485 | }
|
485 | 486 | }
|
486 | 487 | }
|
@@ -530,12 +531,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
|
530 | 531 | args.add(fileToString(file));
|
531 | 532 | } else {
|
532 | 533 | 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); |
539 | 535 | }
|
540 | 536 | }
|
541 | 537 | }
|
@@ -565,12 +561,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
|
565 | 561 |
|
566 | 562 | if (libs != null) {
|
567 | 563 | 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)); |
574 | 565 | }
|
575 | 566 | }
|
576 | 567 |
|
@@ -691,6 +682,17 @@ public void execute() throws MojoExecutionException, MojoFailureException {
|
691 | 682 | }
|
692 | 683 | }
|
693 | 684 |
|
| 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 | + |
694 | 696 | private void attachTextFile(File theFile, String mainClassifier, String suffix) {
|
695 | 697 | final String classifier = (null == mainClassifier ? "" : mainClassifier+"-") + suffix;
|
696 | 698 | log.info("Attempting to attach "+suffix+" artifact");
|
|
0 commit comments