Permalink
Browse files

395281 allow to resolve without reactor project nor local repo

- used for resolving the runtime of eclipserun-plugin
  independent of the project and its target platform

- add setter to TargetPlatformBuilder to control whether IUs installed
  in local maven repo should be part of the target platform

Bug: 395281
Change-Id: Idba050a286c0f657093d8c28196ddd2d9358a83f
  • Loading branch information...
1 parent 2e3faf9 commit 08631a0ea3cfd374f93eb7456e475bb1acdab403 @jsievers jsievers committed Jan 11, 2013
Showing with 122 additions and 105 deletions.
  1. +0 −16 ...epository.tests/src/test/java/org/eclipse/tycho/repository/local/LocalMetadataRepositoryTest.java
  2. +0 −24 ...p2.maven.repository/src/main/java/org/eclipse/tycho/repository/local/LocalMetadataRepository.java
  3. +15 −15 ....tycho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverTest.java
  4. +12 −4 ...ho.p2.resolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverTestBase.java
  5. +25 −0 ...esolver.impl.test/src/test/java/org/eclipse/tycho/p2/impl/resolver/TargetPlatformBuilderTest.java
  6. +1 −5 ...eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/artifacts/p2/P2TargetPlatform.java
  7. +0 −7 ...ycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverFactoryImpl.java
  8. +21 −11 ...lipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/impl/resolver/P2ResolverImpl.java
  9. +31 −10 ...e.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformBuilderImpl.java
  10. +10 −11 ....eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformImpl.java
  11. +4 −1 ...lipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/resolver/facade/P2Resolver.java
  12. +2 −0 ...ho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformBuilder.java
  13. +1 −1 tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java
