Skip to content

Commit

Permalink
The ProGuard mojo must accept include/exclude filters to avoid class …
Browse files Browse the repository at this point in the history
…files conflicts between Maven repo classes and ./target/classes directory classes
  • Loading branch information
lyubomyr-shaydariv committed Nov 11, 2015
1 parent 87c3d54 commit ab2e670
Showing 1 changed file with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.simpligility.maven.plugins.android.AbstractAndroidMojo;
import com.simpligility.maven.plugins.android.CommandExecutor;
import com.simpligility.maven.plugins.android.ExecutionException;
import com.simpligility.maven.plugins.android.IncludeExcludeSet;
import com.simpligility.maven.plugins.android.config.ConfigHandler;
import com.simpligility.maven.plugins.android.config.ConfigPojo;
import com.simpligility.maven.plugins.android.config.PullParameter;
Expand Down Expand Up @@ -32,6 +33,7 @@
import java.util.LinkedList;
import java.util.List;

import static com.simpligility.maven.plugins.android.InclusionExclusionResolver.filterArtifacts;
import static com.simpligility.maven.plugins.android.common.AndroidExtension.AAR;

/**
Expand Down Expand Up @@ -235,6 +237,54 @@ public class ProguardMojo extends AbstractAndroidMojo
@Parameter( defaultValue = "${plugin.artifacts}", required = true, readonly = true )
protected List< Artifact > pluginDependencies;

/**
* Skips transitive dependencies. May be useful if the target classes directory is populated with the
* {@code maven-dependency-plugin} and already contains all dependency classes.
*/
@Parameter( property = "skipDependencies", defaultValue = "false" )
private boolean skipDependencies;

/**
* Allows to include or exclude artifacts by type. The {@code include} parameter has higher priority than the
* {@code exclude} parameter. These two parameters can be overridden by the {@code artifactSet} parameter. Empty
* strings are ignored. Example:
* <pre>
* &lt;artifactTypeSet&gt;
* &lt;includes&gt;
* &lt;include&gt;aar&lt;/include&gt;
* &lt;includes&gt;
* &lt;excludes&gt;
* &lt;exclude&gt;jar&lt;/exclude&gt;
* &lt;excludes&gt;
* &lt;/artifactTypeSet&gt;
* </pre>
*/
@Parameter( property = "artifactTypeSet" )
private IncludeExcludeSet artifactTypeSet;

/**
* Allows to include or exclude artifacts by {@code groupId}, {@code artifactId}, and {@code versionId}. The
* {@code include} parameter has higher priority than the {@code exclude} parameter. These two parameters can
* override the {@code artifactTypeSet} and {@code skipDependencies} parameters. Artifact {@code groupId},
* {@code artifactId}, and {@code versionId} are specified by a string with the respective values separated using
* a colon character {@code :}. {@code artifactId} and {@code versionId} can be optional covering an artifact
* range. Empty strings are ignored. Example:
* <pre>
* &lt;artifactTypeSet&gt;
* &lt;includes&gt;
* &lt;include&gt;foo-group:foo-artifact:1.0-SNAPSHOT&lt;/include&gt;
* &lt;include&gt;bar-group:bar-artifact:1.0-SNAPSHOT&lt;/include&gt;
* &lt;include&gt;baz-group:*&lt;/include&gt;
* &lt;includes&gt;
* &lt;excludes&gt;
* &lt;exclude&gt;qux-group:qux-artifact:*&lt;/exclude&gt;
* &lt;excludes&gt;
* &lt;/artifactTypeSet&gt;
* </pre>
*/
@Parameter( property = "artifactSet" )
private IncludeExcludeSet artifactSet;

private static final Collection< String > ANDROID_LIBRARY_EXCLUDED_FILTER = Arrays
.asList( "org/xml/**", "org/w3c/**", "java/**", "javax/**" );

Expand Down Expand Up @@ -596,7 +646,9 @@ private List< ProGuardInput > getProjectDependencyFiles()
}

// we then add all its dependencies (incl. transitive ones), unless they're blacklisted
for ( Artifact artifact : getTransitiveDependencyArtifacts() )
for ( Artifact artifact : filterArtifacts( getTransitiveDependencyArtifacts(), skipDependencies,
artifactTypeSet.getIncludes(), artifactTypeSet.getExcludes(), artifactSet.getIncludes(),
artifactSet.getExcludes() ) )
{
if ( isBlacklistedArtifact( artifact ) )
{
Expand Down

0 comments on commit ab2e670

Please sign in to comment.