diff --git a/pom.xml b/pom.xml
index b0a9b2de..47487dda 100644
--- a/pom.xml
+++ b/pom.xml
@@ -52,7 +52,7 @@
scm:git:https://github.com/mojohaus/extra-enforcer-rules.git
scm:git:ssh://git@github.com/mojohaus/extra-enforcer-rules.git
- 1.7.0
+ HEAD
https://github.com/mojohaus/extra-enforcer-rules/tree/master
@@ -84,11 +84,6 @@
-
- org.apache.maven.shared
- maven-dependency-tree
- 3.2.1
-
org.apache.maven.shared
maven-common-artifact-filters
diff --git a/src/it/enforce-bytecode-version-direct-deps/invoker.properties b/src/it/enforce-bytecode-version-direct-deps/invoker.properties
new file mode 100644
index 00000000..54144c95
--- /dev/null
+++ b/src/it/enforce-bytecode-version-direct-deps/invoker.properties
@@ -0,0 +1 @@
+invoker.goals = enforcer:enforce
diff --git a/src/it/enforce-bytecode-version-direct-deps/pom.xml b/src/it/enforce-bytecode-version-direct-deps/pom.xml
new file mode 100644
index 00000000..c65ddd39
--- /dev/null
+++ b/src/it/enforce-bytecode-version-direct-deps/pom.xml
@@ -0,0 +1,47 @@
+
+
+ 4.0.0
+ test
+ enforce-bytecode-version-direct-deps
+ 1.0-SNAPSHOT
+ Check only direct dependencies
+
+
+
+
+ maven-enforcer-plugin
+ @enforcerPluginVersion@
+
+
+ @project.groupId@
+ @project.artifactId@
+ @project.version@
+
+
+
+
+
+ 1.5
+ false
+
+
+
+
+
+
+
+
+
+ junit
+ junit
+ 4.13.2
+ test
+
+
+ org.slf4j
+ slf4j-simple
+ 1.7.2
+
+
+
diff --git a/src/it/enforce-bytecode-version-direct-deps/verify.groovy b/src/it/enforce-bytecode-version-direct-deps/verify.groovy
new file mode 100644
index 00000000..9428b275
--- /dev/null
+++ b/src/it/enforce-bytecode-version-direct-deps/verify.groovy
@@ -0,0 +1,12 @@
+File file = new File(basedir, "build.log");
+assert file.exists();
+
+String text = file.getText("utf-8");
+
+// only direct dependency
+assert text.contains('[DEBUG] Analyzing artifact junit:junit:jar')
+assert text.contains('[DEBUG] Analyzing artifact org.slf4j:slf4j-simple:jar')
+
+// no transitive dependencies
+assert !text.contains('[DEBUG] Analyzing artifact org.hamcrest:hamcrest-core:jar')
+assert !text.contains('[DEBUG] Analyzing artifact org.slf4j:slf4j-api:jar')
diff --git a/src/it/enforce-bytecode-version-ignore-optional-dependencies/invoker.properties b/src/it/enforce-bytecode-version-ignore-optional-dependencies/invoker.properties
index f633336e..46b24412 100644
--- a/src/it/enforce-bytecode-version-ignore-optional-dependencies/invoker.properties
+++ b/src/it/enforce-bytecode-version-ignore-optional-dependencies/invoker.properties
@@ -1,2 +1 @@
-invoker.goals = enforcer:enforce install
-invoker.buildResult = success
+invoker.goals = enforcer:enforce
diff --git a/src/it/enforce-bytecode-version-ignore-optional-dependencies/pom.xml b/src/it/enforce-bytecode-version-ignore-optional-dependencies/pom.xml
index 09897486..a5a284c3 100644
--- a/src/it/enforce-bytecode-version-ignore-optional-dependencies/pom.xml
+++ b/src/it/enforce-bytecode-version-ignore-optional-dependencies/pom.xml
@@ -30,11 +30,6 @@
-
-
- compile
-
-
diff --git a/src/it/enforce-bytecode-version-ignore-optional-dependencies/verify.groovy b/src/it/enforce-bytecode-version-ignore-optional-dependencies/verify.groovy
new file mode 100644
index 00000000..c7de0903
--- /dev/null
+++ b/src/it/enforce-bytecode-version-ignore-optional-dependencies/verify.groovy
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+ File log = new File(basedir, 'build.log')
+ assert log.exists()
+
+assert log.getText().contains('[DEBUG] Skipping junit:junit:jar:4.13.2 (test) due to scope')
+assert log.getText().contains('[DEBUG] Skipping javax.transaction:jta:jar:1.1 (compile?) due to skip optional')
diff --git a/src/it/mojo-1799/pom.xml b/src/it/mojo-1799/pom.xml
index 041dd8f3..89e5f504 100644
--- a/src/it/mojo-1799/pom.xml
+++ b/src/it/mojo-1799/pom.xml
@@ -10,12 +10,12 @@
commons-logging
commons-logging
- 1.1.1
+ 1.3.0
org.slf4j
jcl-over-slf4j
- 1.6.1
+ 1.7.2
test
diff --git a/src/it/mojo-1799/verify.groovy b/src/it/mojo-1799/verify.groovy
index 6db2d44b..b8510d05 100644
--- a/src/it/mojo-1799/verify.groovy
+++ b/src/it/mojo-1799/verify.groovy
@@ -18,4 +18,4 @@
*/
File log = new File(basedir, 'build.log')
assert log.exists()
- assert log.getText().contains('[DEBUG] Skipping org.slf4j:jcl-over-slf4j:jar:1.6.1:test due to scope')
\ No newline at end of file
+ assert log.getText().contains('DEBUG] Skipping org.slf4j:jcl-over-slf4j:jar:1.7.2 (test) due to scope')
\ No newline at end of file
diff --git a/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/AbstractResolveDependencies.java b/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/AbstractResolveDependencies.java
index f8836be7..5cf2bbd6 100644
--- a/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/AbstractResolveDependencies.java
+++ b/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/AbstractResolveDependencies.java
@@ -1,113 +1,200 @@
package org.codehaus.mojo.extraenforcer.dependencies;
import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
+import java.util.Optional;
import java.util.Set;
import java.util.regex.Pattern;
+import java.util.stream.Collectors;
import org.apache.maven.RepositoryUtils;
import org.apache.maven.artifact.Artifact;
import org.apache.maven.enforcer.rule.api.AbstractEnforcerRule;
+import org.apache.maven.enforcer.rule.api.EnforcerRuleError;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.project.DefaultProjectBuildingRequest;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
-import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
-import org.apache.maven.shared.dependency.graph.DependencyNode;
+import org.apache.maven.model.DependencyManagement;
import org.eclipse.aether.RepositorySystem;
+import org.eclipse.aether.artifact.ArtifactTypeRegistry;
+import org.eclipse.aether.collection.CollectRequest;
+import org.eclipse.aether.collection.CollectResult;
+import org.eclipse.aether.collection.DependencyCollectionException;
+import org.eclipse.aether.graph.DefaultDependencyNode;
+import org.eclipse.aether.graph.Dependency;
+import org.eclipse.aether.graph.DependencyFilter;
+import org.eclipse.aether.graph.DependencyNode;
+import org.eclipse.aether.graph.DependencyVisitor;
import org.eclipse.aether.resolution.ArtifactRequest;
import org.eclipse.aether.resolution.ArtifactResolutionException;
import org.eclipse.aether.resolution.ArtifactResult;
+import org.eclipse.aether.util.filter.AndDependencyFilter;
+import org.eclipse.aether.util.filter.ScopeDependencyFilter;
/**
* Abstract rule for when the content of the artifacts matters.
*
* @author Robert Scholte
- *
*/
abstract class AbstractResolveDependencies extends AbstractEnforcerRule {
+ /**
+ * Optional list of dependency scopes to ignore. {@code test} and {@code provided} make sense here.
+ */
+ private List ignoredScopes = Collections.emptyList();
+
+ /**
+ * Only verify dependencies with one of these scopes
+ */
+ private List scopes = Collections.emptyList();
+
+ /**
+ * Ignore all dependencies which have {@code <optional>true</optional>}.
+ *
+ * @since 1.2
+ */
+ private boolean ignoreOptionals = false;
+
+ /**
+ * Specify if transitive dependencies should be searched (default) or only look at direct dependencies.
+ */
+ private boolean searchTransitive = true;
+
private final MavenSession session;
- private final RepositorySystem repositorySystem;
- private final DependencyGraphBuilder graphBuilder;
+ private final RepositorySystem repositorySystem;
- protected AbstractResolveDependencies(
- MavenSession session, RepositorySystem repositorySystem, DependencyGraphBuilder graphBuilder) {
+ protected AbstractResolveDependencies(MavenSession session, RepositorySystem repositorySystem) {
this.session = session;
this.repositorySystem = repositorySystem;
- this.graphBuilder = graphBuilder;
}
@Override
public void execute() throws EnforcerRuleException {
-
- ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
- buildingRequest.setProject(session.getCurrentProject());
-
- handleArtifacts(getDependenciesToCheck(buildingRequest));
+ handleArtifacts(getDependenciesToCheck());
}
protected abstract void handleArtifacts(Set artifacts) throws EnforcerRuleException;
- protected boolean isSearchTransitive() {
- return true;
+ private Set getDependenciesToCheck() throws EnforcerRuleException {
+ Set artifacts = null;
+ try {
+ Collection dependencies = collectProjectDependencies();
+ artifacts = resolveArtifacts(dependencies);
+ } catch (DependencyCollectionException | ArtifactResolutionException e) {
+ throw new EnforcerRuleError(e.getMessage(), e);
+ }
+ return artifacts;
}
- private Set getDependenciesToCheck(ProjectBuildingRequest buildingRequest) throws EnforcerRuleException {
- Set dependencies = null;
- try {
- DependencyNode node = graphBuilder.buildDependencyGraph(buildingRequest, null);
-
- if (isSearchTransitive()) {
- dependencies = getAllDescendants(node);
- } else if (node.getChildren() != null) {
- dependencies = new HashSet<>();
- for (DependencyNode depNode : node.getChildren()) {
- dependencies.add(depNode.getArtifact());
+ private Collection collectProjectDependencies() throws DependencyCollectionException {
+
+ ArtifactTypeRegistry artifactTypeRegistry =
+ session.getRepositorySession().getArtifactTypeRegistry();
+
+ DependencyFilter optionalFilter = createOptionalFilter();
+ DependencyFilter scopeFilter = createScopeDependencyFilter();
+ DependencyFilter dependencyFilter = AndDependencyFilter.newInstance(optionalFilter, scopeFilter);
+
+ List dependencies = session.getCurrentProject().getDependencies().stream()
+ .map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry))
+ .filter(d -> dependencyFilter == null
+ || dependencyFilter.accept(new DefaultDependencyNode(d), Collections.emptyList()))
+ .collect(Collectors.toList());
+
+ List managedDependencies = Optional.ofNullable(
+ session.getCurrentProject().getDependencyManagement())
+ .map(DependencyManagement::getDependencies)
+ .map(list -> list.stream()
+ .map(d -> RepositoryUtils.toDependency(d, artifactTypeRegistry))
+ .collect(Collectors.toList()))
+ .orElse(null);
+
+ CollectRequest collectRequest = new CollectRequest();
+ collectRequest.setManagedDependencies(managedDependencies);
+ collectRequest.setRepositories(session.getCurrentProject().getRemoteProjectRepositories());
+ collectRequest.setDependencies(dependencies);
+
+ CollectResult collectResult =
+ repositorySystem.collectDependencies(session.getRepositorySession(), collectRequest);
+
+ Set collectedDependencyNodes = new HashSet<>();
+ collectResult.getRoot().accept(new DependencyVisitor() {
+
+ int depth;
+
+ @Override
+ public boolean visitEnter(org.eclipse.aether.graph.DependencyNode node) {
+ if ((dependencyFilter == null || dependencyFilter.accept(node, Collections.emptyList()))
+ && node.getArtifact() != null) {
+ collectedDependencyNodes.add(node);
}
+ depth++;
+ return searchTransitive || depth <= 1;
}
- } catch (DependencyGraphBuilderException e) {
- throw new EnforcerRuleException(e.getMessage(), e);
- }
- return dependencies;
+
+ @Override
+ public boolean visitLeave(org.eclipse.aether.graph.DependencyNode node) {
+ depth--;
+ return true;
+ }
+ });
+
+ return collectedDependencyNodes;
}
- private Set getAllDescendants(DependencyNode node) {
- Set children = null;
- if (node.getChildren() != null) {
- children = new HashSet<>();
- for (DependencyNode depNode : node.getChildren()) {
- try {
- Artifact artifact = depNode.getArtifact();
- resolveArtifact(artifact);
- children.add(artifact);
-
- Set subNodes = getAllDescendants(depNode);
-
- if (subNodes != null) {
- children.addAll(subNodes);
- }
- } catch (ArtifactResolutionException e) {
- getLog().warn(e.getMessage());
- }
+ private DependencyFilter createOptionalFilter() {
+ if (!ignoreOptionals) {
+ return null;
+ }
+
+ return (node, parents) -> {
+ if (node.getDependency() != null && node.getDependency().isOptional()) {
+ getLog().debug(() -> "Skipping " + node + " due to skip optional");
+ return false;
}
+ return true;
+ };
+ }
+
+ private DependencyFilter createScopeDependencyFilter() {
+ if (scopes.isEmpty() && ignoredScopes.isEmpty()) {
+ return null;
}
- return children;
+
+ ScopeDependencyFilter scopeDependencyFilter = new ScopeDependencyFilter(scopes, ignoredScopes);
+ return (node, parents) -> {
+ if (!scopeDependencyFilter.accept(node, parents)) {
+ getLog().debug(() -> "Skipping " + node + " due to scope");
+ return false;
+ }
+ return true;
+ };
}
- private void resolveArtifact(Artifact artifact) throws ArtifactResolutionException {
- ArtifactRequest request = new ArtifactRequest();
- request.setRepositories(session.getCurrentProject().getRemoteProjectRepositories());
- request.setArtifact(RepositoryUtils.toArtifact(artifact));
+ private Set resolveArtifacts(Collection dependencies) throws ArtifactResolutionException {
- ArtifactResult artifactResult = repositorySystem.resolveArtifact(session.getRepositorySession(), request);
+ List requestArtifacts = dependencies.stream()
+ .map(d -> new ArtifactRequest()
+ .setDependencyNode(d)
+ .setRepositories(session.getCurrentProject().getRemoteProjectRepositories()))
+ .collect(Collectors.toList());
- artifact.setFile(artifactResult.getArtifact().getFile());
- artifact.setVersion(artifactResult.getArtifact().getVersion());
- artifact.setResolved(true);
+ List artifactResult =
+ repositorySystem.resolveArtifacts(session.getRepositorySession(), requestArtifacts);
+
+ return artifactResult.stream()
+ .map(result ->
+ result.getRequest().getDependencyNode().getDependency().setArtifact(result.getArtifact()))
+ .map(dependency -> {
+ Artifact artifact = RepositoryUtils.toArtifact(dependency.getArtifact());
+ artifact.setScope(dependency.getScope());
+ artifact.setOptional(dependency.getOptional());
+ return artifact;
+ })
+ .collect(Collectors.toSet());
}
/**
@@ -157,9 +244,13 @@ protected static String asRegex(String wildcard) {
protected class IgnorableDependency {
// TODO should be private, fix and remove SuppressWarnings
public Pattern groupId;
+
public Pattern artifactId;
+
public Pattern classifier;
+
public Pattern type;
+
public List ignores = new ArrayList<>();
public IgnorableDependency applyIgnoreClasses(String[] ignores, boolean indent) {
diff --git a/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/BanCircularDependencies.java b/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/BanCircularDependencies.java
index 52d7a170..781fcdf5 100644
--- a/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/BanCircularDependencies.java
+++ b/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/BanCircularDependencies.java
@@ -22,20 +22,13 @@
import javax.inject.Inject;
import javax.inject.Named;
-import java.util.HashSet;
import java.util.Set;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.enforcer.rule.api.AbstractEnforcerRule;
-import org.apache.maven.enforcer.rule.api.EnforcerRuleError;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.project.DefaultProjectBuildingRequest;
import org.apache.maven.project.MavenProject;
-import org.apache.maven.project.ProjectBuildingRequest;
-import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
-import org.apache.maven.shared.dependency.graph.DependencyGraphBuilderException;
-import org.apache.maven.shared.dependency.graph.DependencyNode;
+import org.eclipse.aether.RepositorySystem;
/**
* Bans circular dependencies on the classpath.
@@ -43,69 +36,30 @@
* @since 1.0-alpha-4
*/
@Named("banCircularDependencies")
-public class BanCircularDependencies extends AbstractEnforcerRule {
+public class BanCircularDependencies extends AbstractResolveDependencies {
- private final DependencyGraphBuilder graphBuilder;
private final MavenProject project;
- private final MavenSession session;
private String message;
@Inject
- public BanCircularDependencies(DependencyGraphBuilder graphBuilder, MavenProject project, MavenSession session) {
- this.graphBuilder = graphBuilder;
- this.project = project;
- this.session = session;
+ public BanCircularDependencies(MavenSession session, RepositorySystem repositorySystem) {
+ super(session, repositorySystem);
+ project = session.getCurrentProject();
}
- /**
- * {@inheritDoc}
- */
- public void execute() throws EnforcerRuleException {
-
- ProjectBuildingRequest buildingRequest = new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
- buildingRequest.setProject(project);
-
- Set artifacts = getDependenciesToCheck(buildingRequest);
- if (artifacts != null) {
- for (Artifact artifact : artifacts) {
- getLog().debug("groupId: " + artifact.getGroupId() + project.getGroupId());
- if (artifact.getGroupId().equals(project.getGroupId())) {
- getLog().debug("artifactId: " + artifact.getArtifactId() + " " + project.getArtifactId());
- if (artifact.getArtifactId().equals(project.getArtifactId())) {
- throw new EnforcerRuleException(getErrorMessage() + "\n " + artifact.getGroupId() + ":"
- + artifact.getArtifactId() + "\n ");
- }
- }
- }
- }
- }
-
- protected Set getDependenciesToCheck(ProjectBuildingRequest buildingRequest) throws EnforcerRuleError {
- Set dependencies;
- try {
- DependencyNode node = graphBuilder.buildDependencyGraph(buildingRequest, null);
- dependencies = getAllDescendants(node);
- } catch (DependencyGraphBuilderException e) {
- // otherwise we need to change the signature of this protected method
- throw new EnforcerRuleError(e);
- }
- return dependencies;
- }
-
- private Set getAllDescendants(DependencyNode node) {
- Set children = null;
- if (node.getChildren() != null) {
- children = new HashSet<>();
- for (DependencyNode depNode : node.getChildren()) {
- children.add(depNode.getArtifact());
- Set subNodes = getAllDescendants(depNode);
- if (subNodes != null) {
- children.addAll(subNodes);
+ @Override
+ protected void handleArtifacts(Set artifacts) throws EnforcerRuleException {
+ for (Artifact artifact : artifacts) {
+ getLog().debug("groupId: " + artifact.getGroupId() + project.getGroupId());
+ if (artifact.getGroupId().equals(project.getGroupId())) {
+ getLog().debug("artifactId: " + artifact.getArtifactId() + " " + project.getArtifactId());
+ if (artifact.getArtifactId().equals(project.getArtifactId())) {
+ throw new EnforcerRuleException(getErrorMessage() + "\n " + artifact.getGroupId() + ":"
+ + artifact.getArtifactId() + "\n ");
}
}
}
- return children;
}
private String getErrorMessage() {
diff --git a/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/BanDuplicateClasses.java b/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/BanDuplicateClasses.java
index af31cad2..6b1f9d95 100644
--- a/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/BanDuplicateClasses.java
+++ b/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/BanDuplicateClasses.java
@@ -41,7 +41,6 @@
import org.apache.maven.enforcer.rule.api.EnforcerRuleError;
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.execution.MavenSession;
-import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
import org.codehaus.plexus.util.FileUtils;
import org.eclipse.aether.RepositorySystem;
@@ -81,11 +80,6 @@ public class BanDuplicateClasses extends AbstractResolveDependencies {
*/
private List dependencies;
- /**
- * Only verify dependencies with one of these scopes
- */
- private List scopes;
-
/**
* If {@code true} do not fail the build when duplicate classes exactly match each other. In other words, ignore
* duplication if the bytecode in the class files match. Default is {@code false}.
@@ -93,9 +87,8 @@ public class BanDuplicateClasses extends AbstractResolveDependencies {
private boolean ignoreWhenIdentical;
@Inject
- protected BanDuplicateClasses(
- MavenSession session, RepositorySystem repositorySystem, DependencyGraphBuilder graphBuilder) {
- super(session, repositorySystem, graphBuilder);
+ protected BanDuplicateClasses(MavenSession session, RepositorySystem repositorySystem) {
+ super(session, repositorySystem);
}
@Override
@@ -133,10 +126,6 @@ protected void handleArtifacts(Set artifacts) throws EnforcerRuleExcep
Map classesSeen = new HashMap<>();
Set duplicateClassNames = new HashSet<>();
for (Artifact o : artifacts) {
- if (scopes != null && !scopes.contains(o.getScope())) {
- getLog().debug(() -> "Skipping " + o + " due to scope");
- continue;
- }
File file = o.getFile();
getLog().debug(() -> "Searching for duplicate classes in " + file);
if (file == null || !file.exists()) {
diff --git a/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/EnforceBytecodeVersion.java b/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/EnforceBytecodeVersion.java
index 251152ae..8a42c02b 100644
--- a/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/EnforceBytecodeVersion.java
+++ b/src/main/java/org/codehaus/mojo/extraenforcer/dependencies/EnforceBytecodeVersion.java
@@ -27,7 +27,6 @@
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.LinkedHashMap;
@@ -47,7 +46,6 @@
import org.apache.maven.shared.artifact.filter.AbstractStrictPatternArtifactFilter;
import org.apache.maven.shared.artifact.filter.StrictPatternExcludesArtifactFilter;
import org.apache.maven.shared.artifact.filter.StrictPatternIncludesArtifactFilter;
-import org.apache.maven.shared.dependency.graph.DependencyGraphBuilder;
import org.codehaus.plexus.util.IOUtil;
import org.eclipse.aether.RepositorySystem;
@@ -138,9 +136,8 @@ public class EnforceBytecodeVersion extends AbstractResolveDependencies {
}
@Inject
- protected EnforceBytecodeVersion(
- MavenSession session, RepositorySystem repositorySystem, DependencyGraphBuilder graphBuilder) {
- super(session, repositorySystem, graphBuilder);
+ protected EnforceBytecodeVersion(MavenSession session, RepositorySystem repositorySystem) {
+ super(session, repositorySystem);
}
static String renderVersion(int major, int minor) {
@@ -177,9 +174,6 @@ static String renderVersion(int major, int minor) {
*/
int maxJavaMinorVersionNumber = 0;
- /** Specify if transitive dependencies should be searched (default) or only look at direct dependencies. */
- private boolean searchTransitive = true;
-
/**
* @see AbstractStrictPatternArtifactFilter
*/
@@ -195,17 +189,6 @@ static String renderVersion(int major, int minor) {
*/
private boolean strict = false;
- /**
- * Optional list of dependency scopes to ignore. {@code test} and {@code provided} make sense here.
- */
- private String[] ignoredScopes;
-
- /**
- * Ignore all dependencies which have {@code <optional>true</optional>}.
- * @since 1.2
- */
- private boolean ignoreOptionals = false;
-
private List ignorableDependencies = new ArrayList<>();
@Override
@@ -230,11 +213,6 @@ protected void handleArtifacts(Set artifacts) throws EnforcerRuleExcep
}
}
- @Override
- protected boolean isSearchTransitive() {
- return searchTransitive;
- }
-
protected CharSequence getErrorMessage(Artifact artifact) {
return "Found Banned Dependency: " + artifact.getId() + "\n";
}
@@ -391,15 +369,6 @@ public void setMaxJavaMinorVersionNumber(int maxJavaMinorVersionNumber) {
this.maxJavaMinorVersionNumber = maxJavaMinorVersionNumber;
}
- /**
- * Sets the search transitive.
- *
- * @param theSearchTransitive the searchTransitive to set
- */
- public void setSearchTransitive(boolean theSearchTransitive) {
- this.searchTransitive = theSearchTransitive;
- }
-
/**
* Process module-info and Multi-Release JAR classes if true
* @param strict the strictness to set
@@ -416,7 +385,7 @@ public void setStrict(boolean strict) {
* @return the resulting set of dependencies
*/
private Set filterArtifacts(Set dependencies) {
- if (includes == null && excludes == null && ignoredScopes == null && !ignoreOptionals) {
+ if (includes == null && excludes == null) {
return dependencies;
}
@@ -430,12 +399,6 @@ private Set filterArtifacts(Set dependencies) {
Set result = new HashSet<>();
for (Artifact artifact : dependencies) {
- if (ignoredScopes != null && Arrays.asList(ignoredScopes).contains(artifact.getScope())) {
- continue;
- }
- if (ignoreOptionals && artifact.isOptional()) {
- continue;
- }
if (filter.include(artifact)) {
result.add(artifact);
}
diff --git a/src/site/apt/banCircularDependencies.apt.vm b/src/site/apt/banCircularDependencies.apt.vm
index c1e3fd60..f454f935 100644
--- a/src/site/apt/banCircularDependencies.apt.vm
+++ b/src/site/apt/banCircularDependencies.apt.vm
@@ -24,11 +24,18 @@
Ban Circular Dependencies
This rule checks the dependencies and fails if the groupId:artifactId combination exists in the list of direct or transitive dependencies.
-
- <>
- []
+ The following parameters are supported by this rule:
+
+ * <> - a list of scopes (e.g. test, provided) to include when scanning artifacts
+
+ * <> - a list of scopes (e.g. test, provided) to ignore when scanning artifacts
+
+ * <> - a boolean, if <<>> all dependencies which have <<<true>>> are ignored.
+
+ * <> - a boolean, specify if transitive dependencies should be searched (default) or only look at direct dependencies.
+
+ []
Sample Plugin Configuration:
diff --git a/src/site/apt/banDuplicateClasses.apt.vm b/src/site/apt/banDuplicateClasses.apt.vm
index 2d6746d4..e5765549 100644
--- a/src/site/apt/banDuplicateClasses.apt.vm
+++ b/src/site/apt/banDuplicateClasses.apt.vm
@@ -28,22 +28,27 @@ Ban Duplicate Classes
This rule checks the dependencies and fails if any class is present in more than one dependency.
- The following parameters are supported by this rule:
+ The following parameters are supported by this rule:
- * ignoreClasses - a list of classes to ignore duplicates of. Wildcards can be specified using the * character.
+ * <> - a list of classes to ignore duplicates of. Wildcards can be specified using the * character.
- * findAllDuplicates - a boolean to indicate whether the rule should find all duplicates or fail fast at the first duplicate. Defaults to <<>>.
+ * <> - a boolean to indicate whether the rule should find all duplicates or fail fast at the first duplicate. Defaults to <<>>.
- * ignoreWhenIdentical - when <<>> indicates duplicate classes don't fail the build when their bytecode exactly matches each other. Defaults to <<>>.
+ * <> - when <<>> indicates duplicate classes don't fail the build when their bytecode exactly matches each other. Defaults to <<>>.
- * message - an optional message to provide when duplicates are found.
-
- * dependencies - a list of dependencies for which you want to ignore specific classes.
+ * <> - an optional message to provide when duplicates are found.
- * scopes - only verify dependencies with one of these scopes
+ * <> - a list of dependencies for which you want to ignore specific classes.
- []
+ * <> - a list of scopes (e.g. test, provided) to include when scanning artifacts
+ * <> - a list of scopes (e.g. test, provided) to ignore when scanning artifacts
+
+ * <> - a boolean, if <<>> all dependencies which have <<<true>>> are ignored.
+
+ * <> - a boolean, specify if transitive dependencies should be searched (default) or only look at direct dependencies.
+
+ []
Sample Plugin Configuration:
diff --git a/src/site/apt/enforceBytecodeVersion.apt.vm b/src/site/apt/enforceBytecodeVersion.apt.vm
index 7f78569e..b2c08aac 100644
--- a/src/site/apt/enforceBytecodeVersion.apt.vm
+++ b/src/site/apt/enforceBytecodeVersion.apt.vm
@@ -27,25 +27,29 @@ Enforce Bytecode Version
This rule checks the dependencies transitively and fails if any class of any dependency is having its bytecode version higher than the one specified.
- The following parameters are supported by this rule:
+ The following parameters are supported by this rule:
- * maxJdkVersion - the maximum target jdk version in the 1.x form (e.g. 1.6, 1.7, 1.8, 1.9 or 6, 7, 8, 9, 10, 11...)
+ * <> - the maximum target jdk version in the 1.x form (e.g. 1.6, 1.7, 1.8, 1.9 or 6, 7, 8, 9, 10, 11...)
- * maxJavaMajorVersionNumber - an integer indicating the maximum bytecode major version number (cannot be specified if maxJdkVersion is present)
+ * <> - an integer indicating the maximum bytecode major version number (cannot be specified if maxJdkVersion is present)
- * maxJavaMinorVersionNumber - an integer indicating the maximum bytecode minor version number (cannot be specified if maxJdkVersion is present)
+ * <> - an integer indicating the maximum bytecode minor version number (cannot be specified if maxJdkVersion is present)
- * includes, excludes - optional lists of artifact patterns to include or exclude ([groupId]:[artifactId]:[type]:[version] with wildcards and optional segments)
+ * <>, <> - optional lists of artifact patterns to include or exclude ([groupId]:[artifactId]:[type]:[version] with wildcards and optional segments)
- * ignoreClasses - a list of classes to ignore bytecode version problems. Wildcards can be specified using the * character.
+ * <> - a list of classes to ignore bytecode version problems. Wildcards can be specified using the * character.
- * ignoredScopes - a list of scopes (e.g. test, provided) to ignore when scanning artifacts
+ * <> - a list of scopes (e.g. test, provided) to include when scanning artifacts
- * ignoreOptionals - a boolean, if <<>> all dependencies which have <<<true>>> are ignored.
+ * <> - a list of scopes (e.g. test, provided) to ignore when scanning artifacts
- * strict - a boolean, if <<>> process module-info and Multi-Release JAR classes
+ * <> - a boolean, if <<>> all dependencies which have <<<true>>> are ignored.
- []
+ * <> - a boolean, specify if transitive dependencies should be searched (default) or only look at direct dependencies.
+
+ * <> - a boolean, if <<>> process module-info and Multi-Release JAR classes
+
+ []
Note
Sample Plugin Configuration:
diff --git a/src/site/apt/requireContributorRoles.apt.vm b/src/site/apt/requireContributorRoles.apt.vm
index d6c47410..8e9a8ba0 100644
--- a/src/site/apt/requireContributorRoles.apt.vm
+++ b/src/site/apt/requireContributorRoles.apt.vm
@@ -33,15 +33,14 @@ Require Contributor Roles
The following parameters are supported by this rule:
- * <<>> - Comma separated list of roles which must be represented
+ * <> - Comma separated list of roles which must be represented
by at least one contributor.
- * <<>> - Comma separated list of roles which are additionally allowed. <<>> are always valid, so the union of <<>> and <<>> forms the set of all accepted roles.
+ * <> - Comma separated list of roles which are additionally allowed. <<>> are always valid, so the union of <<>> and <<>> forms the set of all accepted roles.
By default it has the value <<<*>>>, which means every role is accepted. This rule does <> support Ant-patterns.
[]
-
Sample Plugin Configuration:
+---+
diff --git a/src/site/apt/requireDeveloperRoles.apt.vm b/src/site/apt/requireDeveloperRoles.apt.vm
index f7ca6500..cd61c9c2 100644
--- a/src/site/apt/requireDeveloperRoles.apt.vm
+++ b/src/site/apt/requireDeveloperRoles.apt.vm
@@ -33,15 +33,14 @@ Require Developer Roles
The following parameters are supported by this rule:
- * <<>> - Comma separated list of roles which must be represented
+ * <> - Comma separated list of roles which must be represented
by at least one developer.
- * <<>> - Comma separated list of roles which are additionally allowed. <<>> are always valid, so the union of <<>> and <<>> forms the set of all accepted roles.
+ * <> - Comma separated list of roles which are additionally allowed. <<>> are always valid, so the union of <<>> and <<>> forms the set of all accepted roles.
By default it has the value <<<*>>>, which means every role is accepted. This rule does <> support Ant-patterns.
[]
-
Sample Plugin Configuration:
+---+
diff --git a/src/site/apt/requireEncoding.apt.vm b/src/site/apt/requireEncoding.apt.vm
index c6b90034..2f89cf62 100644
--- a/src/site/apt/requireEncoding.apt.vm
+++ b/src/site/apt/requireEncoding.apt.vm
@@ -32,15 +32,15 @@ Require Encoding
The following parameters are supported by this rule:
- * <<>> - Required encoding. Default value <<<$\{project.build.sourceEncoding\}>>>.
+ * <> - Required encoding. Default value <<<$\{project.build.sourceEncoding\}>>>.
- * <<>> - List of files to include, separated by comma or pipe
+ * <> - List of files to include, separated by comma or pipe
- * <<>> - List of files to exclude, separated by comma or pipe
+ * <> - List of files to exclude, separated by comma or pipe
- * <<>> - enable SCM file exclusions, enbled by default.
+ * <> - enable SCM file exclusions, enbled by default.
- * <<>> - Should the rule fail after the first error or should the errors be aggregated. Default true.
+ * <> - Should the rule fail after the first error or should the errors be aggregated. Default true.
[]
diff --git a/src/site/apt/requirePropertyDiverges.apt.vm b/src/site/apt/requirePropertyDiverges.apt.vm
index 2c196f1c..b41e101b 100644
--- a/src/site/apt/requirePropertyDiverges.apt.vm
+++ b/src/site/apt/requirePropertyDiverges.apt.vm
@@ -38,9 +38,9 @@ Require Property Diverges
The following parameters are supported by this rule:
- * <<>> - name of the property which should diverge. Must be given.
+ * <> - name of the property which should diverge. Must be given.
- * <<>> - match the property value to a given regular expression.
+ * <> - match the property value to a given regular expression.
When not given, this rule checks that the property in the child does not equal
the one from the defining ancestor.