[MNG-7713] Drop legacy-local-repository option (#1020)

There is really no need for it, and there is a resolver option if really must (but really should not, local repo is and should be considered as transient).

---

https://issues.apache.org/jira/browse/MNG-7713
This commit is contained in:
Tamas Cservenak 2023-03-01 11:17:55 +01:00 committed by GitHub
parent 4e098a3205
commit afc1a2bd86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 25 additions and 47 deletions

View File

@ -1022,7 +1022,7 @@ public boolean isUseLegacyLocalRepository() {
@Override
public MavenExecutionRequest setUseLegacyLocalRepository(boolean useLegacyLocalRepositoryManager) {
this.useLegacyLocalRepositoryManager = useLegacyLocalRepositoryManager;
this.useLegacyLocalRepositoryManager = false;
return this;
}

View File

@ -443,12 +443,22 @@ public interface MavenExecutionRequest {
/**
* @since 3.1
* @deprecated Since 3.9 there is no direct Maven2 interop offered at LRM level. See
* <a href="https://maven.apache.org/resolver/configuration.html">Resolver Configuration</a> page option
* {@code aether.artifactResolver.simpleLrmInterop} that provides similar semantics. This method should
* be never invoked, and always returns {@code false}.
*/
@Deprecated
boolean isUseLegacyLocalRepository();
/**
* @since 3.1
* @deprecated Since 3.9 there is no direct Maven2 interop offered at LRM level. See
* <a href="https://maven.apache.org/resolver/configuration.html">Resolver Configuration</a> page option
* {@code aether.artifactResolver.simpleLrmInterop} that provides similar semantics. This method should
* be never invoked, and ignores parameter (value remains always {@code false}).
*/
@Deprecated
MavenExecutionRequest setUseLegacyLocalRepository(boolean useLegacyLocalRepository);
/**

View File

@ -54,11 +54,9 @@
import org.eclipse.aether.RepositorySystem;
import org.eclipse.aether.repository.LocalRepository;
import org.eclipse.aether.repository.LocalRepositoryManager;
import org.eclipse.aether.repository.NoLocalRepositoryManagerException;
import org.eclipse.aether.repository.RepositoryPolicy;
import org.eclipse.aether.repository.WorkspaceReader;
import org.eclipse.aether.resolution.ResolutionErrorPolicy;
import org.eclipse.aether.spi.localrepo.LocalRepositoryManagerFactory;
import org.eclipse.aether.util.ConfigUtils;
import org.eclipse.aether.util.listener.ChainedRepositoryListener;
import org.eclipse.aether.util.repository.AuthenticationBuilder;
@ -129,8 +127,6 @@ public class DefaultRepositorySystemSessionFactory {
private final RepositorySystem repoSystem;
private final LocalRepositoryManagerFactory simpleLocalRepoMgrFactory;
private final WorkspaceReader workspaceRepository;
private final SettingsDecrypter settingsDecrypter;
@ -146,7 +142,6 @@ public class DefaultRepositorySystemSessionFactory {
public DefaultRepositorySystemSessionFactory(
ArtifactHandlerManager artifactHandlerManager,
RepositorySystem repoSystem,
@Nullable @Named("simple") LocalRepositoryManagerFactory simpleLocalRepoMgrFactory,
@Nullable @Named("ide") WorkspaceReader workspaceRepository,
SettingsDecrypter settingsDecrypter,
EventSpyDispatcher eventSpyDispatcher,
@ -154,7 +149,6 @@ public DefaultRepositorySystemSessionFactory(
RuntimeInformation runtimeInformation) {
this.artifactHandlerManager = artifactHandlerManager;
this.repoSystem = repoSystem;
this.simpleLocalRepoMgrFactory = simpleLocalRepoMgrFactory;
this.workspaceRepository = workspaceRepository;
this.settingsDecrypter = settingsDecrypter;
this.eventSpyDispatcher = eventSpyDispatcher;
@ -372,33 +366,22 @@ private void setUpLocalRepositoryManager(MavenExecutionRequest request, DefaultR
LocalRepository localRepo =
new LocalRepository(request.getLocalRepository().getBasedir());
if (request.isUseLegacyLocalRepository()) {
try {
session.setLocalRepositoryManager(simpleLocalRepoMgrFactory.newInstance(session, localRepo));
logger.info("Disabling enhanced local repository: using legacy is strongly discouraged to ensure"
+ " build reproducibility.");
} catch (NoLocalRepositoryManagerException e) {
logger.error("Failed to configure legacy local repository: falling back to default");
session.setLocalRepositoryManager(repoSystem.newLocalRepositoryManager(session, localRepo));
}
} else {
LocalRepositoryManager lrm = repoSystem.newLocalRepositoryManager(session, localRepo);
LocalRepositoryManager lrm = repoSystem.newLocalRepositoryManager(session, localRepo);
String localRepoTail = ConfigUtils.getString(session, null, MAVEN_REPO_LOCAL_TAIL);
if (localRepoTail != null) {
boolean ignoreTailAvailability =
ConfigUtils.getBoolean(session, true, MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY);
List<LocalRepositoryManager> tail = new ArrayList<>();
List<String> paths = Arrays.stream(localRepoTail.split(","))
.filter(p -> p != null && !p.trim().isEmpty())
.collect(toList());
for (String path : paths) {
tail.add(repoSystem.newLocalRepositoryManager(session, new LocalRepository(path)));
}
session.setLocalRepositoryManager(new ChainedLocalRepositoryManager(lrm, tail, ignoreTailAvailability));
} else {
session.setLocalRepositoryManager(lrm);
String localRepoTail = ConfigUtils.getString(session, null, MAVEN_REPO_LOCAL_TAIL);
if (localRepoTail != null) {
boolean ignoreTailAvailability =
ConfigUtils.getBoolean(session, true, MAVEN_REPO_LOCAL_TAIL_IGNORE_AVAILABILITY);
List<LocalRepositoryManager> tail = new ArrayList<>();
List<String> paths = Arrays.stream(localRepoTail.split(","))
.filter(p -> p != null && !p.trim().isEmpty())
.collect(toList());
for (String path : paths) {
tail.add(repoSystem.newLocalRepositoryManager(session, new LocalRepository(path)));
}
session.setLocalRepositoryManager(new ChainedLocalRepositoryManager(lrm, tail, ignoreTailAvailability));
} else {
session.setLocalRepositoryManager(lrm);
}
}

View File

@ -106,8 +106,6 @@ public class CLIManager {
public static final String THREADS = "T";
public static final String LEGACY_LOCAL_REPOSITORY = "llr";
public static final String BUILDER = "b";
public static final String NO_TRANSFER_PROGRESS = "ntp";
@ -276,11 +274,6 @@ public CLIManager() {
.hasArg()
.desc("Thread count, for instance 4 (int) or 2C/2.5C (int/float) where C is core multiplied")
.build());
options.addOption(Option.builder(LEGACY_LOCAL_REPOSITORY)
.longOpt("legacy-local-repository")
.desc(
"Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true")
.build());
options.addOption(Option.builder(BUILDER)
.longOpt("builder")
.hasArg()

View File

@ -281,7 +281,6 @@ public int doMain(CliRequest cliRequest) {
toolchains(cliRequest);
populateRequest(cliRequest);
encryption(cliRequest);
repository(cliRequest);
return execute(cliRequest);
} catch (ExitException e) {
return e.exitCode;
@ -843,13 +842,6 @@ private void encryption(CliRequest cliRequest) throws Exception {
}
}
private void repository(CliRequest cliRequest) throws Exception {
if (cliRequest.commandLine.hasOption(CLIManager.LEGACY_LOCAL_REPOSITORY)
|| Boolean.getBoolean("maven.legacyLocalRepo")) {
cliRequest.request.setUseLegacyLocalRepository(true);
}
}
private int execute(CliRequest cliRequest) throws MavenExecutionRequestPopulationException {
MavenExecutionRequest request = executionRequestPopulator.populateDefaults(cliRequest.request);