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 c936a1669c..0f638c3ea4 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,11 +20,12 @@ 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.version.TychoVersion; @Component(role = IAgentServiceFactory.class, hint = "org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager") public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServiceFactory { - @Requirement + @Requirement Logger logger; @Requirement @@ -33,26 +34,25 @@ public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServic @Requirement MavenAuthenticator authenticator; - @Override - public Object createService(IProvisioningAgent agent) { - IArtifactRepositoryManager plainRepoManager = (IArtifactRepositoryManager) new ArtifactRepositoryComponent() - .createService(agent); - if (getDisableP2MirrorsConfiguration()) { - plainRepoManager = new P2MirrorDisablingArtifactRepositoryManager(plainRepoManager, - logger); - } + @Override + public Object createService(IProvisioningAgent agent) { + IArtifactRepositoryManager plainRepoManager = (IArtifactRepositoryManager) new ArtifactRepositoryComponent() + .createService(agent); + if (getDisableP2MirrorsConfiguration()) { + plainRepoManager = new P2MirrorDisablingArtifactRepositoryManager(plainRepoManager, logger); + } return new RemoteArtifactRepositoryManager(plainRepoManager, repositoryIdManager, authenticator); - } + } - private boolean getDisableP2MirrorsConfiguration() { - String key = "tycho.disableP2Mirrors"; + private boolean getDisableP2MirrorsConfiguration() { + String key = "tycho.disableP2Mirrors"; String value = System.getProperty(key); - - boolean disableP2Mirrors = Boolean.parseBoolean(value); - if (disableP2Mirrors && logger.isDebugEnabled()) { - String message = key + "=" + value + " -> ignoring mirrors specified in p2 artifact repositories"; - logger.debug(message); - } - return disableP2Mirrors; - } + if (value != null) { + logger.info("Using " + key + + " 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 false; + } } diff --git a/src/site/markdown/SystemProperties.md b/src/site/markdown/SystemProperties.md index 4890aed2da..7ba6c87471 100644 --- a/src/site/markdown/SystemProperties.md +++ b/src/site/markdown/SystemProperties.md @@ -26,3 +26,12 @@ Name | Value | Default | Documentation --- | --- | --- tycho.comparator.showDiff | true / false | false | If set to true if text-like files show a unified diff of possible differences in files tycho.comparator.threshold | bytes | 5242880 (~5MB) | gives the number of bytes for content to be compared semantically, larger files will only be compared byte-by-byte + +### P2 + +These properties control the behaviour of P2 used by Tycho + +Name | Value | Default | Documentation +--- | --- | --- +eclipse.p2.mirrors | true / false | true | Each p2 site can define a list of artifact repository mirrors, this controls if P2 mirrors should be used. This is independent from configuring mirrors in the maven configuration to be used by Tycho! + diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryPropertiesTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryPropertiesTest.java index 0a4714c5d8..56c41f2147 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryPropertiesTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryPropertiesTest.java @@ -78,4 +78,10 @@ public void testPropertyPropagation() throws Exception { assertTrue(properties.containsKey(TychoConstants.PROP_PGP_SIGNATURES) && !properties.get(TychoConstants.PROP_PGP_SIGNATURES).isBlank()); } + + @Override + protected boolean isDisableMirrors() { + // we want to test mirror properties... + return false; + } } diff --git a/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/AbstractTychoIntegrationTest.java b/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/AbstractTychoIntegrationTest.java index 10e53fb2e4..1862059973 100644 --- a/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/AbstractTychoIntegrationTest.java +++ b/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/AbstractTychoIntegrationTest.java @@ -90,6 +90,9 @@ protected Verifier getVerifier(String test, boolean setTargetPlatform, File user Verifier verifier = new Verifier(testDir.getAbsolutePath()); verifier.setForkJvm(isForked()); + if (isDisableMirrors()) { + verifier.setSystemProperty("eclipse.p2.mirrors", "false"); + } String debug = System.getProperty("tycho.mvnDebug"); if (debug != null) { System.out.println("Preparing to execute Maven in debug mode"); @@ -145,6 +148,14 @@ protected Verifier getVerifier(String test, boolean setTargetPlatform, File user return verifier; } + + /** + * can be overridden by subclass to explicitly enable mirrors, by default they are disabled. + * + */ + protected boolean isDisableMirrors() { + return true; + } protected boolean isForked() { return true;