Skip to content

Commit

Permalink
Add option to ignore specific maven dependency scopes
Browse files Browse the repository at this point in the history
  • Loading branch information
TomasHofman committed Dec 3, 2024
1 parent f93859e commit 16f31b3
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ public class UpgradeComponentsMojo extends AbstractChannelMojo {
@Parameter(property = "ignoreTestDependencies", defaultValue = "true")
boolean ignoreTestDependencies;

@Parameter(property = "ignoreScopes", defaultValue = "test")
Set<String> ignoreScopes = new HashSet<>();

/**
* When a dependency is defined with version string referencing a property, and that property is defined in a parent
* pom outside the project, the property would be injected into a pom where the dependency is defined, if this
Expand Down Expand Up @@ -177,6 +180,9 @@ private void init() throws MojoExecutionException {

ignoreStreams.forEach(ga -> ignoredStreams.add(SimpleProjectRef.parse(ga)));
dontIgnoreStreams.forEach(ga -> unignoredStreams.add(SimpleProjectRef.parse(ga)));
if (ignoreTestDependencies) {
ignoreScopes.add("test");
}
}

/**
Expand Down Expand Up @@ -489,7 +495,7 @@ private List<Tuple3<Dependency, ArtifactRef, String>> findDependenciesToUpgrade(
continue;
}
}
if ("test".equals(dependency.getScope()) && ignoreTestDependencies) {
if (ignoreScopes.contains(dependency.getScope())) {
getLog().info("Skipping dependency (ignored scope): "
+ resolvedArtifact.asProjectVersionRef().toString());
continue;
Expand Down Expand Up @@ -563,8 +569,8 @@ private void injectTransitiveDependencies() throws DependencyGraphBuilderExcepti
if (declaredDependencies.contains(artifact.asProjectRef())) {
return;
}
// Ignore test scope dependencies.
if ("test".equals(node.getArtifact().getScope()) && ignoreTestDependencies) {
// Ignore specific scopes.
if (ignoreScopes.contains(node.getArtifact().getScope())) {
// Ignore test scope undeclared dependencies entirely.
return;
}
Expand Down

0 comments on commit 16f31b3

Please sign in to comment.