Skip to content

Commit

Permalink
[MNG-8030] Backport itr: ignore transitive repositories (#1469)
Browse files Browse the repository at this point in the history
Backport of the Maven4 feature: ignore transitive repositories.

---

https://issues.apache.org/jira/browse/MNG-8030
  • Loading branch information
cstamas committed Apr 20, 2024
1 parent 18b8893 commit f6935a9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ public class DefaultMavenExecutionRequest implements MavenExecutionRequest {

private boolean cacheNotFound;

private boolean ignoreTransitiveRepositories;

private List<Proxy> proxies;

private List<Server> servers;
Expand Down Expand Up @@ -169,6 +171,7 @@ public static MavenExecutionRequest copy(MavenExecutionRequest original) {
copy.setOffline(original.isOffline());
copy.setInteractiveMode(original.isInteractiveMode());
copy.setCacheNotFound(original.isCacheNotFound());
copy.setIgnoreTransitiveRepositories(original.isIgnoreTransitiveRepositories());
copy.setCacheTransferError(original.isCacheTransferError());
copy.setProxies(original.getProxies());
copy.setServers(original.getServers());
Expand Down Expand Up @@ -1018,6 +1021,17 @@ public MavenExecutionRequest setCacheNotFound(boolean cacheNotFound) {
return this;
}

@Override
public boolean isIgnoreTransitiveRepositories() {
return ignoreTransitiveRepositories;
}

@Override
public MavenExecutionRequest setIgnoreTransitiveRepositories(boolean ignoreTransitiveRepositories) {
this.ignoreTransitiveRepositories = ignoreTransitiveRepositories;
return this;
}

@Override
public boolean isUseLegacyLocalRepository() {
return this.useLegacyLocalRepositoryManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,16 @@ public interface MavenExecutionRequest {

MavenExecutionRequest setCacheNotFound(boolean cacheNotFound);

/**
* @since 3.9.7
*/
boolean isIgnoreTransitiveRepositories();

/**
* @since 3.9.7
*/
MavenExecutionRequest setIgnoreTransitiveRepositories(boolean ignoreTransitiveRepositories);

// Profiles
List<Profile> getProfiles();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,8 @@ public DefaultRepositorySystemSession newRepositorySession(MavenExecutionRequest

session.setRepositoryListener(eventSpyDispatcher.chainListener(new LoggingRepositoryListener(logger)));

session.setIgnoreArtifactDescriptorRepositories(request.isIgnoreTransitiveRepositories());

boolean recordReverseTree = ConfigUtils.getBoolean(session, false, MAVEN_REPO_LOCAL_RECORD_REVERSE_TREE);
if (recordReverseTree) {
session.setRepositoryListener(new ChainedRepositoryListener(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ public class CLIManager {

public static final String COLOR = "color";

public static final String IGNORE_TRANSITIVE_REPOSITORIES = "itr";

protected Options options;

@SuppressWarnings({"checkstyle:linelength", "checkstyle:MethodLength"})
Expand Down Expand Up @@ -261,6 +263,10 @@ public CLIManager() {
.longOpt("no-transfer-progress")
.desc("Do not display transfer progress when downloading or uploading")
.build());
options.addOption(Option.builder(IGNORE_TRANSITIVE_REPOSITORIES)
.longOpt("ignore-transitive-repositories")
.desc("If set, Maven will ignore remote repositories introduced by transitive dependencies.")
.build());

// Adding this back in for compatibility with the verifier that hard codes this option.
options.addOption(Option.builder("npr")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1407,6 +1407,7 @@ private MavenExecutionRequest populateRequest(CliRequest cliRequest, MavenExecut

request.setCacheNotFound(true);
request.setCacheTransferError(false);
request.setIgnoreTransitiveRepositories(commandLine.hasOption(CLIManager.IGNORE_TRANSITIVE_REPOSITORIES));

//
// Builder, concurrency and parallelism
Expand Down

0 comments on commit f6935a9

Please sign in to comment.