You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by rf...@apache.org on 2015/02/19 20:54:08 UTC
svn commit: r1660993 -
/maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java
Author: rfscholte
Date: Thu Feb 19 19:54:08 2015
New Revision: 1660993
URL: http://svn.apache.org/r1660993
Log:
Add dependenciesToAnalyzeIncludes/excludes
Modified:
maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java
Modified: maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java?rev=1660993&r1=1660992&r2=1660993&view=diff
==============================================================================
--- maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java (original)
+++ maven/plugins/trunk/maven-jdeps-plugin/src/main/java/org/apache/maven/plugin/jdeps/AbstractJDepsMojo.java Thu Feb 19 19:54:08 2015
@@ -30,6 +30,8 @@ import java.util.Properties;
import java.util.StringTokenizer;
import org.apache.commons.lang.SystemUtils;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.ArtifactUtils;
import org.apache.maven.artifact.DependencyResolutionRequiredException;
import org.apache.maven.execution.MavenSession;
import org.apache.maven.plugin.AbstractMojo;
@@ -41,6 +43,7 @@ import org.apache.maven.plugins.annotati
import org.apache.maven.project.MavenProject;
import org.apache.maven.toolchain.Toolchain;
import org.apache.maven.toolchain.ToolchainManager;
+import org.codehaus.plexus.util.MatchPatterns;
import org.codehaus.plexus.util.StringUtils;
import org.codehaus.plexus.util.cli.CommandLineException;
import org.codehaus.plexus.util.cli.CommandLineUtils;
@@ -72,6 +75,39 @@ public abstract class AbstractJDepsMojo
private boolean failOnWarning;
/**
+ * Additional dependencies which should be analyzed besides the classes.
+ * Specify as {@code groupId:artifactId}, allowing ant-pattern.
+ *
+ * E.g.
+ * <pre>
+ * <dependenciesToAnalyzeIncludes>
+ * <include>*:*</include>
+ * <include>org.foo.*:*</include>
+ * <include>com.foo.bar:*</include>
+ * <include>dot.foo.bar:utilities</include>
+ * </dependenciesToAnalyzeIncludes>
+ * </pre>
+ */
+ @Parameter
+ private List<String> dependenciesToAnalyzeIncludes;
+
+ /**
+ * Subset of {@link AbstractJDepsMojo#dependenciesToAnalyzeIncludes} which should be not analyzed.
+ * Specify as {@code groupId:artifactId}, allowing ant-pattern.
+ *
+ * E.g.
+ * <pre>
+ * <dependenciesToAnalyzeExcludes>
+ * <exclude>org.foo.*:*</exclude>
+ * <exclude>com.foo.bar:*</exclude>
+ * <exclude>dot.foo.bar:utilities</exclude>
+ * </dependenciesToAnalyzeExcludes>
+ * </pre>
+ */
+ @Parameter
+ private List<String> dependenciesToAnalyzeExcludes;
+
+ /**
* Destination directory for DOT file output
*/
@Parameter( property = "jdeps.dotOutput" )
@@ -282,6 +318,32 @@ public abstract class AbstractJDepsMojo
{
// <classes> can be a pathname to a .class file, a directory, a JAR file, or a fully-qualified class name.
cmd.createArg().setFile( new File( getClassesDirectory() ) );
+
+ if ( dependenciesToAnalyzeIncludes != null )
+ {
+ MatchPatterns includes = MatchPatterns.from( dependenciesToAnalyzeIncludes );
+
+ MatchPatterns excludes;
+ if ( dependenciesToAnalyzeExcludes != null )
+ {
+ excludes = MatchPatterns.from( dependenciesToAnalyzeExcludes );
+ }
+ else
+ {
+ excludes = MatchPatterns.from( Collections.<String>emptyList() );
+ }
+
+ for ( Artifact artifact : project.getArtifacts() )
+ {
+ String versionlessKey = ArtifactUtils.versionlessKey( artifact );
+
+ if ( includes.matchesPatternStart( versionlessKey, true )
+ && !excludes.matchesPatternStart( versionlessKey, true ) )
+ {
+ cmd.createArg().setFile( artifact.getFile() );
+ }
+ }
+ }
}
private String getJDepsExecutable() throws IOException