Skip to content

Commit 076aa6d

Browse files
Merge pull request #103 from NkD/feature/add-parameter-inlibsfilter
add parameter inLibsFilter
2 parents a394a31 + 2b56e5c commit 076aa6d

File tree

2 files changed

+30
-5
lines changed

2 files changed

+30
-5
lines changed

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

+24-5
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,13 @@ public class ProGuardMojo extends AbstractMojo {
187187
*/
188188
protected String inFilter;
189189

190+
/**
191+
* Apply ProGuard classpathentry Filters to all input lib jars. e.g. <code>!META-INF/**,!META-INF/versions/9/**.class</code>
192+
*
193+
* @parameter
194+
*/
195+
protected String inLibsFilter;
196+
190197
/**
191198
* Specifies the names of the output jars. If attach=true the value ignored and name constructed base on classifier
192199
* If empty input jar would be overdriven.
@@ -372,6 +379,18 @@ private String fileToString(File file) {
372379
return fileNameToString(file.toString());
373380
}
374381

382+
private String libFileToStringWithInLibsFilter(File file) {
383+
return libFileToStringWithInLibsFilter(file.toString());
384+
}
385+
386+
private String libFileToStringWithInLibsFilter(String file) {
387+
StringBuilder filter = new StringBuilder(fileNameToString(file));
388+
if ((inLibsFilter != null)) {
389+
filter.append("(").append(inLibsFilter).append(")");
390+
}
391+
return filter.toString();
392+
}
393+
375394
private boolean useArtifactClassifier() {
376395
return appendClassifier && ((attachArtifactClassifier != null) && (attachArtifactClassifier.length() > 0));
377396
}
@@ -516,7 +535,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
516535
libraryJars.add(file);
517536
} else {
518537
args.add("-libraryjars");
519-
args.add(fileToString(file));
538+
args.add(libFileToStringWithInLibsFilter(file));
520539
}
521540
}
522541
}
@@ -570,7 +589,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
570589
libraryJars.add(file);
571590
} else {
572591
args.add("-libraryjars");
573-
args.add(fileToString(file));
592+
args.add(libFileToStringWithInLibsFilter(file));
574593
}
575594
}
576595
}
@@ -605,7 +624,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
605624
libraryJars.add(new File(lib));
606625
} else {
607626
args.add("-libraryjars");
608-
args.add(fileNameToString(lib));
627+
args.add(libFileToStringWithInLibsFilter(lib));
609628
}
610629
}
611630
}
@@ -638,15 +657,15 @@ public void execute() throws MojoExecutionException, MojoFailureException {
638657
File subDir = new File(tempLibraryjarsDir, String.valueOf(directoryIndex));
639658
FileUtils.copyDirectory(libraryJar, subDir);
640659
args.add("-libraryjars");
641-
args.add(fileToString(subDir));
660+
args.add(libFileToStringWithInLibsFilter(subDir));
642661
}
643662
} catch (IOException e) {
644663
throw new MojoFailureException("Can't copy to temporary libraryJars directory", e);
645664
}
646665
directoryIndex++;
647666
}
648667
args.add("-libraryjars");
649-
args.add(fileToString(commonDir));
668+
args.add(libFileToStringWithInLibsFilter(commonDir));
650669
}
651670

652671
File mappingFile = new File(outputDirectory, mappingFileName);

src/site/apt/index.apt

+6
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@ proguard-maven-plugin
3131
<inFilter>!org/microemu/app/classloader/**</inFilter>
3232
---
3333

34+
** You can use <<<inLibsFilter>>> to apply ProGuard {{{http://proguard.sourceforge.net/manual/usage.html#filters}classpathentry Filters}} to all input lib jars
35+
36+
---
37+
<inLibsFilter>!META-INF/versions/**</inLibsFilter>
38+
---
39+
3440
** You can use <<<outFilter>>> to apply ProGuard {{{http://proguard.sourceforge.net/manual/usage.html#filters}classpathentry Filters}} to output jar
3541

3642
---

0 commit comments

Comments
 (0)