diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/DependencyResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/DependencyResolver.java index 93aa52c8f0..736d659ce0 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/DependencyResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/DependencyResolver.java @@ -33,8 +33,7 @@ public interface DependencyResolver { PomDependencyCollector resolvePomDependencies(MavenSession session, MavenProject project); - public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project, - List reactorProjects); + public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project); /** * @param targetPlatform @@ -42,8 +41,8 @@ public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, Mav * null, the final target platform of the project will be used. */ public DependencyArtifacts resolveDependencies(MavenSession session, MavenProject project, - TargetPlatform targetPlatform, List reactorProjects, - DependencyResolverConfiguration resolverConfiguration, List environments); + TargetPlatform targetPlatform, DependencyResolverConfiguration resolverConfiguration, + List environments); public void injectDependenciesIntoMavenModel(MavenProject project, TychoProject projectType, DependencyArtifacts resolvedDependencies, DependencyArtifacts testDepedencyArtifacts, Logger logger); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java index f0e060e379..7fb65b8e67 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java @@ -80,13 +80,12 @@ public DependencyArtifacts getDependencyArtifacts(ReactorProject reactorProject) } MavenSession mavenSession = getMavenSession(reactorProject); MavenProject mavenProject = getMavenProject(reactorProject); - List reactorProjects = DefaultReactorProject.adapt(mavenSession); TargetPlatform preliminaryTargetPlatform = dependencyResolver.computePreliminaryTargetPlatform(mavenSession, - mavenProject, reactorProjects); + mavenProject); TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(mavenProject); DependencyResolverConfiguration resolverConfiguration = configuration.getDependencyResolverConfiguration(); DependencyArtifacts dependencyArtifacts = dependencyResolver.resolveDependencies(mavenSession, mavenProject, - preliminaryTargetPlatform, reactorProjects, resolverConfiguration, configuration.getEnvironments()); + preliminaryTargetPlatform, resolverConfiguration, configuration.getEnvironments()); if (logger != null) { if (logger.isDebugEnabled() && DebugUtils.isDebugEnabled(mavenSession, mavenProject)) { StringBuilder sb = new StringBuilder(); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java index d60817829d..162a8b8afe 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiBundleProject.java @@ -691,7 +691,6 @@ public DependencyArtifacts getTestDependencyArtifacts(ReactorProject reactorProj logger.info("Resolving test dependencies of " + reactorProject); MavenSession mavenSession = getMavenSession(reactorProject); MavenProject mavenProject = getMavenProject(reactorProject); - List reactorProjects = DefaultReactorProject.adapt(mavenSession); TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(mavenProject); DependencyResolverConfiguration resolverConfiguration = configuration.getDependencyResolverConfiguration(); DependencyResolverConfiguration testResolverConfiguration = new DependencyResolverConfiguration() { @@ -713,9 +712,9 @@ public Collection getAdditionalRequirements() { } }; TargetPlatform preliminaryTargetPlatform = dependencyResolver.computePreliminaryTargetPlatform(mavenSession, - mavenProject, reactorProjects); + mavenProject); return dependencyResolver.resolveDependencies(mavenSession, mavenProject, preliminaryTargetPlatform, - reactorProjects, testResolverConfiguration, configuration.getEnvironments()); + testResolverConfiguration, configuration.getEnvironments()); }); } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformService.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformService.java index c5ee914534..3c16ed915d 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformService.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformService.java @@ -123,7 +123,7 @@ private TargetPlatform computeFinalTargetPlatform(ReactorProject project, return null; } preliminaryTargetPlatform = (PreliminaryTargetPlatformImpl) dependencyResolver - .computePreliminaryTargetPlatform(session, mavenProject, DefaultReactorProject.adapt(session)); + .computePreliminaryTargetPlatform(session, mavenProject); } List upstreamProjectResults = getBuildResults(upstreamProjects); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2DependencyResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2DependencyResolver.java index 31c94c7966..87b6c64097 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2DependencyResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2DependencyResolver.java @@ -28,6 +28,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Objects; import java.util.Set; import java.util.TreeMap; import java.util.function.Function; @@ -83,7 +84,6 @@ import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; import org.eclipse.tycho.core.resolver.shared.PomDependencies; -import org.eclipse.tycho.core.utils.TychoProjectUtils; import org.eclipse.tycho.helper.PluginRealmHelper; import org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator; import org.eclipse.tycho.p2.metadata.PublisherOptions; @@ -196,16 +196,16 @@ protected Collection getDependencyMetadata(final MavenSessi } @Override - public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project, - List reactorProjects) { - ReactorProject reactorProject = DefaultReactorProject.adapt(project); + public TargetPlatform computePreliminaryTargetPlatform(MavenSession mavenSession, MavenProject mavenProject) { + ReactorProject reactorProject = DefaultReactorProject.adapt(mavenProject); return reactorProject.computeContextValue(TargetPlatform.PRELIMINARY_TARGET_PLATFORM_KEY, () -> { - logger.debug("Computing preliminary target platform for " + project); - TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(project); - ExecutionEnvironmentConfiguration ee = projectManager.getExecutionEnvironmentConfiguration(project); + logger.debug("Computing preliminary target platform for " + mavenProject); + List reactorProjects = DefaultReactorProject.adapt(mavenSession); + TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(mavenProject); + ExecutionEnvironmentConfiguration ee = projectManager.getExecutionEnvironmentConfiguration(mavenProject); TargetPlatformConfigurationStub tpConfiguration = new TargetPlatformConfigurationStub(); - for (ArtifactRepository repository : project.getRemoteArtifactRepositories()) { + for (ArtifactRepository repository : mavenProject.getRemoteArtifactRepositories()) { addEntireP2RepositoryToTargetPlatform(repository, tpConfiguration); } @@ -296,19 +296,13 @@ private void addEntireP2RepositoryToTargetPlatform(ArtifactRepository repository @Override public DependencyArtifacts resolveDependencies(final MavenSession session, final MavenProject project, - TargetPlatform targetPlatform, List reactorProjects, - DependencyResolverConfiguration resolverConfiguration, List environments) { - ReactorProject reactorProject = DefaultReactorProject.adapt(project); - if (targetPlatform == null) { - targetPlatform = TychoProjectUtils.getTargetPlatform(reactorProject); - } - - // TODO 364134 For compatibility reasons, target-platform-configuration includes settings for the dependency resolution - // --> split this information logically, e.g. through two distinct interfaces + TargetPlatform targetPlatform, DependencyResolverConfiguration resolverConfiguration, + List environments) { + Objects.requireNonNull(targetPlatform); TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(project); P2Resolver osgiResolverImpl = resolverFactory.createResolver(environments); - + List reactorProjects = DefaultReactorProject.adapt(session); return doResolveDependencies(session, project, reactorProjects, resolverConfiguration, targetPlatform, osgiResolverImpl, configuration); } @@ -431,4 +425,5 @@ private MavenDependencyDescriptor resolveDescriptorWithValidation(MavenProject p } return result; } + } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2tools/RepositoryReferenceTool.java b/tycho-core/src/main/java/org/eclipse/tycho/p2tools/RepositoryReferenceTool.java index e12095a942..6787b5d2b5 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2tools/RepositoryReferenceTool.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2tools/RepositoryReferenceTool.java @@ -34,7 +34,6 @@ import org.eclipse.tycho.core.DependencyResolverConfiguration; import org.eclipse.tycho.core.TargetPlatformConfiguration; import org.eclipse.tycho.core.TychoProjectManager; -import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.p2.repository.RepositoryBlackboardKey; import org.eclipse.tycho.p2.tools.RepositoryReferences; @@ -122,8 +121,7 @@ private void addTargetPlatformRepository(RepositoryReferences sources, MavenSess .getDependencyResolverConfiguration(); DependencyArtifacts dependencyArtifacts = dependencyResolver.resolveDependencies(session, project, - targetPlatform, DefaultReactorProject.adapt(session), resolverConfiguration, - configuration.getEnvironments()); + targetPlatform, resolverConfiguration, configuration.getEnvironments()); dependencyArtifacts.getArtifacts().forEach(artifact -> artifact.getLocation(true)); // ensure artifacts are available locally // this contains dependency-only metadata for 'this' project diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java index ca3159fd6d..42c6deeed3 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractEclipseTestMojo.java @@ -800,7 +800,7 @@ public Collection getAdditionalRequirements() { DependencyArtifacts testRuntimeArtifacts = dependencyResolver.resolveDependencies(session, project, projectManager.getTargetPlatform(project) .orElseThrow(() -> new MojoExecutionException(TychoConstants.TYCHO_NOT_CONFIGURED + project)), - getReactorProjects(), resolverConfiguration, getTestTargetEnvironments()); + resolverConfiguration, getTestTargetEnvironments()); if (testRuntimeArtifacts == null) { throw new MojoExecutionException( "Cannot determinate build target platform location -- not executing tests"); diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractTestMojo.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractTestMojo.java index 077ba33944..feec4bdceb 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractTestMojo.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/AbstractTestMojo.java @@ -310,10 +310,6 @@ protected ReactorProject getReactorProject() { return DefaultReactorProject.adapt(project); } - protected List getReactorProjects() { - return DefaultReactorProject.adapt(session); - } - /** * This generates a bundle that is a fragment to the host that enhances the original bundle by * the following items: