From d1f537ef5bb7458bbe6e3e1f9c8835633964d127 Mon Sep 17 00:00:00 2001 From: Lars Vogel Date: Wed, 20 Dec 2023 11:13:26 +0100 Subject: [PATCH] Option to ignore p2 mirrors via the Maven settings and the new eclipse.p2.mirrors option Commit 7e6d595 has removed the option for tycho.disableP2Mirrors 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 also add support for the new eclipse.p2.mirrors property --- p2-maven-plugin/pom.xml | 5 +++ ...ArtifactRepositoryManagerAgentFactory.java | 33 ++++++++++++++++--- 2 files changed, 33 insertions(+), 5 deletions(-) diff --git a/p2-maven-plugin/pom.xml b/p2-maven-plugin/pom.xml index 91f5ef57d4..48f9dc5990 100644 --- a/p2-maven-plugin/pom.xml +++ b/p2-maven-plugin/pom.xml @@ -207,6 +207,11 @@ commons-net commons-net + + org.eclipse.tycho + tycho-core + 5.0.0-SNAPSHOT + diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/RemoteArtifactRepositoryManagerAgentFactory.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/RemoteArtifactRepositoryManagerAgentFactory.java index 0f638c3ea4..120883dfc7 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/RemoteArtifactRepositoryManagerAgentFactory.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/RemoteArtifactRepositoryManagerAgentFactory.java @@ -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; import org.eclipse.tycho.version.TychoVersion; @Component(role = IAgentServiceFactory.class, hint = "org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager") @@ -34,6 +35,9 @@ public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServic @Requirement MavenAuthenticator authenticator; + @Requirement + MavenContext mavenContext; + @Override public Object createService(IProvisioningAgent agent) { IArtifactRepositoryManager plainRepoManager = (IArtifactRepositoryManager) new ArtifactRepositoryComponent() @@ -45,14 +49,33 @@ public Object createService(IProvisioningAgent agent) { } private boolean getDisableP2MirrorsConfiguration() { - String key = "tycho.disableP2Mirrors"; - String value = System.getProperty(key); - if (value != null) { - logger.info("Using " + key + String deprecatedKey = "tycho.disableP2Mirrors"; + String deprecatedValue = System.getProperty(deprecatedKey); + + if (deprecatedValue == null) { + deprecatedValue = mavenContext.getSessionProperties().getProperty(deprecatedKey); + } + + if (deprecatedValue != null) { + logger.info("Using " + deprecatedKey + " to disable P2 mirrors is deprecated, use the property eclipse.p2.mirrors instead, see https://tycho.eclipseprojects.io/doc/" + TychoVersion.getTychoVersion() + "/SystemProperties.html for details."); - return Boolean.parseBoolean(value); + return Boolean.parseBoolean(deprecatedValue); + } + + String key = "eclipse.p2.mirrors "; + String value = System.getProperty(key); + + if (value == null) { + value = mavenContext.getSessionProperties().getProperty(key); + } + + + if (value != null) { + // eclipse.p2.mirrors false -> disable mirrors + return !Boolean.parseBoolean(value); } return false; + } }