@@ -29,7 +29,6 @@
import org.eclipse.equinox.p2.query.QueryUtil;
import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository;
import org.eclipse.tycho.p2.impl.repo.FileBasedTychoRepositoryIndex;
-import org.eclipse.tycho.p2.repository.GAV;
import org.eclipse.tycho.p2.repository.LocalRepositoryReader;
import org.eclipse.tycho.p2.repository.RepositoryLayoutHelper;
import org.eclipse.tycho.p2.repository.TychoRepositoryIndex;
@@ -62,21 +61,6 @@ private LocalMetadataRepository createRepository(File location) throws Provision
}
@Test
- public void testIncludeInTargetPlatformFalse() throws Exception {
- LocalMetadataRepository repository = createRepository(tempFolder.newFolder());
- repository.setIncludeInTargetPlatform(false);
- InstallableUnitDescription iud = new MetadataFactory.InstallableUnitDescription();
- iud.setId("test");
- iud.setVersion(Version.parseVersion("1.0.0"));
- IInstallableUnit iu = MetadataFactory.createInstallableUnit(iud);
- repository.addInstallableUnit(iu, new GAV("groupId", "artifactId", "version"));
-
- IQueryResult<IInstallableUnit> result = repository.query(QueryUtil.ALL_UNITS, monitor);
- ArrayList<IInstallableUnit> allius = new ArrayList<IInstallableUnit>(result.toSet());
- Assert.assertEquals(0, allius.size());
- }
-
- @Test
public void addInstallableUnit() throws CoreException {
File location = new File("target/metadataRepo");
LocalMetadataRepository repository = createRepository(location);
@@ -14,15 +14,10 @@
import java.io.IOException;
import java.net.URI;
import java.util.Collection;
-import java.util.Collections;
import java.util.LinkedHashSet;
import java.util.Set;
-import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
-import org.eclipse.equinox.p2.query.CollectionResult;
-import org.eclipse.equinox.p2.query.IQuery;
-import org.eclipse.equinox.p2.query.IQueryResult;
import org.eclipse.tycho.p2.maven.repository.AbstractMavenMetadataRepository;
import org.eclipse.tycho.p2.maven.repository.xmlio.MetadataIO;
import org.eclipse.tycho.p2.repository.GAV;
@@ -33,8 +28,6 @@
public class LocalMetadataRepository extends AbstractMavenMetadataRepository {
private Set<GAV> changedGAVs = new LinkedHashSet<GAV>();
- // TODO this shouldn't be handled here
- private boolean includeInTargetPlatform = true;
/**
* Create new repository
@@ -57,15 +50,6 @@ public LocalMetadataRepository(URI location, TychoRepositoryIndex projectIndex,
}
@Override
- public IQueryResult<IInstallableUnit> query(IQuery<IInstallableUnit> query, IProgressMonitor monitor) {
- if (includeInTargetPlatform) {
- return super.query(query, monitor);
- } else {
- return new CollectionResult<IInstallableUnit>(Collections.<IInstallableUnit> emptyList());
- }
- }
-
- @Override
public void addInstallableUnits(Collection<IInstallableUnit> newUnits) {
for (IInstallableUnit unit : newUnits) {
GAV gav = RepositoryLayoutHelper.getGAV(unit.getProperties());
@@ -128,12 +112,4 @@ public boolean isModifiable() {
return true;
}
- public void setIncludeInTargetPlatform(boolean value) {
- this.includeInTargetPlatform = value;
- }
-
- public boolean getIncludeInTargetPlatform() {
- return includeInTargetPlatform;
- }
-
}
@@ -60,7 +60,7 @@ public void basic() throws Exception {
String artifactId = "org.eclipse.tycho.p2.impl.resolver.test.bundle01";
addReactorProject(bundle, TYPE_ECLIPSE_PLUGIN, artifactId);
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), bundle);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), bundle);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -116,7 +116,7 @@ public void duplicateInstallableUnit() throws Exception {
addReactorProject(resourceFile("duplicate-iu/featureA2"), TYPE_ECLIPSE_FEATURE, "featureA2");
try {
- impl.resolveProject(context.buildTargetPlatform(), projectLocation);
+ impl.resolveDependencies(context.buildTargetPlatform(), projectLocation);
fail();
} catch (DuplicateReactorIUsException e) {
// TODO proper assertion
@@ -129,7 +129,7 @@ public void featureInstallableUnits() throws Exception {
String artifactId = "org.eclipse.tycho.p2.impl.resolver.test.feature01";
addReactorProject(feature, TYPE_ECLIPSE_FEATURE, artifactId);
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), feature);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), feature);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -156,7 +156,7 @@ public void sourceBundle() throws Exception {
sb.setDependencyMetadata(metadata);
context.addReactorArtifact(sb);
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), feature);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), feature);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -188,7 +188,7 @@ public void eclipseRepository() throws Exception {
addContextProject(resourceFile("resolver/bundle01"), TYPE_ECLIPSE_PLUGIN);
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), projectDir);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), projectDir);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -208,7 +208,7 @@ public void bundleUsesSWT() throws Exception {
String artifactId = "org.eclipse.tycho.p2.impl.resolver.test.bundleUsesSWT";
addReactorProject(bundle, TYPE_ECLIPSE_PLUGIN, artifactId);
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), bundle);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), bundle);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -227,7 +227,7 @@ public void swt() throws Exception {
File swtFragment = resourceFile("resolver/swt/swtFragment");
addReactorProject(swtFragment, TYPE_ECLIPSE_PLUGIN, "org.eclipse.tycho.p2.impl.resolver.test.swtFragment");
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), swt);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), swt);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -243,7 +243,7 @@ public void swtFragment() throws Exception {
File swtFragment = resourceFile("resolver/swt/swtFragment");
addReactorProject(swtFragment, TYPE_ECLIPSE_PLUGIN, "org.eclipse.tycho.p2.impl.resolver.test.swtFragment");
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), swtFragment);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), swtFragment);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -262,7 +262,7 @@ public void swtFragmentWithRemoteSWT() throws Exception {
File swtFragment = resourceFile("resolver/swt/swtFragment");
addReactorProject(swtFragment, TYPE_ECLIPSE_PLUGIN, "org.eclipse.tycho.p2.impl.resolver.test.swtFragment");
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), swtFragment);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), swtFragment);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -299,7 +299,7 @@ public void reactorVsExternal() throws Exception {
File featureProject = resourceFile("reactor-vs-external/feature01");
addReactorProject(featureProject, TYPE_ECLIPSE_FEATURE, "org.sonatype.tycho.p2.impl.resolver.test.feature01");
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), featureProject);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), featureProject);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -322,7 +322,7 @@ public void resolutionRestrictedEE() throws Exception {
String artifactId = "bundle.bree";
addReactorProject(bundle, TYPE_ECLIPSE_PLUGIN, artifactId);
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), bundle);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), bundle);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -345,7 +345,7 @@ public void resolutionEE() throws Exception {
String artifactId = "bundle.bree";
addReactorProject(bundle, TYPE_ECLIPSE_PLUGIN, artifactId);
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), bundle);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), bundle);
Assert.assertEquals(1, results.size());
P2ResolutionResult result = results.get(0);
@@ -368,7 +368,7 @@ public void resolutionCustomEE() throws Exception {
File bundle = resourceFile("resolver/bundleRequiringVersionedJDKPackage");
addReactorProject(bundle, TYPE_ECLIPSE_PLUGIN, "bundleRequiringVersionedJDKPackage");
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), bundle);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), bundle);
assertThat(results.size(), is(1));
P2ResolutionResult result = results.get(0); // huh?
@@ -389,7 +389,7 @@ public void featureMultienvP2Inf() throws Exception {
String artifactId = "feature.multienv.p2-inf";
addReactorProject(bundle, TYPE_ECLIPSE_FEATURE, artifactId);
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), bundle);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), bundle);
Assert.assertEquals(2, results.size());
@@ -417,7 +417,7 @@ public void productMultienvP2Inf() throws Exception {
String artifactId = "product.multienv.p2-inf";
addReactorProject(bundle, TYPE_ECLIPSE_REPOSITORY, artifactId);
- List<P2ResolutionResult> results = impl.resolveProject(context.buildTargetPlatform(), bundle);
+ List<P2ResolutionResult> results = impl.resolveDependencies(context.buildTargetPlatform(), bundle);
Assert.assertEquals(2, results.size());
@@ -111,15 +111,15 @@ protected final TargetPlatformBuilderImpl createTargetPlatformBuilderWithEE(Stri
protected final TargetPlatformBuilderImpl createTargetPlatformBuilderWithEE(
ExecutionEnvironmentResolutionHandler eeResolutionHandler) throws Exception {
- return new TestTargetPlatformBuilderFactory().createTargetPlatformBuider(eeResolutionHandler);
+ return new TestTargetPlatformBuilderFactory().createTargetPlatformBuilder(eeResolutionHandler);
}
protected final TargetPlatformBuilderImpl createTargetPlatformBuilderWithCustomEE(String customEE) throws Exception {
return new TestTargetPlatformBuilderFactory()
.createTargetPlatformBuilder(new CustomEEResolutionHints(customEE));
}
- private static class TestTargetPlatformBuilderFactory {
+ static class TestTargetPlatformBuilderFactory {
private MavenContext mavenContext;
private TargetDefinitionResolverService targetDefinitionResolverService;
@@ -140,6 +140,14 @@ protected final TargetPlatformBuilderImpl createTargetPlatformBuilderWithCustomE
localArtifactRepo = new LocalArtifactRepository(localRepoIndices, localRepositoryReader);
}
+ public LocalMetadataRepository getLocalMetadataRepository() {
+ return localMetadataRepo;
+ }
+
+ public TargetPlatformBuilderImpl createTargetPlatformBuilder() throws Exception {
+ return createTargetPlatformBuilder(new NoopEEResolverHints());
+ }
+
public TargetPlatformBuilderImpl createTargetPlatformBuilder(
ExecutionEnvironmentResolutionHints executionEnvironment) throws Exception {
ExecutionEnvironmentResolutionHandler eeHandler = new ExecutionEnvironmentResolutionHandler(
@@ -151,10 +159,10 @@ public void readFullSpecification(Collection<IInstallableUnit> targetPlatformCon
}
};
- return createTargetPlatformBuider(eeHandler);
+ return createTargetPlatformBuilder(eeHandler);
}
- public TargetPlatformBuilderImpl createTargetPlatformBuider(ExecutionEnvironmentResolutionHandler eeHandler)
+ public TargetPlatformBuilderImpl createTargetPlatformBuilder(ExecutionEnvironmentResolutionHandler eeHandler)
throws ProvisionException {
return new TargetPlatformBuilderImpl(new RemoteAgent(mavenContext), mavenContext,
targetDefinitionResolverService, eeHandler, localArtifactRepo, localMetadataRepo);
@@ -10,12 +10,16 @@
*******************************************************************************/
package org.eclipse.tycho.p2.impl.resolver;
+import static org.junit.Assert.assertEquals;
+
import java.io.File;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.tycho.ArtifactKey;
@@ -30,7 +34,11 @@
import org.eclipse.tycho.p2.impl.test.ArtifactMock;
import org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator;
import org.eclipse.tycho.p2.metadata.IDependencyMetadata;
+import org.eclipse.tycho.p2.repository.GAV;
+import org.eclipse.tycho.p2.target.TargetPlatformBuilderImpl;
+import org.eclipse.tycho.repository.local.LocalMetadataRepository;
import org.eclipse.tycho.test.util.BuildPropertiesParserForTesting;
+import org.eclipse.tycho.test.util.InstallableUnitUtil;
import org.junit.Assert;
import org.junit.Test;
@@ -193,6 +201,23 @@ public void testReactorProjectFiltering() throws Exception {
assertContainsIU(units, "org.eclipse.tycho.p2.impl.test.feature-p2-inf.feature.group");
}
+ @Test
+ public void testIncludeLocalMavenRepo() throws Exception {
+ TestTargetPlatformBuilderFactory factory = new TestTargetPlatformBuilderFactory();
+ LocalMetadataRepository localMetadataRepo = factory.getLocalMetadataRepository();
+ // add one IU to local repo
+ localMetadataRepo.addInstallableUnit(InstallableUnitUtil.createIU("locallyInstalledIU", "1.0.0"), new GAV(
+ "test", "foo", "1.0.0"));
+ TargetPlatformBuilderImpl tpBuilder = factory.createTargetPlatformBuilder();
+ Collection<IInstallableUnit> iusIncludingLocalRepo = tpBuilder.buildTargetPlatform().getInstallableUnits();
+ tpBuilder.setIncludeLocalMavenRepo(false);
+ Collection<IInstallableUnit> iusWithoutLocalRepo = tpBuilder.buildTargetPlatform().getInstallableUnits();
+ Set<IInstallableUnit> retainedIUs = new HashSet<IInstallableUnit>(iusIncludingLocalRepo);
+ retainedIUs.removeAll(iusWithoutLocalRepo);
+ assertEquals(1, retainedIUs.size());
+ assertEquals("locallyInstalledIU", retainedIUs.iterator().next().getId());
+ }
+
private void assertContainsIU(Collection<IInstallableUnit> units, String id) {
Assert.assertNotNull("Missing installable unit with id " + id, getIU(units, id));
}
@@ -32,11 +32,7 @@
*/
ExecutionEnvironmentResolutionHints getEEResolutionHints();
- /**
- * Notify the target platform implementation about which IUs are actually used. This for example
- * allows debug output.
- */
- void reportUsedIUs(Collection<IInstallableUnit> usedUnits);
+ void reportUsedLocalIUs(Collection<IInstallableUnit> usedUnits);
void downloadArtifacts(Collection<IInstallableUnit> usedUnits);
@@ -62,13 +62,6 @@ private static synchronized LocalMetadataRepository getLocalMetadataRepository(M
localMetadataRepository = new LocalMetadataRepository(localMavenRepoRoot.toURI(),
localRepoIndices.getMetadataIndex(), contentLocator);
- // TODO this logic shouldn't be here
- String localArtifactHandling = context.getSessionProperties().getProperty("tycho.localArtifacts");
- if ("ignore".equalsIgnoreCase(localArtifactHandling)) {
- context.getLogger().debug(
- "tycho.localArtifacts=" + localArtifactHandling + " -> ignoring locally built artifacts");
- localMetadataRepository.setIncludeInTargetPlatform(false);
- }
}
return localMetadataRepository;
}
Oops, something went wrong. Retry.

0 comments on commit 08631a0

Please sign in to comment.