aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMariya Yordanova2011-07-26 04:28:53 (EDT)
committerjsievers2011-09-23 05:20:21 (EDT)
commit8cb66ec2bd3db0755f5fc2130a62521746d2cbe4 (patch)
tree6c01257cc105952bb6dd5df9759f4a0507ebf028
parentdd4234ef04a89151edf4481cac1b9225111f71ae (diff)
downloadorg.eclipse.tycho-8cb66ec2bd3db0755f5fc2130a62521746d2cbe4.zip
org.eclipse.tycho-8cb66ec2bd3db0755f5fc2130a62521746d2cbe4.tar.gz
org.eclipse.tycho-8cb66ec2bd3db0755f5fc2130a62521746d2cbe4.tar.bz2
353175 Allow to disable p2 mirrors defined in artifact repositories
- Configurable from target-platform-configuration: set disableP2Mirrors=true to ignore/remove the value p2.mirrorsURL when Tycho loads artifact repositories - The result is the same as setting -Declipse.p2.mirrors=false on the command line
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformConfiguration.java10
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java12
-rw-r--r--tycho-p2-resolver/org.eclipse.tycho.p2.resolver.facade/src/main/java/org/eclipse/tycho/p2/resolver/facade/P2ResolverFactory.java3
-rw-r--r--tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/disablemirrors/artifacts.xml16
-rw-r--r--tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/disablemirrors/content.xml10
-rw-r--r--tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/usemirrors/artifacts.xml16
-rw-r--r--tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/usemirrors/content.xml10
-rw-r--r--tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverOfflineTest.java8
-rw-r--r--tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverTest.java3
-rw-r--r--tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/ResolutionContextDisableP2MirrorsTest.java61
-rw-r--r--tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java4
-rw-r--r--tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/ResolutionContextImpl.java52
-rw-r--r--tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java13
13 files changed, 190 insertions, 28 deletions
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformConfiguration.java b/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformConfiguration.java
index f9a78cf..6d0610c 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformConfiguration.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformConfiguration.java
@@ -31,6 +31,8 @@ public class TargetPlatformConfiguration {
private Boolean allowConflictingDependencies;
+ private boolean disableP2Mirrors;
+
/**
* Returns the list of configured target environments, or the running environment if no
* environments have been specified explicitly.
@@ -84,4 +86,12 @@ public class TargetPlatformConfiguration {
public Boolean getAllowConflictingDependencies() {
return allowConflictingDependencies;
}
+
+ public void setDisableP2Mirrors(boolean disableP2Mirrors) {
+ this.disableP2Mirrors = disableP2Mirrors;
+ }
+
+ public boolean isDisableP2Mirrors() {
+ return disableP2Mirrors;
+ }
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java
index 83eb983..8f14b20 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformConfigurationReader.java
@@ -60,6 +60,8 @@ public class DefaultTargetPlatformConfigurationReader {
setPomDependencies(result, configuration);
setAllowConflictingDependencies(result, configuration);
+
+ setDisableP2Mirrors(result, configuration);
}
}
@@ -85,6 +87,16 @@ public class DefaultTargetPlatformConfigurationReader {
return result;
}
+ private void setDisableP2Mirrors(TargetPlatformConfiguration result, Xpp3Dom configuration) {
+ Xpp3Dom disableP2mirrorsDom = configuration.getChild("disableP2Mirrors");
+ if (disableP2mirrorsDom == null) {
+ return;
+ }
+
+ result.setDisableP2Mirrors(Boolean.parseBoolean(disableP2mirrorsDom.getValue()));
+
+ }
+
private void setAllowConflictingDependencies(TargetPlatformConfiguration result, Xpp3Dom configuration) {
Xpp3Dom allowConflictingDependenciesDom = configuration.getChild("allowConflictingDependencies");
if (allowConflictingDependenciesDom == null) {
diff --git a/tycho-p2-resolver/org.eclipse.tycho.p2.resolver.facade/src/main/java/org/eclipse/tycho/p2/resolver/facade/P2ResolverFactory.java b/tycho-p2-resolver/org.eclipse.tycho.p2.resolver.facade/src/main/java/org/eclipse/tycho/p2/resolver/facade/P2ResolverFactory.java
index 41d312d..0a05cf1 100644
--- a/tycho-p2-resolver/org.eclipse.tycho.p2.resolver.facade/src/main/java/org/eclipse/tycho/p2/resolver/facade/P2ResolverFactory.java
+++ b/tycho-p2-resolver/org.eclipse.tycho.p2.resolver.facade/src/main/java/org/eclipse/tycho/p2/resolver/facade/P2ResolverFactory.java
@@ -16,7 +16,8 @@ import org.eclipse.tycho.core.facade.MavenLogger;
public interface P2ResolverFactory {
- public ResolutionContext createResolutionContext(File localMavenRepositoryRoot, boolean offline, MavenLogger logger);
+ public ResolutionContext createResolutionContext(File localMavenRepositoryRoot, boolean offline,
+ boolean disableP2Mirrors, MavenLogger logger);
public P2Resolver createResolver(MavenLogger logger);
}
diff --git a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/disablemirrors/artifacts.xml b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/disablemirrors/artifacts.xml
new file mode 100644
index 0000000..8425b2e
--- /dev/null
+++ b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/disablemirrors/artifacts.xml
@@ -0,0 +1,16 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?artifactRepository version='1.1.0'?>
+<repository name='disablemirrors' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1'>
+ <properties size='2'>
+ <property name='p2.compressed' value='false'/>
+ <property name='p2.timestamp' value='1276701781937'/>
+ <property name='p2.mirrorsURL' value='file://dummy/'/>
+ </properties>
+ <mappings size='3'>
+ <rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
+ <rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
+ <rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
+ </mappings>
+ <artifacts size='0'>
+ </artifacts>
+</repository>
diff --git a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/disablemirrors/content.xml b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/disablemirrors/content.xml
new file mode 100644
index 0000000..2e98e6b
--- /dev/null
+++ b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/disablemirrors/content.xml
@@ -0,0 +1,10 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?metadataRepository version='1.1.0'?>
+<repository name='disablemirrors' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1'>
+ <properties size='2'>
+ <property name='p2.compressed' value='false'/>
+ <property name='p2.timestamp' value='1276701781937'/>
+ </properties>
+ <units size='0'>
+ </units>
+</repository>
diff --git a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/usemirrors/artifacts.xml b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/usemirrors/artifacts.xml
new file mode 100644
index 0000000..a0e022a
--- /dev/null
+++ b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/usemirrors/artifacts.xml
@@ -0,0 +1,16 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?artifactRepository version='1.1.0'?>
+<repository name='usemirrors' type='org.eclipse.equinox.p2.artifact.repository.simpleRepository' version='1'>
+ <properties size='2'>
+ <property name='p2.compressed' value='false'/>
+ <property name='p2.timestamp' value='1276701781937'/>
+ <property name='p2.mirrorsURL' value='file://dummy/'/>
+ </properties>
+ <mappings size='3'>
+ <rule filter='(&amp; (classifier=osgi.bundle))' output='${repoUrl}/plugins/${id}_${version}.jar'/>
+ <rule filter='(&amp; (classifier=binary))' output='${repoUrl}/binary/${id}_${version}'/>
+ <rule filter='(&amp; (classifier=org.eclipse.update.feature))' output='${repoUrl}/features/${id}_${version}.jar'/>
+ </mappings>
+ <artifacts size='0'>
+ </artifacts>
+</repository>
diff --git a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/usemirrors/content.xml b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/usemirrors/content.xml
new file mode 100644
index 0000000..d6c28a3
--- /dev/null
+++ b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/resources/p2-mirrors-disable/usemirrors/content.xml
@@ -0,0 +1,10 @@
+<?xml version='1.0' encoding='UTF-8'?>
+<?metadataRepository version='1.1.0'?>
+<repository name='usemirrors' type='org.eclipse.equinox.internal.p2.metadata.repository.LocalMetadataRepository' version='1'>
+ <properties size='2'>
+ <property name='p2.compressed' value='false'/>
+ <property name='p2.timestamp' value='1276701781937'/>
+ </properties>
+ <units size='0'>
+ </units>
+</repository>
diff --git a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverOfflineTest.java b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverOfflineTest.java
index 23f4a7d..977b4ea 100644
--- a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverOfflineTest.java
+++ b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverOfflineTest.java
@@ -35,6 +35,7 @@ import org.junit.Before;
import org.junit.Test;
public class P2ResolverOfflineTest extends P2ResolverTestBase {
+ private static final boolean DISABLE_MIRRORS = false;
private HttpServer server;
private String servedUrl;
@@ -42,7 +43,8 @@ public class P2ResolverOfflineTest extends P2ResolverTestBase {
@Before
public void initResolver() throws Exception {
MavenLogger logger = new MavenLoggerStub();
- context = new P2ResolverFactoryImpl().createResolutionContext(getLocalRepositoryLocation(), false, logger);
+ context = new P2ResolverFactoryImpl().createResolutionContext(getLocalRepositoryLocation(), false,
+ DISABLE_MIRRORS, logger);
impl = new P2ResolverImpl(logger);
}
@@ -83,7 +85,7 @@ public class P2ResolverOfflineTest extends P2ResolverTestBase {
// now go offline and resolve again
context = new P2ResolverFactoryImpl().createResolutionContext(getLocalRepositoryLocation(), true,
- new MavenLoggerStub());
+ DISABLE_MIRRORS, new MavenLoggerStub());
List<P2ResolutionResult> results = resolveFromHttp(context, impl, servedUrl);
Assert.assertEquals(1, results.size());
@@ -98,7 +100,7 @@ public class P2ResolverOfflineTest extends P2ResolverTestBase {
delete(getLocalRepositoryLocation());
context = new P2ResolverFactoryImpl().createResolutionContext(getLocalRepositoryLocation(), true,
- new MavenLoggerStub());
+ DISABLE_MIRRORS, new MavenLoggerStub());
try {
resolveFromHttp(context, impl, servedUrl);
diff --git a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverTest.java b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverTest.java
index a566947..1cf8dd5 100644
--- a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverTest.java
+++ b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverTest.java
@@ -46,7 +46,8 @@ public class P2ResolverTest extends P2ResolverTestBase {
@Before
public void initDefaultResolver() throws Exception {
MavenLogger logger = new MavenLoggerStub();
- context = new P2ResolverFactoryImpl().createResolutionContext(getLocalRepositoryLocation(), false, logger);
+ context = new P2ResolverFactoryImpl().createResolutionContext(getLocalRepositoryLocation(), false, false,
+ logger);
impl = new P2ResolverImpl(logger);
impl.setEnvironments(getEnvironments());
}
diff --git a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/ResolutionContextDisableP2MirrorsTest.java b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/ResolutionContextDisableP2MirrorsTest.java
new file mode 100644
index 0000000..e3571d0
--- /dev/null
+++ b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/ResolutionContextDisableP2MirrorsTest.java
@@ -0,0 +1,61 @@
+package org.eclipse.tycho.p2.impl.resolver;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+import java.net.URI;
+
+import org.eclipse.equinox.p2.core.IProvisioningAgent;
+import org.eclipse.equinox.p2.repository.artifact.spi.AbstractArtifactRepository;
+import org.eclipse.tycho.p2.impl.test.MavenLoggerStub;
+import org.eclipse.tycho.test.util.ResourceUtil;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ResolutionContextDisableP2MirrorsTest {
+
+ private P2RepositoryCache repositoryCache;
+ private File localRepo;
+
+ @Before
+ public void setUp() {
+ localRepo = new File("target/localrepo");
+ IProvisioningAgent agent = P2ResolverFactoryImpl.getProvisioningAgent(localRepo, false);
+ repositoryCache = (P2RepositoryCache) agent.getService(P2RepositoryCache.SERVICE_NAME);
+ assertNotNull(repositoryCache);
+ }
+
+ @Test
+ public void testDisableP2Mirrors() throws Exception {
+ ResolutionContextImpl context = createResolutionContext(true);
+
+ URI location = ResourceUtil.resourceFile("p2-mirrors-disable/disablemirrors").toURI();
+ context.addP2Repository(location);
+ assertNull(getP2MirrorsUrlFromCachedRepository(location));
+ }
+
+ @Test
+ public void testWithoutDisableP2Mirrors() throws Exception {
+ ResolutionContextImpl context = createResolutionContext(false);
+
+ // need a different URI here, to force reloading
+ // TODO why is the cache active in this test -> test through the right interface?
+ URI location = ResourceUtil.resourceFile("p2-mirrors-disable/usemirrors").toURI();
+ context.addP2Repository(location);
+ assertNotNull(getP2MirrorsUrlFromCachedRepository(location));
+ }
+
+ private ResolutionContextImpl createResolutionContext(boolean disableP2Mirrors) {
+ P2ResolverFactoryImpl p2ResolverFactoryImpl = new P2ResolverFactoryImpl();
+ ResolutionContextImpl context = p2ResolverFactoryImpl.createResolutionContext(localRepo, false,
+ disableP2Mirrors, new MavenLoggerStub());
+ return context;
+ }
+
+ private String getP2MirrorsUrlFromCachedRepository(URI location) {
+ String p2MirrorsUrl = repositoryCache.getArtifactRepository(location).getProperty(
+ AbstractArtifactRepository.PROP_MIRRORS_URL);
+ return p2MirrorsUrl;
+ }
+}
diff --git a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java
index 50eea45..ce03589 100644
--- a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java
+++ b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java
@@ -26,10 +26,10 @@ import org.eclipse.tycho.p2.resolver.facade.P2ResolverFactory;
public class P2ResolverFactoryImpl implements P2ResolverFactory {
public ResolutionContextImpl createResolutionContext(File localMavenRepositoryRoot, boolean offline,
- MavenLogger logger) {
+ boolean disableP2Mirrors, MavenLogger logger) {
IProvisioningAgent agent = getProvisioningAgent(localMavenRepositoryRoot, offline);
- return new ResolutionContextImpl(agent, localMavenRepositoryRoot, offline, logger);
+ return new ResolutionContextImpl(agent, localMavenRepositoryRoot, offline, disableP2Mirrors, logger);
}
public P2ResolverImpl createResolver(MavenLogger logger) {
diff --git a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/ResolutionContextImpl.java b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/ResolutionContextImpl.java
index 694a9e1..beb087d 100644
--- a/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/ResolutionContextImpl.java
+++ b/tycho-p2-resolver/tycho-p2-resolver-impl/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/ResolutionContextImpl.java
@@ -87,7 +87,10 @@ public class ResolutionContextImpl implements ResolutionContext {
private final IProvisioningAgent agent;
- ResolutionContextImpl(IProvisioningAgent agent, File localMavenRepositoryRoot, boolean offline, MavenLogger logger) {
+ private final boolean disableP2Mirrors;
+
+ ResolutionContextImpl(IProvisioningAgent agent, File localMavenRepositoryRoot, boolean offline,
+ boolean disableP2Mirrors, MavenLogger logger) {
this.agent = agent;
this.logger = logger;
this.monitor = new LoggingProgressMonitor(logger);
@@ -111,6 +114,8 @@ public class ResolutionContextImpl implements ResolutionContext {
this.offline = offline;
+ this.disableP2Mirrors = disableP2Mirrors;
+
this.bundlesPublisher = new ResolutionContextBundlePublisher(localMavenRepositoryRoot, logger);
// setup p2 views of maven local repository
@@ -259,7 +264,10 @@ public class ResolutionContextImpl implements ResolutionContext {
artifactRepository = artifactRepositoryManager.loadRepository(location, monitor);
artifactRepositories.add(artifactRepository);
- forceSingleThreadedDownload(artifactRepositoryManager, artifactRepository);
+ forceSingleThreadedDownload(artifactRepository);
+ if (disableP2Mirrors) {
+ forceMirrorsDisabled(artifactRepository);
+ }
}
repositoryCache.putRepository(location, metadataRepository, artifactRepository);
@@ -270,34 +278,46 @@ public class ResolutionContextImpl implements ResolutionContext {
}
}
- protected void forceSingleThreadedDownload(IArtifactRepositoryManager artifactRepositoryManager,
- IArtifactRepository artifactRepository) {
+ protected void forceSingleThreadedDownload(IArtifactRepository artifactRepository) {
try {
if (artifactRepository instanceof SimpleArtifactRepository) {
- forceSingleThreadedDownload((SimpleArtifactRepository) artifactRepository);
+ OrderedProperties p = getProperties(artifactRepository);
+ p.put(org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.PROP_MAX_THREADS,
+ "1");
} else if (artifactRepository instanceof CompositeArtifactRepository) {
- forceSingleThreadedDownload(artifactRepositoryManager, (CompositeArtifactRepository) artifactRepository);
+ List<URI> children = ((CompositeArtifactRepository) artifactRepository).getChildren();
+ for (URI child : children) {
+ forceSingleThreadedDownload(artifactRepositoryManager.loadRepository(child, monitor));
+ }
}
} catch (Exception e) {
// we've tried
}
}
- protected void forceSingleThreadedDownload(IArtifactRepositoryManager artifactRepositoryManager,
- CompositeArtifactRepository artifactRepository) throws ProvisionException {
- List<URI> children = artifactRepository.getChildren();
- for (URI child : children) {
- forceSingleThreadedDownload(artifactRepositoryManager,
- artifactRepositoryManager.loadRepository(child, monitor));
+ private void forceMirrorsDisabled(IArtifactRepository artifactRepository) throws ProvisionException {
+ if (artifactRepository instanceof SimpleArtifactRepository) {
+ try {
+ OrderedProperties p = getProperties(artifactRepository);
+ p.remove(org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.PROP_MIRRORS_URL);
+ } catch (Exception e) {
+ throw new RuntimeException("Could not disable p2 mirrors", e);
+ }
+ } else if (artifactRepository instanceof CompositeArtifactRepository) {
+ for (URI child : ((CompositeArtifactRepository) artifactRepository).getChildren()) {
+ forceMirrorsDisabled(artifactRepositoryManager.loadRepository(child, monitor));
+ }
}
+
}
- protected void forceSingleThreadedDownload(SimpleArtifactRepository artifactRepository) throws SecurityException,
- NoSuchFieldException, IllegalArgumentException, IllegalAccessException {
+ private OrderedProperties getProperties(IArtifactRepository artifactRepository) throws NoSuchFieldException,
+ IllegalAccessException {
+ // TODO there should be a better way to modify repository properties
Field field = AbstractRepository.class.getDeclaredField("properties");
field.setAccessible(true);
- OrderedProperties p = (OrderedProperties) field.get(artifactRepository);
- p.put(org.eclipse.equinox.internal.p2.artifact.repository.simple.SimpleArtifactRepository.PROP_MAX_THREADS, "1");
+ OrderedProperties p = (OrderedProperties) field.get((SimpleArtifactRepository) artifactRepository);
+ return p;
}
// --------------------------------------------------------------------------------
diff --git a/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java b/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java
index 64787de..a95ff8e 100644
--- a/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java
+++ b/tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java
@@ -144,13 +144,18 @@ public class P2TargetPlatformResolver extends AbstractTargetPlatformResolver imp
MavenLogger loggerForOsgiImpl = new MavenLoggerAdapter(getLogger(), DebugUtils.isDebugEnabled(session, project));
File localRepositoryRoot = new File(session.getLocalRepository().getBasedir());
+
+ TargetPlatformConfiguration configuration = (TargetPlatformConfiguration) project
+ .getContextValue(TychoConstants.CTX_TARGET_PLATFORM_CONFIGURATION);
+
ResolutionContext resolutionContext = resolverFactory.createResolutionContext(localRepositoryRoot,
- session.isOffline(), loggerForOsgiImpl);
+ session.isOffline(), configuration.isDisableP2Mirrors(), loggerForOsgiImpl);
+
P2Resolver osgiResolverImpl = resolverFactory.createResolver(loggerForOsgiImpl);
try {
return doResolvePlatform(session, project, reactorProjects, dependencies, resolutionContext,
- osgiResolverImpl);
+ osgiResolverImpl, configuration);
} finally {
resolutionContext.stop();
}
@@ -158,9 +163,7 @@ public class P2TargetPlatformResolver extends AbstractTargetPlatformResolver imp
protected TargetPlatform doResolvePlatform(final MavenSession session, final MavenProject project,
List<ReactorProject> reactorProjects, List<Dependency> dependencies, ResolutionContext resolutionContext,
- P2Resolver resolver) {
- TargetPlatformConfiguration configuration = (TargetPlatformConfiguration) project
- .getContextValue(TychoConstants.CTX_TARGET_PLATFORM_CONFIGURATION);
+ P2Resolver resolver, TargetPlatformConfiguration configuration) {
Map<File, ReactorProject> projects = new HashMap<File, ReactorProject>();