Skip to content

Commit

Permalink
Restoring the option to ignore p2 mirrors via the Maven settings
Browse files Browse the repository at this point in the history
Commit 7e6d595 has removed the option
to use the settings.xml to disable the usage of p2 mirrors.

See https://github.com/eclipse-tycho/tycho/wiki/Frequently-asked-questions#how-do-i-disable-p2-mirrors

Restores this option and give the command line option priority.
  • Loading branch information
vogella committed Dec 20, 2023
1 parent 1af7b26 commit a47c112
Showing 1 changed file with 8 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory;
import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager;
import org.eclipse.tycho.IRepositoryIdManager;
import org.eclipse.tycho.core.shared.MavenContext;

@Component(role = IAgentServiceFactory.class, hint = "org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager")
public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServiceFactory {
Expand All @@ -33,6 +34,9 @@ public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServic
@Requirement
MavenAuthenticator authenticator;

@Requirement
MavenContext mavenContext;

@Override
public Object createService(IProvisioningAgent agent) {
IArtifactRepositoryManager plainRepoManager = (IArtifactRepositoryManager) new ArtifactRepositoryComponent()
Expand All @@ -48,6 +52,10 @@ private boolean getDisableP2MirrorsConfiguration() {
String key = "tycho.disableP2Mirrors";
String value = System.getProperty(key);

if (value == null) {
value = mavenContext.getSessionProperties().getProperty(key);
}

boolean disableP2Mirrors = Boolean.parseBoolean(value);
if (disableP2Mirrors && logger.isDebugEnabled()) {
String message = key + "=" + value + " -> ignoring mirrors specified in p2 artifact repositories";
Expand Down

0 comments on commit a47c112

Please sign in to comment.