Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Oberlies2014-05-16 13:35:57 +0000
committerTobias Oberlies2014-05-20 09:56:37 +0000
commit3da912208f166302bcbf3c6ecac97554f9483536 (patch)
tree0a771f9f4d072af122db71ca1e037c5a7ee9a481
parent4fd98f40b0dbaaef3cec52af66796c9aace33987 (diff)
downloadorg.eclipse.tycho-3da912208f166302bcbf3c6ecac97554f9483536.tar.gz
org.eclipse.tycho-3da912208f166302bcbf3c6ecac97554f9483536.tar.xz
org.eclipse.tycho-3da912208f166302bcbf3c6ecac97554f9483536.zip
412416 Don't re-compute target platform in test mojo
- Since commit cb1a0a2, the special preparation for optional dependencies is no longer done in computeTargetPlatform (but instead in resolveDependencies). Therefore calling computeTargetPlatform is no longer necessary. - Also: Fix name of computeTargetPlaform - since commit dd1e6a7 it only aims to compute the preliminary target platform. When called in the middle of the build, it would have returned a mixture of preliminary/final metadata. With this change, we are certain to use the final target platform for resolving the test runtime. Bug: 412416 Change-Id: I30ee61cc67527af79b360cd20bfe1d42d26e3fce Signed-off-by: Tobias Oberlies <tobias.oberlies@sap.com>
-rw-r--r--tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformFactoryImpl.java7
-rw-r--r--tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java10
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformResolver.java11
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/targetplatform/LocalTargetPlatformResolver.java4
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoDependencyResolver.java7
-rw-r--r--tycho-core/src/main/java/org/eclipse/tycho/core/utils/TychoProjectUtils.java3
-rw-r--r--tycho-p2/tycho-p2-facade/src/main/java/org/eclipse/tycho/p2/resolver/P2TargetPlatformResolver.java18
-rw-r--r--tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java8
8 files changed, 32 insertions, 36 deletions
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformFactoryImpl.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformFactoryImpl.java
index 812932976..73a1ab415 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformFactoryImpl.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.impl/src/main/java/org/eclipse/tycho/p2/target/TargetPlatformFactoryImpl.java
@@ -176,8 +176,7 @@ public class TargetPlatformFactoryImpl implements TargetPlatformFactory {
LinkedHashSet<IInstallableUnit> externalUIs = gatherExternalInstallableUnits(completeRepositories,
targetFileContent, pomDependenciesContent, includeLocalMavenRepo);
- Map<IInstallableUnit, ReactorProjectIdentities> reactorProjectUIs = getPreliminaryReactorProjectUIs(
- reactorProjects, tpConfiguration.getFailOnDuplicateIUs());
+ Map<IInstallableUnit, ReactorProjectIdentities> reactorProjectUIs = getPreliminaryReactorProjectUIs(reactorProjects);
List<TargetPlatformFilter> iuFilters = tpConfiguration.getFilters();
TargetPlatformFilterEvaluator filter = !iuFilters.isEmpty() ? new TargetPlatformFilterEvaluator(iuFilters,
@@ -338,7 +337,7 @@ public class TargetPlatformFactoryImpl implements TargetPlatformFactory {
}
private Map<IInstallableUnit, ReactorProjectIdentities> getPreliminaryReactorProjectUIs(
- List<ReactorProject> reactorProjects, boolean failOnDuplicateIUs) throws DuplicateReactorIUsException {
+ List<ReactorProject> reactorProjects) throws DuplicateReactorIUsException {
if (reactorProjects == null) {
return Collections.emptyMap();
}
@@ -367,7 +366,7 @@ public class TargetPlatformFactoryImpl implements TargetPlatformFactory {
}
}
- if (failOnDuplicateIUs && !duplicateReactorUIs.isEmpty()) {
+ if (!duplicateReactorUIs.isEmpty()) {
// TODO 392320 we should only fail if IUs with same id and version but different content are found
throw new DuplicateReactorIUsException(duplicateReactorUIs);
}
diff --git a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java
index 0be3e6f7a..9505cb5f4 100644
--- a/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java
+++ b/tycho-bundles/org.eclipse.tycho.p2.resolver.shared/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java
@@ -31,8 +31,6 @@ public class TargetPlatformConfigurationStub {
private final List<TargetDefinition> targetDefinitions = new ArrayList<TargetDefinition>();
private boolean forceIgnoreLocalArtifacts = false;
- private boolean failOnDuplicateIUs = true;
-
public void setEnvironments(List<TargetEnvironment> environments) {
this.environments = environments;
}
@@ -78,14 +76,6 @@ public class TargetPlatformConfigurationStub {
return targetDefinitions;
}
- public void setFailOnDuplicateIUs(boolean failOnDuplicateIUs) {
- this.failOnDuplicateIUs = failOnDuplicateIUs;
- }
-
- public boolean getFailOnDuplicateIUs() {
- return failOnDuplicateIUs;
- }
-
public void setForceIgnoreLocalArtifacts(boolean forceIgnoreLocalArtifacts) {
this.forceIgnoreLocalArtifacts = forceIgnoreLocalArtifacts;
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformResolver.java
index f7436bd2c..6c98084fd 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformResolver.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformResolver.java
@@ -28,11 +28,16 @@ import org.eclipse.tycho.core.osgitools.AbstractTychoProject;
public interface TargetPlatformResolver {
public void setupProjects(MavenSession session, MavenProject project, ReactorProject reactorProject);
- public TargetPlatform computeTargetPlatform(MavenSession session, MavenProject project,
- List<ReactorProject> reactorProjects, boolean failOnDuplicateIUs);
+ public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project,
+ List<ReactorProject> reactorProjects);
+ /**
+ * @param targetPlatform
+ * The candidate artifacts which may be used to resolve dependencies. If
+ * <code>null</code>, the final target platform of the project will be used.
+ */
public DependencyArtifacts resolveDependencies(MavenSession session, MavenProject project,
- TargetPlatform resolutionContext, List<ReactorProject> reactorProjects,
+ TargetPlatform targetPlatform, List<ReactorProject> reactorProjects,
DependencyResolverConfiguration resolverConfiguration);
public void injectDependenciesIntoMavenModel(MavenProject project, AbstractTychoProject projectType,
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/targetplatform/LocalTargetPlatformResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/targetplatform/LocalTargetPlatformResolver.java
index b8cf01464..27c17daf0 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/targetplatform/LocalTargetPlatformResolver.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/targetplatform/LocalTargetPlatformResolver.java
@@ -97,8 +97,8 @@ public class LocalTargetPlatformResolver extends AbstractTargetPlatformResolver
}
}
- public TargetPlatform computeTargetPlatform(MavenSession session, MavenProject project,
- List<ReactorProject> reactorProjects, boolean failOnDuplicateIUs) {
+ public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project,
+ List<ReactorProject> reactorProjects) {
// everything is done in resolveDependencies
return null;
}
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoDependencyResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoDependencyResolver.java
index 8b3dcb06e..dc74a885a 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoDependencyResolver.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoDependencyResolver.java
@@ -96,15 +96,16 @@ public class DefaultTychoDependencyResolver implements TychoDependencyResolver {
TargetPlatformResolver resolver = targetPlatformResolverLocator.lookupPlatformResolver(project);
logger.info("Computing target platform for " + project);
- TargetPlatform targetPlatform = resolver.computeTargetPlatform(session, project, reactorProjects, true);
+ TargetPlatform preliminaryTargetPlatform = resolver.computePreliminaryTargetPlatform(session, project,
+ reactorProjects);
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
DependencyResolverConfiguration resolverConfiguration = configuration.getDependencyResolverConfiguration();
logger.info("Resolving dependencies of " + project);
- DependencyArtifacts dependencyArtifacts = resolver.resolveDependencies(session, project, targetPlatform,
- reactorProjects, resolverConfiguration);
+ DependencyArtifacts dependencyArtifacts = resolver.resolveDependencies(session, project,
+ preliminaryTargetPlatform, reactorProjects, resolverConfiguration);
if (logger.isDebugEnabled() && DebugUtils.isDebugEnabled(session, project)) {
StringBuilder sb = new StringBuilder();
diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/utils/TychoProjectUtils.java b/tycho-core/src/main/java/org/eclipse/tycho/core/utils/TychoProjectUtils.java
index 985ee5847..3fd16586c 100644
--- a/tycho-core/src/main/java/org/eclipse/tycho/core/utils/TychoProjectUtils.java
+++ b/tycho-core/src/main/java/org/eclipse/tycho/core/utils/TychoProjectUtils.java
@@ -61,6 +61,9 @@ public class TychoProjectUtils {
return targetPlatformConfiguration;
}
+ /**
+ * Returns the final target platform of the given project.
+ */
public static TargetPlatform getTargetPlatform(MavenProject project) {
TargetPlatform targetPlatform = (TargetPlatform) project.getContextValue(TychoConstants.CTX_TARGET_PLATFORM);
if (targetPlatform == null) {
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 c1006a3ad..f7e9999af 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
@@ -185,14 +185,13 @@ public class P2TargetPlatformResolver extends AbstractTargetPlatformResolver imp
return false;
}
- public TargetPlatform computeTargetPlatform(MavenSession session, MavenProject project,
- List<ReactorProject> reactorProjects, boolean failOnDuplicateIUs) {
+ public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project,
+ List<ReactorProject> reactorProjects) {
TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
ExecutionEnvironmentConfiguration ee = TychoProjectUtils.getExecutionEnvironmentConfiguration(project);
TargetPlatformConfigurationStub tpConfiguration = new TargetPlatformConfigurationStub();
tpConfiguration.setIncludePackedArtifacts(configuration.isIncludePackedArtifacts());
- tpConfiguration.setFailOnDuplicateIUs(failOnDuplicateIUs);
PomDependencyCollector pomDependencies = null;
if (TargetPlatformConfiguration.POM_DEPENDENCIES_CONSIDER.equals(configuration.getPomDependencies())) {
@@ -311,8 +310,11 @@ public class P2TargetPlatformResolver extends AbstractTargetPlatformResolver imp
}
public DependencyArtifacts resolveDependencies(final MavenSession session, final MavenProject project,
- TargetPlatform resolutionContext, List<ReactorProject> reactorProjects,
+ TargetPlatform targetPlatform, List<ReactorProject> reactorProjects,
DependencyResolverConfiguration resolverConfiguration) {
+ if (targetPlatform == null) {
+ targetPlatform = TychoProjectUtils.getTargetPlatform(project);
+ }
// TODO 364134 For compatibility reasons, target-platform-configuration includes settings for the dependency resolution
// --> split this information logically, e.g. through two distinct interfaces
@@ -321,13 +323,13 @@ public class P2TargetPlatformResolver extends AbstractTargetPlatformResolver imp
P2Resolver osgiResolverImpl = resolverFactory.createResolver(new MavenLoggerAdapter(getLogger(), DebugUtils
.isDebugEnabled(session, project)));
- return doResolveDependencies(session, project, reactorProjects, resolverConfiguration, resolutionContext,
+ return doResolveDependencies(session, project, reactorProjects, resolverConfiguration, targetPlatform,
osgiResolverImpl, configuration);
}
private DependencyArtifacts doResolveDependencies(MavenSession session, MavenProject project,
List<ReactorProject> reactorProjects, DependencyResolverConfiguration resolverConfiguration,
- TargetPlatform resolutionContext, P2Resolver resolver, TargetPlatformConfiguration configuration) {
+ TargetPlatform targetPlatform, P2Resolver resolver, TargetPlatformConfiguration configuration) {
Map<File, ReactorProject> projects = new HashMap<File, ReactorProject>();
@@ -348,7 +350,7 @@ public class P2TargetPlatformResolver extends AbstractTargetPlatformResolver imp
ReactorProject optionalDependencyPreparedProject = getThisReactorProject(session, project, configuration);
if (!isAllowConflictingDependencies(project, configuration)) {
- List<P2ResolutionResult> results = resolver.resolveDependencies(resolutionContext,
+ List<P2ResolutionResult> results = resolver.resolveDependencies(targetPlatform,
optionalDependencyPreparedProject);
MultiEnvironmentTargetPlatform multiPlatform = new MultiEnvironmentTargetPlatform(
@@ -367,7 +369,7 @@ public class P2TargetPlatformResolver extends AbstractTargetPlatformResolver imp
return multiPlatform;
} else {
- P2ResolutionResult result = resolver.collectProjectDependencies(resolutionContext,
+ P2ResolutionResult result = resolver.collectProjectDependencies(targetPlatform,
optionalDependencyPreparedProject);
return newDefaultTargetPlatform(DefaultReactorProject.adapt(project), projects, result);
diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java
index 283e6ee8a..2ba5a1e58 100644
--- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java
+++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TestMojo.java
@@ -54,7 +54,6 @@ import org.eclipse.tycho.ArtifactDescriptor;
import org.eclipse.tycho.ArtifactKey;
import org.eclipse.tycho.ReactorProject;
import org.eclipse.tycho.artifacts.DependencyArtifacts;
-import org.eclipse.tycho.artifacts.TargetPlatform;
import org.eclipse.tycho.core.BundleProject;
import org.eclipse.tycho.core.DependencyResolverConfiguration;
import org.eclipse.tycho.core.TargetPlatformConfiguration;
@@ -731,9 +730,6 @@ public class TestMojo extends AbstractMojo {
TargetPlatformResolver platformResolver = targetPlatformResolverLocator.lookupPlatformResolver(project);
final List<Dependency> extraDependencies = getExtraDependencies();
List<ReactorProject> reactorProjects = getReactorProjects();
- // TODO 364134 re-use target platform from dependency resolution
- TargetPlatform targetPlatform = platformResolver
- .computeTargetPlatform(session, project, reactorProjects, false);
final DependencyResolverConfiguration resolverConfiguration = new DependencyResolverConfiguration() {
public OptionalResolutionAction getOptionalResolutionAction() {
@@ -745,8 +741,8 @@ public class TestMojo extends AbstractMojo {
}
};
- DependencyArtifacts testRuntimeArtifacts = platformResolver.resolveDependencies(session, project,
- targetPlatform, reactorProjects, resolverConfiguration);
+ DependencyArtifacts testRuntimeArtifacts = platformResolver.resolveDependencies(session, project, null,
+ reactorProjects, resolverConfiguration);
if (testRuntimeArtifacts == null) {
throw new MojoExecutionException("Cannot determinate build target platform location -- not executing tests");

Back to the top