Skip to content

Commit

Permalink
Option to ignore p2 mirrors via the Maven settings and the new
Browse files Browse the repository at this point in the history
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
  • Loading branch information
vogella committed Jan 9, 2024
1 parent 7e8005b commit e277ed2
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
5 changes: 5 additions & 0 deletions p2-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,11 @@
<groupId>commons-net</groupId>
<artifactId>commons-net</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-core</artifactId>
<version>5.0.0-SNAPSHOT</version>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
*******************************************************************************/
package org.eclipse.tycho.p2maven.transport;

import org.apache.maven.plugin.LegacySupport;
import org.codehaus.plexus.component.annotations.Component;
import org.codehaus.plexus.component.annotations.Requirement;
import org.codehaus.plexus.logging.Logger;
Expand All @@ -34,6 +35,9 @@ public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServic
@Requirement
MavenAuthenticator authenticator;

@Requirement
protected LegacySupport mavenContext;

@Override
public Object createService(IProvisioningAgent agent) {
IArtifactRepositoryManager plainRepoManager = (IArtifactRepositoryManager) new ArtifactRepositoryComponent()
Expand All @@ -45,14 +49,41 @@ 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.getSession().getSystemProperties().getProperty(deprecatedKey);
}

if (deprecatedValue == null) {
deprecatedValue = mavenContext.getSession().getUserProperties().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.getSession().getSystemProperties().getProperty(key);
}

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

if (value != null) {
// eclipse.p2.mirrors false -> disable mirrors
return !Boolean.parseBoolean(value);
}
return false;

}
}

0 comments on commit e277ed2

Please sign in to comment.