-
Notifications
You must be signed in to change notification settings - Fork 156
Add separate plugin parameter to filter dependencies #400
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -149,6 +149,7 @@ public class ProGuardMojo extends AbstractMojo { | |
|
|
||
| /** | ||
| * Specifies that project compile dependencies should be added as {@code -injars}. | ||
| * Filters for the dependencies can be specified with {@link #inDependenciesFilter}. | ||
| * | ||
| * @parameter default-value="false" | ||
| */ | ||
|
|
@@ -210,6 +211,14 @@ public class ProGuardMojo extends AbstractMojo { | |
| */ | ||
| protected String inLibsFilter; | ||
|
|
||
| /** | ||
| * Apply ProGuard classpathentry filters to all dependency jars when {@link #includeDependencyInjar} is used. | ||
| * e.g. {@code !META-INF/**,!META-INF/versions/9/**.class} | ||
| * | ||
| * @parameter | ||
| */ | ||
| protected String inDependenciesFilter; | ||
|
|
||
| /** | ||
| * Specifies the names of the output jars. If not set, the input jar is overwritten. | ||
| * | ||
|
|
@@ -600,19 +609,16 @@ public void execute() throws MojoExecutionException, MojoFailureException { | |
| if (inJarFile.exists()) { | ||
| args.add("-injars"); | ||
| StringBuilder filter = new StringBuilder(fileToString(inJarFile)); | ||
| if ((inFilter != null) || (!addMavenDescriptor)) { | ||
| List<String> filterList = new ArrayList<>(); | ||
|
|
||
| if (!addMavenDescriptor) { | ||
| filterList.add(MAVEN_DESCRIPTORS_FILTER); | ||
| } | ||
|
|
||
| if (inFilter != null) { | ||
| filterList.add(inFilter); | ||
| } | ||
|
|
||
| filter.append(createFilterString(filterList)); | ||
| List<String> filterList = new ArrayList<>(); | ||
| if (!addMavenDescriptor) { | ||
| filterList.add(MAVEN_DESCRIPTORS_FILTER); | ||
| } | ||
| if (inFilter != null) { | ||
| filterList.add(inFilter); | ||
| } | ||
| filter.append(createFilterString(filterList)); | ||
|
|
||
| args.add(filter.toString()); | ||
| } | ||
|
|
||
|
|
@@ -624,8 +630,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { | |
| if (!addMavenDescriptor) { | ||
| dependencyInjarFilterList.add(MAVEN_DESCRIPTORS_FILTER); | ||
| } | ||
| if (inFilter != null) { | ||
| dependencyInjarFilterList.add(inFilter); | ||
| if (inDependenciesFilter != null) { | ||
| dependencyInjarFilterList.add(inDependenciesFilter); | ||
|
Comment on lines
-627
to
+634
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another alternative to adding a new parameter could be to reuse the existing But maybe adding a new parameter (as currently done in this pull request) is still the cleanest approach.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For backwards compatibility this could use inFilter if inDependenciesFilter is null but inFilter non-null. But maybe it is better to not do too much complexity in name of compatibility. This is an easy change for users if they use the filters. |
||
| } | ||
| String dependencyInjarFilter = createFilterString(dependencyInjarFilterList); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Side note: This will require JDK >= 9 for building because it uses
javac --release, but I guess it is safe to assume that most users will have that.(This is not technically needed for the other changes in this pull request.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Requiring JDK 9 is fine. We could even change this to 11. I have no intention to maintain this for older versions.