Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MNG-8030] Backport itr: ignore transitive repositories #1469

Merged
merged 1 commit into from
Apr 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -1409,6 +1409,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
Loading