diff --git a/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java b/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java index a67fb24..f26f100 100644 --- a/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java +++ b/src/main/java/org/apache/maven/shared/invoker/DefaultInvocationRequest.java @@ -112,6 +112,8 @@ public class DefaultInvocationRequest implements InvocationRequest { private boolean noTransferProgress; + private boolean ignoreTransitiveRepositories; + private List args = new ArrayList<>(); /** @@ -692,6 +694,17 @@ public InvocationRequest setNoTransferProgress(boolean noTransferProgress) { return this; } + @Override + public boolean isIgnoreTransitiveRepositories() { + return ignoreTransitiveRepositories; + } + + @Override + public InvocationRequest setIgnoreTransitiveRepositories(boolean ignoreTransitiveRepositories) { + this.ignoreTransitiveRepositories = ignoreTransitiveRepositories; + return this; + } + /** * {@inheritDoc} */ diff --git a/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java b/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java index 8665570..0c41043 100644 --- a/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java +++ b/src/main/java/org/apache/maven/shared/invoker/InvocationRequest.java @@ -40,6 +40,15 @@ public interface InvocationRequest { */ boolean isBatchMode(); + /** + * Indicates whether Maven should ignore transitive repositories. By default, transitive repositories are not + * ignored. + * + * @return true if transitive repositories should be ignored, false otherwise. + * @since 3.4.0 + */ + boolean isIgnoreTransitiveRepositories(); + /** * Gets the network mode of the Maven invocation. By default, Maven is executed in online mode. * @@ -791,6 +800,15 @@ enum CheckSumPolicy { */ InvocationRequest setNoTransferProgress(boolean noTransferProgress); + /** + * Sets the ignore transitive repositories mode. Equivalent of {@code -itr} or {@code --ignore-transitive-repositories} + * + * @param ignoreTransitiveRepositories true if transitive repositories should be ignored, false otherwise. + * @return This invocation request. + * @since 3.4.0 + */ + InvocationRequest setIgnoreTransitiveRepositories(boolean ignoreTransitiveRepositories); + /** * Get the current set builder strategy id equivalent of {@code --builder id}. Note. This is available since * Maven 3.2.1 diff --git a/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java b/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java index b0e5fc8..c9043e3 100644 --- a/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java +++ b/src/main/java/org/apache/maven/shared/invoker/MavenCommandLineBuilder.java @@ -453,6 +453,10 @@ else if (request.isShowErrors()) { if (request.isNoTransferProgress()) { cli.createArg().setValue("-ntp"); } + + if (request.isIgnoreTransitiveRepositories()) { + cli.createArg().setValue("-itr"); + } } /** diff --git a/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java b/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java index bbd2ce6..87a28f7 100644 --- a/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java +++ b/src/test/java/org/apache/maven/shared/invoker/MavenCommandLineBuilderTest.java @@ -492,6 +492,12 @@ void testShouldSetNoTransferProgressFlagFromRequest() { assertArgumentsPresent(cli, Collections.singleton("-ntp")); } + @Test + void testShouldSetIgnoreTransitiveRepositoriesFromRequest() { + mclb.setFlags(newRequest().setIgnoreTransitiveRepositories(true), cli); + assertArgumentsPresent(cli, Collections.singleton("-itr")); + } + @Test void testShouldSpecifyFileOptionUsingNonStandardPomFileLocation() throws Exception { File projectDir = Files.createDirectories(