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 ebed7133f5..c5ee914534 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 @@ -55,10 +55,12 @@ public class DefaultTargetPlatformService implements TargetPlatformService { private DependencyResolver dependencyResolver; @Requirement - ReactorRepositoryManager repositoryManager; + private ReactorRepositoryManager repositoryManager; + + @Requirement + private P2ResolverFactory p2ResolverFactory; @Requirement - P2ResolverFactory p2ResolverFactory; private TargetPlatformFactory tpFactory; @Override @@ -125,8 +127,8 @@ private TargetPlatform computeFinalTargetPlatform(ReactorProject project, } List upstreamProjectResults = getBuildResults(upstreamProjects); - TargetPlatform result = getTpFactory().createTargetPlatformWithUpdatedReactorContent( - preliminaryTargetPlatform, upstreamProjectResults, pomDependencyCollector); + TargetPlatform result = tpFactory.createTargetPlatformWithUpdatedReactorContent(preliminaryTargetPlatform, + upstreamProjectResults, pomDependencyCollector); project.setContextValue(TargetPlatform.FINAL_TARGET_PLATFORM_KEY, result); return result; @@ -141,13 +143,6 @@ private List getBuildResults(List l ExecutionEnvironmentConfiguration eeConfiguration = new ExecutionEnvironmentConfigurationImpl(logger, false, toolchainManager, mavenSession); eeConfiguration.setProfileConfiguration("JavaSE-" + javaVersion, "tycho-eclipse-application-resolver"); - TargetPlatform targetPlatform = resolverFactory.getTargetPlatformFactory().createTargetPlatform(tpConfiguration, - eeConfiguration, null); + TargetPlatform targetPlatform = platformFactory.createTargetPlatform(tpConfiguration, eeConfiguration, null); return targetPlatform; } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/DefaultTargetPlatformFactory.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/DefaultTargetPlatformFactory.java new file mode 100644 index 0000000000..19329e85a1 --- /dev/null +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/DefaultTargetPlatformFactory.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2008, 2023 Sonatype Inc. and others. + * This program and the accompanying materials + * are made available under the terms of the Eclipse Public License 2.0 + * which accompanies this distribution, and is available at + * https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + * + * Contributors: + * Sonatype Inc. - initial API and implementation + * Christoph Läubrich - Bug 567098 - pomDependencies=consider should wrap non-osgi jars + * Issue #443 - Use regular Maven coordinates -when possible- for dependencies + * Issue #822 - If multiple fragments match a bundle all items are added to the classpath while only the one with the highest version should match + * Extracted into DefaultTargetPlatformFactory + *******************************************************************************/ +package org.eclipse.tycho.p2resolver; + +import java.io.File; +import java.util.List; + +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.eclipse.equinox.p2.core.IProvisioningAgent; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; +import org.eclipse.tycho.ExecutionEnvironmentConfiguration; +import org.eclipse.tycho.IRepositoryIdManager; +import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.TargetPlatform; +import org.eclipse.tycho.core.TychoProjectManager; +import org.eclipse.tycho.core.osgitools.MavenBundleResolver; +import org.eclipse.tycho.core.shared.MavenContext; +import org.eclipse.tycho.p2.repository.LocalArtifactRepository; +import org.eclipse.tycho.p2.repository.LocalMetadataRepository; +import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices; +import org.eclipse.tycho.p2.repository.LocalRepositoryReader; +import org.eclipse.tycho.p2.repository.RepositoryReader; +import org.eclipse.tycho.p2.target.facade.PomDependencyCollector; +import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; +import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory; + +@Component(role = TargetPlatformFactory.class) +public class DefaultTargetPlatformFactory implements TargetPlatformFactory { + + // TODO cache these instances in an p2 agent, and not here + private LocalMetadataRepository localMetadataRepository; + private LocalArtifactRepository localArtifactRepository; + + @Requirement + private IProvisioningAgent agent; + + @Requirement + private MavenContext mavenContext; + + @Requirement + private LocalRepositoryP2Indices localRepoIndices; + + @Requirement + private IRepositoryIdManager repositoryIdManager; + + @Requirement + private MavenBundleResolver bundleResolver; + + @Requirement + private TychoProjectManager projectManager; + + @Requirement + private TargetDefinitionResolverService targetDefinitionResolverService; + private TargetPlatformFactoryImpl impl; + + @Override + public TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpConfiguration, + ExecutionEnvironmentConfiguration eeConfiguration, List reactorProjects, + ReactorProject project) { + return getImpl().createTargetPlatform(tpConfiguration, eeConfiguration, reactorProjects, project); + } + + @Override + public TargetPlatform createTargetPlatformWithUpdatedReactorContent(TargetPlatform baseTargetPlatform, + List upstreamProjectResults, PomDependencyCollector pomDependencies) { + return getImpl().createTargetPlatformWithUpdatedReactorContent(baseTargetPlatform, upstreamProjectResults, + pomDependencies); + } + + private TargetPlatformFactory getImpl() { + if (impl == null) { + // TODO should be plexus-components! + LocalMetadataRepository localMetadataRepo = getLocalMetadataRepository(mavenContext, localRepoIndices); + LocalArtifactRepository localArtifactRepo = getLocalArtifactRepository(mavenContext, localRepoIndices); + //TODO merge the impl here... + impl = new TargetPlatformFactoryImpl(mavenContext, agent, localArtifactRepo, localMetadataRepo, + targetDefinitionResolverService, repositoryIdManager, projectManager, bundleResolver); + } + return impl; + } + + private synchronized LocalMetadataRepository getLocalMetadataRepository(MavenContext context, + LocalRepositoryP2Indices localRepoIndices) { + if (localMetadataRepository == null) { + File localMavenRepoRoot = context.getLocalRepositoryRoot(); + RepositoryReader contentLocator = new LocalRepositoryReader(context); + localMetadataRepository = new LocalMetadataRepository(getAgent(), localMavenRepoRoot.toURI(), + localRepoIndices.getMetadataIndex(), contentLocator); + + } + return localMetadataRepository; + } + + private synchronized LocalArtifactRepository getLocalArtifactRepository(MavenContext mavenContext, + LocalRepositoryP2Indices localRepoIndices) { + if (localArtifactRepository == null) { + RepositoryReader contentLocator = new LocalRepositoryReader(mavenContext); + localArtifactRepository = new LocalArtifactRepository(getAgent(), localRepoIndices, contentLocator); + } + return localArtifactRepository; + } + + private IProvisioningAgent getAgent() { + //force triggering service loads... just in case not initialized yet ... + agent.getService(IArtifactRepositoryManager.class); + return agent; + } +} 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 145f765ca5..491df4e564 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; @@ -140,6 +141,7 @@ public class P2DependencyResolver implements DependencyResolver, Initializable { @Requirement private MavenDependenciesResolver dependenciesResolver; + @Requirement private TargetPlatformFactory tpFactory; @Requirement @@ -218,19 +220,12 @@ public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, Mav tpConfiguration .setIgnoreLocalArtifacts(configuration.getIgnoreLocalArtifacts() == LocalArtifactHandling.ignore); tpConfiguration.setReferencedRepositoryMode(configuration.getReferencedRepositoryMode()); - TargetPlatform result = getTpFactory().createTargetPlatform(tpConfiguration, ee, reactorProjects, + TargetPlatform result = tpFactory.createTargetPlatform(tpConfiguration, ee, reactorProjects, reactorProject); return result; }); } - private synchronized TargetPlatformFactory getTpFactory() { - if (tpFactory == null) { - tpFactory = resolverFactory.getTargetPlatformFactory(); - } - return tpFactory; - } - private ReactorProject getThisReactorProject(MavenSession session, MavenProject project, TargetPlatformConfiguration configuration) { // 'this' project should obey optionalDependencies configuration diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverFactoryImpl.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverFactoryImpl.java index 48ad6bfd0d..ae112056b5 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverFactoryImpl.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverFactoryImpl.java @@ -15,7 +15,6 @@ *******************************************************************************/ package org.eclipse.tycho.p2resolver; -import java.io.File; import java.util.AbstractMap.SimpleEntry; import java.util.ArrayList; import java.util.Collection; @@ -53,20 +52,13 @@ import org.eclipse.tycho.core.resolver.P2ResolverFactory; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.core.shared.MavenLogger; -import org.eclipse.tycho.p2.repository.LocalArtifactRepository; -import org.eclipse.tycho.p2.repository.LocalMetadataRepository; import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices; -import org.eclipse.tycho.p2.repository.LocalRepositoryReader; -import org.eclipse.tycho.p2.repository.RepositoryReader; import org.eclipse.tycho.p2.target.facade.PomDependencyCollector; +import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory; @Component(role = P2ResolverFactory.class) public class P2ResolverFactoryImpl implements P2ResolverFactory { - // TODO cache these instances in an p2 agent, and not here - private LocalMetadataRepository localMetadataRepository; - private LocalArtifactRepository localArtifactRepository; - @Requirement IProvisioningAgent agent; @@ -93,26 +85,8 @@ public class P2ResolverFactoryImpl implements P2ResolverFactory { @Requirement private MavenBundleResolver bundleResolver; - private synchronized LocalMetadataRepository getLocalMetadataRepository(MavenContext context, - LocalRepositoryP2Indices localRepoIndices) { - if (localMetadataRepository == null) { - File localMavenRepoRoot = context.getLocalRepositoryRoot(); - RepositoryReader contentLocator = new LocalRepositoryReader(context); - localMetadataRepository = new LocalMetadataRepository(getAgent(), localMavenRepoRoot.toURI(), - localRepoIndices.getMetadataIndex(), contentLocator); - - } - return localMetadataRepository; - } - - private synchronized LocalArtifactRepository getLocalArtifactRepository(MavenContext mavenContext, - LocalRepositoryP2Indices localRepoIndices) { - if (localArtifactRepository == null) { - RepositoryReader contentLocator = new LocalRepositoryReader(mavenContext); - localArtifactRepository = new LocalArtifactRepository(getAgent(), localRepoIndices, contentLocator); - } - return localArtifactRepository; - } + @Requirement + private TargetPlatformFactory targetPlatformFactory; private IProvisioningAgent getAgent() { //force triggering service loads... just in case not initialized yet ... @@ -129,18 +103,9 @@ public PomDependencyCollector newPomDependencyCollector(ReactorProject project) return new PomDependencyCollectorImpl(logger, project, getAgent()); } - @Override - public TargetPlatformFactoryImpl getTargetPlatformFactory() { - // TODO should be plexus-components! - LocalMetadataRepository localMetadataRepo = getLocalMetadataRepository(mavenContext, localRepoIndices); - LocalArtifactRepository localArtifactRepo = getLocalArtifactRepository(mavenContext, localRepoIndices); - return new TargetPlatformFactoryImpl(mavenContext, agent, localArtifactRepo, localMetadataRepo, - targetDefinitionResolverService, repositoryIdManager, projectManager, bundleResolver); - } - @Override public P2Resolver createResolver(Collection environments) { - return new P2ResolverImpl(getTargetPlatformFactory(), this, mavenContext.getLogger(), environments); + return new P2ResolverImpl(targetPlatformFactory, this, mavenContext.getLogger(), environments); } public Set calculateDependencyFragments(ResolutionData data, diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/PublisherServiceFactoryImpl.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/PublisherServiceFactoryImpl.java index 75b7cc1be4..0f9ec06724 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/PublisherServiceFactoryImpl.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/PublisherServiceFactoryImpl.java @@ -19,7 +19,7 @@ import org.eclipse.tycho.Interpolator; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.TargetEnvironment; -import org.eclipse.tycho.TargetPlatform; +import org.eclipse.tycho.TargetPlatformService; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.p2.repository.PublishingRepository; import org.eclipse.tycho.p2.tools.publisher.PublishProductToolImpl; @@ -39,9 +39,14 @@ public class PublisherServiceFactoryImpl implements PublisherServiceFactory { @Requirement private ReactorRepositoryManager reactorRepoManager; + @Requirement + private TargetPlatformService targetPlatformService; + @Override public PublisherService createPublisher(ReactorProject project, List environments) { - P2TargetPlatform targetPlatform = (P2TargetPlatform) getFinalTargetPlatform(project); + P2TargetPlatform targetPlatform = targetPlatformService.getTargetPlatform(project) + .filter(P2TargetPlatform.class::isInstance).map(P2TargetPlatform.class::cast) + .orElseThrow(() -> new IllegalStateException("Target platform is missing")); PublisherActionRunner publisherRunner = getPublisherRunnerForProject(targetPlatform, environments); PublishingRepository publishingRepository = reactorRepoManager.getPublishingRepository(project); @@ -51,7 +56,9 @@ public PublisherService createPublisher(ReactorProject project, List environments, String buildQualifier, Interpolator interpolator) { - P2TargetPlatform targetPlatform = (P2TargetPlatform) getFinalTargetPlatform(project); + P2TargetPlatform targetPlatform = targetPlatformService.getTargetPlatform(project) + .filter(P2TargetPlatform.class::isInstance).map(P2TargetPlatform.class::cast) + .orElseThrow(() -> new IllegalStateException("Target platform is missing")); PublisherActionRunner publisherRunner = getPublisherRunnerForProject(targetPlatform, environments); PublishingRepository publishingRepository = reactorRepoManager.getPublishingRepository(project); @@ -59,40 +66,10 @@ public PublishProductTool createProductPublisher(ReactorProject project, List environments) { - checkCollaborators(); - return new PublisherActionRunner(targetPlatform.getMetadataRepository(), environments, mavenContext.getLogger()); } - // setters for DS - - public void setMavenContext(MavenContext mavenContext) { - this.mavenContext = mavenContext; - } - - public void setReactorRepositoryManager(ReactorRepositoryManager reactorRepoManager) { - this.reactorRepoManager = reactorRepoManager; - } - - private void checkCollaborators() { - if (mavenContext == null || reactorRepoManager == null) { - throw new IllegalStateException(); // shoudn't happen; see OSGI-INF/publisherfactory.xml - } - } - } diff --git a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/CustomEEResolutionHandlerTest.java b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/CustomEEResolutionHandlerTest.java index 9eb6ab96f8..edbbbc37fe 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/CustomEEResolutionHandlerTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/CustomEEResolutionHandlerTest.java @@ -24,17 +24,14 @@ import java.util.Collections; import java.util.List; -import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.tycho.ExecutionEnvironment; import org.eclipse.tycho.ExecutionEnvironmentConfiguration; import org.eclipse.tycho.SystemCapability; import org.eclipse.tycho.SystemCapability.Type; -import org.eclipse.tycho.core.resolver.MavenTargetLocationFactory; import org.eclipse.tycho.core.test.utils.ResourceUtil; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory; import org.eclipse.tycho.test.util.LogVerifier; -import org.eclipse.tycho.test.util.TestResolverFactory; import org.eclipse.tycho.testing.TychoPlexusTestCase; import org.junit.Before; import org.junit.Rule; @@ -50,8 +47,7 @@ public class CustomEEResolutionHandlerTest extends TychoPlexusTestCase { @Before public void setUpContext() throws Exception { - tpFactory = new TestResolverFactory(logVerifier.getMavenLogger(), logVerifier.getLogger(), - lookup(IProvisioningAgent.class), lookup(MavenTargetLocationFactory.class)).getTargetPlatformFactory(); + tpFactory = lookup(TargetPlatformFactory.class); tpConfig = new TargetPlatformConfigurationStub(); } diff --git a/tycho-core/src/test/java/org/eclipse/tycho/test/util/TestResolverFactory.java b/tycho-core/src/test/java/org/eclipse/tycho/test/util/TestResolverFactory.java index 3b797f536a..ce54c8a915 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/test/util/TestResolverFactory.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/test/util/TestResolverFactory.java @@ -33,7 +33,6 @@ import org.eclipse.tycho.p2.repository.LocalMetadataRepository; import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices; import org.eclipse.tycho.p2.repository.LocalRepositoryReader; -import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory; import org.eclipse.tycho.p2resolver.DefaultTargetDefinitionVariableResolver; import org.eclipse.tycho.p2resolver.LocalRepositoryP2IndicesImpl; import org.eclipse.tycho.p2resolver.P2ResolverImpl; @@ -102,11 +101,6 @@ public PomDependencyCollectorImpl newPomDependencyCollector() { return newPomDependencyCollector(new ReactorProjectStub(new File("."), "test")); } - @Override - public TargetPlatformFactory getTargetPlatformFactory() { - return getTargetPlatformFactoryImpl(); - } - public TargetPlatformFactoryImpl getTargetPlatformFactoryImpl() { return new TargetPlatformFactoryImpl(mavenContext, agent, localArtifactRepo, localMetadataRepo, targetDefinitionResolverService, idManager, null, null); diff --git a/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipserun/EclipseRunMojo.java b/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipserun/EclipseRunMojo.java index 323a857298..c694169d93 100644 --- a/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipserun/EclipseRunMojo.java +++ b/tycho-eclipse-plugin/src/main/java/org/eclipse/tycho/eclipserun/EclipseRunMojo.java @@ -57,6 +57,7 @@ import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; +import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory; /** * Launch an eclipse process with arbitrary commandline arguments. The eclipse @@ -265,6 +266,9 @@ public class EclipseRunMojo extends AbstractMojo { @Component private ToolchainManager toolchainManager; + @Component + private TargetPlatformFactory platformFactory; + public EclipseRunMojo() { // default constructor } @@ -278,7 +282,7 @@ public EclipseRunMojo(File work, boolean clearWorkspaceBeforeLaunch, MavenProjec List applicationArgs, int forkedProcessTimeoutInSeconds, Map environmentVariables, EquinoxInstallationFactory installationFactory, EquinoxLauncher launcher, ToolchainProvider toolchainProvider, P2ResolverFactory resolverFactory, Logger logger, - ToolchainManager toolchainManager) { + ToolchainManager toolchainManager, TargetPlatformFactory platformFactory) { this.work = work; this.clearWorkspaceBeforeLaunch = clearWorkspaceBeforeLaunch; this.project = project; @@ -298,6 +302,7 @@ public EclipseRunMojo(File work, boolean clearWorkspaceBeforeLaunch, MavenProjec this.resolverFactory = resolverFactory; this.logger = logger; this.toolchainManager = toolchainManager; + this.platformFactory = platformFactory; } @Override @@ -340,8 +345,7 @@ private EquinoxInstallation createEclipseInstallation() throws MojoFailureExcept ExecutionEnvironmentConfiguration eeConfiguration = new ExecutionEnvironmentConfigurationImpl(logger, false, toolchainManager, session); eeConfiguration.setProfileConfiguration(executionEnvironment, "tycho-eclipserun-plugin "); - TargetPlatform targetPlatform = resolverFactory.getTargetPlatformFactory().createTargetPlatform(tpConfiguration, - eeConfiguration, null); + TargetPlatform targetPlatform = platformFactory.createTargetPlatform(tpConfiguration, eeConfiguration, null); P2Resolver resolver = resolverFactory .createResolver(Collections.singletonList(TargetEnvironment.getRunningEnvironment())); for (Dependency dependency : dependencies) { diff --git a/tycho-eclipse-plugin/src/test/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojoTest.java b/tycho-eclipse-plugin/src/test/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojoTest.java index 8460d243a1..f09ecccf26 100644 --- a/tycho-eclipse-plugin/src/test/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojoTest.java +++ b/tycho-eclipse-plugin/src/test/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojoTest.java @@ -142,10 +142,10 @@ public void testExecutionEnvironmentIsRespectedDuringDependencyResolution() thro P2Resolver mockP2Resolver = mock(P2Resolver.class); P2ResolverFactory mockP2ResolverFactory = mock(P2ResolverFactory.class); - when(mockP2ResolverFactory.getTargetPlatformFactory()).thenReturn(mockTargetPlatformFactory); when(mockP2ResolverFactory.createResolver(any())).thenReturn(mockP2Resolver); setVariableValueToObject(runMojo, "resolverFactory", mockP2ResolverFactory); + setVariableValueToObject(runMojo, "platformFactory", mockTargetPlatformFactory); setVariableValueToObject(runMojo, "executionEnvironment", "custom-ee"); diff --git a/tycho-extras/tycho-p2-extras-plugin/src/main/java/org/eclipse/tycho/plugins/p2/extras/CompareWithBaselineMojo.java b/tycho-extras/tycho-p2-extras-plugin/src/main/java/org/eclipse/tycho/plugins/p2/extras/CompareWithBaselineMojo.java index 45682644c2..b1f7d32da8 100644 --- a/tycho-extras/tycho-p2-extras-plugin/src/main/java/org/eclipse/tycho/plugins/p2/extras/CompareWithBaselineMojo.java +++ b/tycho-extras/tycho-p2-extras-plugin/src/main/java/org/eclipse/tycho/plugins/p2/extras/CompareWithBaselineMojo.java @@ -46,6 +46,7 @@ import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; +import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory; import org.osgi.framework.Version; /** @@ -114,6 +115,9 @@ public static enum ReportBehavior { @Component private TychoProjectManager projectManager; + @Component + private TargetPlatformFactory platformFactory; + /** * The hint of an available {@link ArtifactComparator} component to use for comparison of * artifacts with same version. @@ -151,8 +155,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { } ExecutionEnvironmentConfiguration eeConfiguration = projectManager .getExecutionEnvironmentConfiguration(project); - TargetPlatform baselineTP = resolverFactory.getTargetPlatformFactory().createTargetPlatform(baselineTPStub, - eeConfiguration, null); + TargetPlatform baselineTP = platformFactory.createTargetPlatform(baselineTPStub, eeConfiguration, null); for (IInstallableUnit item : dependencyMetadata) { try {