Skip to content

Commit 9c39d70

Browse files
committed
Add support for Java 9 multi release jars wvengen#61
- A property for library jar exclusions (libraryJarExclusion)
1 parent f0ec275 commit 9c39d70

File tree

1 file changed

+24
-20
lines changed

1 file changed

+24
-20
lines changed

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

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060

6161
public class ProGuardMojo extends AbstractMojo {
6262

63-
/**
63+
/**
6464
* Set this to 'true' to bypass ProGuard processing entirely.
6565
*
6666
* @parameter property="proguard.skip"
@@ -123,7 +123,13 @@ public class ProGuardMojo extends AbstractMojo {
123123
* @parameter default-value="false"
124124
*/
125125
private boolean putLibraryJarsInTempDir;
126-
126+
127+
/**
128+
* Sets an exclude for all library jars, eg: (!META-INF/versions/**)
129+
*
130+
* @parameter default-value=""
131+
*/
132+
private String libraryJarExclusion;
127133

128134
/**
129135
* Specifies that project compile dependencies should be added as injar.
@@ -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,19 @@ 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+
if (libraryJarExclusion != null) {
693+
args.add(libraryJarExclusion);
694+
}
695+
}
696+
}
697+
694698
private void attachTextFile(File theFile, String mainClassifier, String suffix) {
695699
final String classifier = (null == mainClassifier ? "" : mainClassifier+"-") + suffix;
696700
log.info("Attempting to attach "+suffix+" artifact");

0 commit comments

Comments
 (0)