Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<release>8</release>
Copy link
Contributor Author

@Marcono1234 Marcono1234 Apr 1, 2025

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.)

Copy link
Collaborator

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.

<compilerArgs>
<arg>-Xlint</arg>
</compilerArgs>
Expand Down
32 changes: 19 additions & 13 deletions src/main/java/com/github/wvengen/maven/proguard/ProGuardMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -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"
*/
Expand Down Expand Up @@ -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.
*
Expand Down Expand Up @@ -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());
}

Expand All @@ -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
Copy link
Contributor Author

@Marcono1234 Marcono1234 Apr 1, 2025

Choose a reason for hiding this comment

The 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 inLibsFilter for this case here as well. That might be a bit more appropriate than the previous inFilter.

But maybe adding a new parameter (as currently done in this pull request) is still the cleanest approach.

Copy link
Collaborator

Choose a reason for hiding this comment

The 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);

Expand Down
Loading