From bd0da0a00478313f01f6eadfd6e78956d8df7796 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 23 Dec 2022 06:36:35 +0100 Subject: [PATCH 01/19] Remove getDeprecatedTargetEnvironment from the parser --- ...aultTargetPlatformConfigurationReader.java | 21 ------------------- 1 file changed, 21 deletions(-) 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 db1608ebf2..03c9d77c15 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 @@ -302,18 +302,8 @@ private void setDisableP2Mirrors(Xpp3Dom configuration) { private void addTargetEnvironments(TargetPlatformConfiguration result, MavenProject project, Xpp3Dom configuration) { try { - TargetEnvironment deprecatedTargetEnvironmentSpec = getDeprecatedTargetEnvironment(configuration); - if (deprecatedTargetEnvironmentSpec != null) { - result.addEnvironment(deprecatedTargetEnvironmentSpec); - } - Xpp3Dom environmentsDom = configuration.getChild(ENVIRONMENTS); if (environmentsDom != null) { - if (deprecatedTargetEnvironmentSpec != null) { - String message = "Deprecated target-platform-configuration element must not be combined with new element; check the (inherited) configuration of " - + project.getId(); - throw new RuntimeException(message); - } for (Xpp3Dom environmentDom : environmentsDom.getChildren("environment")) { result.addEnvironment(newTargetEnvironment(environmentDom)); } @@ -323,17 +313,6 @@ private void addTargetEnvironments(TargetPlatformConfiguration result, MavenProj } } - protected TargetEnvironment getDeprecatedTargetEnvironment(Xpp3Dom configuration) - throws TargetPlatformConfigurationException { - Xpp3Dom environmentDom = configuration.getChild("environment"); - if (environmentDom != null) { - logger.warn( - "target-platform-configuration element is deprecated; use instead"); - return newTargetEnvironment(environmentDom); - } - return null; - } - private void setPomDependencies(TargetPlatformConfiguration result, Xpp3Dom configuration) { String value = getStringValue(configuration.getChild(POM_DEPENDENCIES)); if (value == null) { From f45dd787b487acada4e2eef8f9a0f078424b9d73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 23 Dec 2022 08:04:55 +0100 Subject: [PATCH 02/19] Filter non matching TargetEnvironments already in the config --- .../org/eclipse/tycho/TargetEnvironment.java | 7 ++- .../org/eclipse/tycho/core/TychoProject.java | 3 ++ .../core/osgitools/AbstractTychoProject.java | 6 +++ .../tycho/core/osgitools/EquinoxResolver.java | 6 +-- .../core/osgitools/OsgiBundleProject.java | 15 ++++++ ...aultTargetPlatformConfigurationReader.java | 52 +++++++++++++++---- .../tycho/p2resolver/P2ResolverImpl.java | 43 +-------------- 7 files changed, 74 insertions(+), 58 deletions(-) diff --git a/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetEnvironment.java b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetEnvironment.java index f48f608160..6d762ddc6b 100644 --- a/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetEnvironment.java +++ b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetEnvironment.java @@ -14,6 +14,8 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.Map; import java.util.Objects; import java.util.Properties; @@ -78,8 +80,9 @@ public String toConfigSpec() { * * @return a new instance of {@link HashMap} with the target environment set */ - public HashMap toFilterProperties() { - HashMap result = new HashMap<>(); + public Map toFilterProperties() { + //for nicer debug output, use an ordered map here + Map result = new LinkedHashMap<>(3); if (os != null) result.put(OSGI_OS, os); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProject.java index 4471ecdddd..d2f3b9dd86 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProject.java @@ -22,6 +22,7 @@ import org.eclipse.tycho.IArtifactFacade; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.TargetEnvironment; +import org.osgi.framework.Filter; /** * tycho-specific behavior associated with MavenProject instances. stateless. @@ -54,6 +55,8 @@ public interface TychoProject { */ public TargetEnvironment getImplicitTargetEnvironment(MavenProject project); + public Filter getTargetEnvironmentFilter(MavenProject project); + /** * @return a collection of dependencies (and their transitive dependencies) that where present * before Tycho has injected the target content of the project into the model, also 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 5dd96b0e52..b86d2cdd0d 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 @@ -45,6 +45,7 @@ import org.eclipse.tycho.core.utils.TychoProjectUtils; import org.eclipse.tycho.p2resolver.PomReactorProjectFacade; import org.eclipse.tycho.targetplatform.TargetDefinition; +import org.osgi.framework.Filter; public abstract class AbstractTychoProject extends AbstractLogEnabled implements TychoProject { @@ -115,6 +116,11 @@ public TargetEnvironment getImplicitTargetEnvironment(MavenProject project) { return null; } + @Override + public Filter getTargetEnvironmentFilter(MavenProject project) { + return null; + } + public void readExecutionEnvironmentConfiguration(ReactorProject project, MavenSession mavenSession, ExecutionEnvironmentConfiguration sink) { TargetPlatformConfiguration tpConfiguration = TychoProjectUtils.getTargetPlatformConfiguration(project); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/EquinoxResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/EquinoxResolver.java index a8ebe402a2..59cef3aa87 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/EquinoxResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/EquinoxResolver.java @@ -65,7 +65,6 @@ import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils; import org.eclipse.tycho.core.ee.StandardExecutionEnvironment; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment; -import org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts; import org.eclipse.tycho.core.utils.TychoProjectUtils; import org.osgi.framework.Bundle; import org.osgi.framework.BundleException; @@ -199,14 +198,11 @@ protected Properties getPlatformProperties(ReactorProject project, MavenSession DependencyArtifacts artifacts, ExecutionEnvironment ee) { TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project); + //FIXME formally we should resolve the configuration for ALL declared environments! TargetEnvironment environment = configuration.getEnvironments().get(0); - if (artifacts instanceof MultiEnvironmentDependencyArtifacts multiEnv) { - environment = multiEnv.getPlatforms().stream().findFirst().orElse(environment); - } logger.debug("Using TargetEnvironment " + environment.toFilterExpression() + " to create resolver properties"); Properties properties = new Properties(); properties.putAll(project.getProperties()); - return getPlatformProperties(properties, mavenSession, environment, ee); } 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 f30405ac23..dfc39bcd9b 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 @@ -97,6 +97,8 @@ import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; +import org.osgi.framework.Filter; +import org.osgi.framework.FrameworkUtil; import org.osgi.framework.InvalidSyntaxException; import org.osgi.framework.Version; @@ -741,6 +743,19 @@ public TargetEnvironment getImplicitTargetEnvironment(MavenProject project) { return null; } + @Override + public Filter getTargetEnvironmentFilter(MavenProject project) { + String filterStr = getManifestValue(EclipsePlatformNamespace.ECLIPSE_PLATFORM_FILTER_HEADER, project); + if (filterStr != null) { + try { + return FrameworkUtil.createFilter(filterStr); + } catch (InvalidSyntaxException e) { + // at least we tried... + } + } + return super.getTargetEnvironmentFilter(project); + } + private static String sn(String str) { if (str != null && !str.isBlank()) { return str; 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 03c9d77c15..43c770d055 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 @@ -20,9 +20,12 @@ import java.net.URISyntaxException; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Map; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; import java.util.Objects; import java.util.Properties; +import java.util.stream.Collectors; import org.apache.commons.io.FilenameUtils; import org.apache.maven.execution.MavenSession; @@ -42,12 +45,14 @@ import org.eclipse.tycho.core.TargetPlatformConfiguration; import org.eclipse.tycho.core.TargetPlatformConfiguration.BREEHeaderSelectionPolicy; import org.eclipse.tycho.core.TychoProject; +import org.eclipse.tycho.core.TychoProjectManager; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; import org.eclipse.tycho.core.resolver.shared.PomDependencies; import org.eclipse.tycho.targetplatform.TargetDefinitionFile; import org.eclipse.tycho.targetplatform.TargetPlatformArtifactResolver; import org.eclipse.tycho.targetplatform.TargetResolveException; +import org.osgi.framework.Filter; @Component(role = DefaultTargetPlatformConfigurationReader.class) public class DefaultTargetPlatformConfigurationReader { @@ -71,7 +76,7 @@ public class DefaultTargetPlatformConfigurationReader { private Logger logger; @Requirement - private Map projectTypes; + private TychoProjectManager projectManager; @Requirement private TargetPlatformFilterConfigurationReader filterReader; @@ -82,7 +87,7 @@ public class DefaultTargetPlatformConfigurationReader { public TargetPlatformConfiguration getTargetPlatformConfiguration(MavenSession session, MavenProject project) throws BuildFailureException { TargetPlatformConfiguration result = new TargetPlatformConfiguration(); - + TychoProject tychoProject = projectManager.getTychoProject(project).orElse(null); // Use org.eclipse.tycho:target-platform-configuration/configuration/environment, if provided Plugin plugin = project.getPlugin("org.eclipse.tycho:target-platform-configuration"); @@ -94,7 +99,7 @@ public TargetPlatformConfiguration getTargetPlatformConfiguration(MavenSession s + configuration.toString()); } - addTargetEnvironments(result, project, configuration); + addTargetEnvironments(result, project, configuration, tychoProject); setTargetPlatformResolver(result, configuration); @@ -127,9 +132,8 @@ public TargetPlatformConfiguration getTargetPlatformConfiguration(MavenSession s } if (result.getEnvironments().isEmpty()) { - TychoProject projectType = projectTypes.get(project.getPackaging()); - if (projectType != null) { - TargetEnvironment env = projectType.getImplicitTargetEnvironment(project); + if (tychoProject != null) { + TargetEnvironment env = tychoProject.getImplicitTargetEnvironment(project); if (env != null) { if (logger.isDebugEnabled()) { logger.debug("Implicit target environment for " + project.toString() + ": " + env.toString()); @@ -299,13 +303,27 @@ private void setDisableP2Mirrors(Xpp3Dom configuration) { } } - private void addTargetEnvironments(TargetPlatformConfiguration result, MavenProject project, - Xpp3Dom configuration) { + private void addTargetEnvironments(TargetPlatformConfiguration result, MavenProject project, Xpp3Dom configuration, + TychoProject tychoProject) { try { Xpp3Dom environmentsDom = configuration.getChild(ENVIRONMENTS); if (environmentsDom != null) { + Filter filter = getProjectFiler(tychoProject, project); + List skipped = new ArrayList<>(); for (Xpp3Dom environmentDom : environmentsDom.getChildren("environment")) { - result.addEnvironment(newTargetEnvironment(environmentDom)); + TargetEnvironment environment = newTargetEnvironment(environmentDom); + if (!matchFilter(environment, filter)) { + skipped.add(environment); + } else { + result.addEnvironment(environment); + } + } + if (!skipped.isEmpty()) { + logger.info(MessageFormat.format( + "Declared TargetEnvironment(s) {0} are skipped for {1} as they do not match the project filter {2}.", + skipped.stream().map(TargetEnvironment::toFilterProperties).map(String::valueOf) + .collect(Collectors.joining(", ")), + project.getId(), filter)); } } } catch (TargetPlatformConfigurationException e) { @@ -313,6 +331,20 @@ private void addTargetEnvironments(TargetPlatformConfiguration result, MavenProj } } + private static boolean matchFilter(TargetEnvironment environment, Filter filter) { + if (filter != null) { + return filter.matches(environment.toFilterProperties()); + } + return true; + } + + private static Filter getProjectFiler(TychoProject tychoProject, MavenProject project) { + if (tychoProject != null) { + return tychoProject.getTargetEnvironmentFilter(project); + } + return null; + } + private void setPomDependencies(TargetPlatformConfiguration result, Xpp3Dom configuration) { String value = getStringValue(configuration.getChild(POM_DEPENDENCIES)); if (value == null) { diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverImpl.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverImpl.java index 8857316e07..4eaf43b533 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverImpl.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverImpl.java @@ -18,9 +18,7 @@ package org.eclipse.tycho.p2resolver; import java.io.File; -import java.text.MessageFormat; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.HashMap; @@ -35,7 +33,6 @@ import java.util.function.Consumer; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.equinox.internal.p2.metadata.InstallableUnit; import org.eclipse.equinox.p2.metadata.IArtifactKey; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.metadata.IProvidedCapability; @@ -43,7 +40,6 @@ import org.eclipse.equinox.p2.metadata.MetadataFactory; import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.p2.metadata.VersionRange; -import org.eclipse.equinox.p2.metadata.expression.IMatchExpression; import org.eclipse.equinox.p2.publisher.eclipse.BundlesAction; import org.eclipse.equinox.p2.query.IQuery; import org.eclipse.equinox.p2.query.IQueryResult; @@ -118,18 +114,9 @@ public Map resolveTargetDependencies(Targ // we need a linked hashmap to maintain iteration-order, some of the code relies on it! Map results = new LinkedHashMap<>(); Set usedTargetPlatformUnits = new LinkedHashSet<>(); - Set metadata = project != null ? project.getDependencyMetadata(DependencyMetadataType.SEED) - : Collections.emptySet(); for (TargetEnvironment environment : environments) { - if (isMatchingEnv(metadata, environment, logger::debug)) { - results.put(environment, resolveDependencies(Collections.emptySet(), project, - new ProjectorResolutionStrategy(logger), environment, targetPlatform, usedTargetPlatformUnits)); - } else { - logger.info(MessageFormat.format( - "Project {0}:{1}:{2} does not match environment {3} skip dependency resolution", - project.getGroupId(), project.getArtifactId(), project.getVersion(), - environment.toFilterExpression())); - } + results.put(environment, resolveDependencies(Collections.emptySet(), project, + new ProjectorResolutionStrategy(logger), environment, targetPlatform, usedTargetPlatformUnits)); } targetPlatform.reportUsedLocalIUs(usedTargetPlatformUnits); @@ -460,32 +447,6 @@ private static void addArtifactFile(DefaultP2ResolutionResult result, IInstallab // throw new IllegalArgumentException(); } - /** - * Check if the Metadata contains any constraints that forbid the given - * {@link TargetEnvironment} - * - * @param metadata - * @param environment - * @return - */ - private static boolean isMatchingEnv(Set metadata, TargetEnvironment environment, - Consumer debugConsumer) { - if (metadata != null) { - for (IInstallableUnit meta : metadata) { - IMatchExpression filter = meta.getFilter(); - if (filter != null) { - boolean match = filter.isMatch(InstallableUnit.contextIU(environment.toFilterProperties())); - debugConsumer.accept(MessageFormat.format("{0}: {1} (matches {2})", filter, - Arrays.toString(filter.getParameters()), match)); - if (!match) { - return false; - } - } - } - } - return true; - } - public static void addDependenciesForTests(Consumer requirementsConsumer) { /* * In case the test harness bundles (cf. TestMojo.getTestDependencies()) are part of the From 2dfdc5e5957ca859c32248ee40acd0be8ab23a40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 23 Dec 2022 09:49:24 +0100 Subject: [PATCH 03/19] Do not use a default implicit target env configuration --- .../org/eclipse/tycho/TargetEnvironment.java | 23 ++++++++++++------- .../core/osgitools/OsgiBundleProject.java | 4 ++-- ...aultTargetPlatformConfigurationReader.java | 14 +---------- .../tycho/core/resolver/P2Resolver.java | 3 --- .../core/resolver/P2ResolverFactory.java | 13 +++++++++-- .../p2resolver/P2DependencyResolver.java | 6 +---- .../p2resolver/P2ResolverFactoryImpl.java | 6 +++-- .../tycho/p2resolver/P2ResolverImpl.java | 14 ++++------- .../P2ResolverAdditionalRequirementsTest.java | 5 +++- .../tycho/p2resolver/P2ResolverTest.java | 18 ++++++++++----- .../tycho/p2resolver/P2ResolverTestBase.java | 2 -- .../tycho/test/util/TestResolverFactory.java | 5 ++-- .../extras/tpvalidator/TPValidationMojo.java | 9 ++++---- .../extras/eclipserun/EclipseRunMojo.java | 7 ++++-- .../p2/extras/CompareWithBaselineMojo.java | 7 +++--- .../tycho/versionbump/AbstractUpdateMojo.java | 11 +++++++-- .../tycho/versionbump/UpdateProductMojo.java | 4 ---- .../tycho/versionbump/UpdateTargetMojo.java | 9 ++++---- .../tycho/source/SourceFeatureMojo.java | 8 +++---- 19 files changed, 88 insertions(+), 80 deletions(-) diff --git a/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetEnvironment.java b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetEnvironment.java index 6d762ddc6b..c2d96e20e6 100644 --- a/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetEnvironment.java +++ b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetEnvironment.java @@ -20,6 +20,7 @@ import java.util.Properties; public final class TargetEnvironment { + private static final Properties EMPTY_PROPERTIES = new Properties(); private static final String OSGI_OS = "osgi.os"; private static final String OSGI_WS = "osgi.ws"; private static final String OSGI_ARCH = "osgi.arch"; @@ -145,14 +146,20 @@ public boolean equals(Object obj) { } public static TargetEnvironment getRunningEnvironment() { - Properties properties = new Properties(); - properties.put(PlatformPropertiesUtils.OSGI_OS, PlatformPropertiesUtils.getOS(properties)); - properties.put(PlatformPropertiesUtils.OSGI_WS, PlatformPropertiesUtils.getWS(properties)); - properties.put(PlatformPropertiesUtils.OSGI_ARCH, PlatformPropertiesUtils.getArch(properties)); - - return new TargetEnvironment(properties.getProperty(PlatformPropertiesUtils.OSGI_OS), - properties.getProperty(PlatformPropertiesUtils.OSGI_WS), - properties.getProperty(PlatformPropertiesUtils.OSGI_ARCH)); + return getRunningEnvironment(null); + } + + public static TargetEnvironment getRunningEnvironment(ReactorProject project) { + Properties properties; + if (project == null) { + properties = EMPTY_PROPERTIES; + } else { + properties = Objects.requireNonNullElse(project.getProperties(), EMPTY_PROPERTIES); + } + String os = PlatformPropertiesUtils.getOS(properties); + String ws = PlatformPropertiesUtils.getWS(properties); + String arch = PlatformPropertiesUtils.getArch(properties); + return new TargetEnvironment(os, ws, arch); } } 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 dfc39bcd9b..898eb581d4 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 @@ -94,7 +94,6 @@ import org.eclipse.tycho.model.Feature; import org.eclipse.tycho.model.ProductConfiguration; import org.eclipse.tycho.model.UpdateSite; -import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter; import org.osgi.framework.BundleException; import org.osgi.framework.Constants; import org.osgi.framework.Filter; @@ -368,7 +367,8 @@ private Collection computeExtraTestClasspath(ReactorProject reac for (ProjectClasspathEntry cpe : entries) { if (cpe instanceof JUnitClasspathContainerEntry junit) { logger.info("Resolve JUnit " + junit.getJUnitSegment() + " classpath container..."); - P2Resolver resolver = resolverFactory.createResolver(new MavenLoggerAdapter(logger, false)); + P2Resolver resolver = resolverFactory.createResolver( + Collections.singletonList(TargetEnvironment.getRunningEnvironment(reactorProject))); TargetPlatform tp = TychoProjectUtils.getTargetPlatform(reactorProject); Collection result = resolver.resolveArtifactDependencies(tp, junit.getArtifacts()) .values(); 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 43c770d055..49425ceafd 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 @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Objects; -import java.util.Properties; import java.util.stream.Collectors; import org.apache.commons.io.FilenameUtils; @@ -39,7 +38,6 @@ import org.eclipse.tycho.BuildFailureException; import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.OptionalResolutionAction; -import org.eclipse.tycho.PlatformPropertiesUtils; import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.artifacts.configuration.TargetPlatformFilterConfigurationReader; import org.eclipse.tycho.core.TargetPlatformConfiguration; @@ -147,17 +145,7 @@ public TargetPlatformConfiguration getTargetPlatformConfiguration(MavenSession s if (result.getEnvironments().isEmpty()) { // applying defaults logger.warn("No explicit target runtime environment configuration. Build is platform dependent."); - - // Otherwise, use project or execution properties, if provided - Properties properties = DefaultReactorProject.adapt(project).getProperties(); - - // Otherwise, use current system os/ws/nl/arch - String os = PlatformPropertiesUtils.getOS(properties); - String ws = PlatformPropertiesUtils.getWS(properties); - String arch = PlatformPropertiesUtils.getArch(properties); - - result.addEnvironment(new TargetEnvironment(os, ws, arch)); - + result.addEnvironment(TargetEnvironment.getRunningEnvironment(DefaultReactorProject.adapt(project))); result.setImplicitTargetEnvironment(true); } else { result.setImplicitTargetEnvironment(false); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/P2Resolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/P2Resolver.java index f916794be4..63e3a2c287 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/P2Resolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/P2Resolver.java @@ -16,7 +16,6 @@ package org.eclipse.tycho.core.resolver; import java.util.Collection; -import java.util.List; import java.util.Map; import org.eclipse.tycho.ArtifactKey; @@ -30,8 +29,6 @@ public interface P2Resolver { - public void setEnvironments(List environments); - /** * Sets additional properties that will be used to evaluate filter expressions in the p2 * metadata. These properties are also known as "profile properties" in p2. diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/P2ResolverFactory.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/P2ResolverFactory.java index 83802a86f1..5043476319 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/P2ResolverFactory.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/P2ResolverFactory.java @@ -14,10 +14,12 @@ *******************************************************************************/ package org.eclipse.tycho.core.resolver; +import java.util.Collection; + import org.eclipse.tycho.ArtifactDescriptor; import org.eclipse.tycho.MavenDependencyDescriptor; import org.eclipse.tycho.ReactorProject; -import org.eclipse.tycho.core.shared.MavenLogger; +import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.p2.target.facade.PomDependencyCollector; import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory; @@ -32,7 +34,14 @@ public interface P2ResolverFactory { // TODO directly register as service public TargetPlatformFactory getTargetPlatformFactory(); - public P2Resolver createResolver(MavenLogger logger); + /** + * Create a resolver for the given environments + * + * @param environments + * + * @return a resolver that is capable of resolving the provided environments + */ + public P2Resolver createResolver(Collection environments); /** * tries to resolve a {@link MavenDependencyDescriptor} from the given 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 1d0753fc03..e58c975fcd 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 @@ -71,7 +71,6 @@ import org.eclipse.tycho.core.maven.MavenDependencyInjector; import org.eclipse.tycho.core.osgitools.AbstractTychoProject; import org.eclipse.tycho.core.osgitools.BundleReader; -import org.eclipse.tycho.core.osgitools.DebugUtils; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts; import org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts; @@ -80,7 +79,6 @@ 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.osgi.adapters.MavenLoggerAdapter; import org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator; import org.eclipse.tycho.p2.metadata.PublisherOptions; import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices; @@ -309,8 +307,7 @@ public DependencyArtifacts resolveDependencies(final MavenSession session, final // --> split this information logically, e.g. through two distinct interfaces TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(reactorProject); - P2Resolver osgiResolverImpl = resolverFactory - .createResolver(new MavenLoggerAdapter(getLogger(), DebugUtils.isDebugEnabled(session, project))); + P2Resolver osgiResolverImpl = resolverFactory.createResolver(configuration.getEnvironments()); return doResolveDependencies(session, project, reactorProjects, resolverConfiguration, targetPlatform, osgiResolverImpl, configuration); @@ -322,7 +319,6 @@ private DependencyArtifacts doResolveDependencies(MavenSession session, MavenPro Map projects = new HashMap<>(); - resolver.setEnvironments(configuration.getEnvironments()); resolver.setAdditionalFilterProperties(configuration.getProfileProperties()); resolver.setPomDependencies(configuration.getPomDependencies()); 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 8bcb2b7bdb..2e190c2258 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 @@ -45,8 +45,10 @@ import org.eclipse.tycho.IRepositoryIdManager; import org.eclipse.tycho.MavenDependencyDescriptor; import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.TychoConstants; import org.eclipse.tycho.core.TychoProjectManager; +import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.core.shared.MavenLogger; @@ -133,8 +135,8 @@ public TargetPlatformFactoryImpl getTargetPlatformFactory() { } @Override - public P2ResolverImpl createResolver(MavenLogger logger) { - return new P2ResolverImpl(getTargetPlatformFactory(), this, logger); + public P2Resolver createResolver(Collection environments) { + return new P2ResolverImpl(getTargetPlatformFactory(), this, mavenContext.getLogger(), environments); } public Set calculateDependencyFragments(ResolutionData data, diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverImpl.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverImpl.java index 4eaf43b533..b5e945b7d6 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverImpl.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2ResolverImpl.java @@ -80,7 +80,7 @@ public class P2ResolverImpl implements P2Resolver { private final IProgressMonitor monitor; - private List environments; + private final List environments; private Map additionalFilterProperties = new HashMap<>(); private final List additionalRequirements = new ArrayList<>(); @@ -92,12 +92,12 @@ public class P2ResolverImpl implements P2Resolver { private P2ResolverFactoryImpl p2ResolverFactoryImpl; public P2ResolverImpl(TargetPlatformFactoryImpl targetPlatformFactory, P2ResolverFactoryImpl p2ResolverFactoryImpl, - MavenLogger logger) { + MavenLogger logger, Collection environments) { this.targetPlatformFactory = targetPlatformFactory; this.p2ResolverFactoryImpl = p2ResolverFactoryImpl; this.logger = logger; this.monitor = new LoggingProgressMonitor(logger); - this.environments = Collections.singletonList(TargetEnvironment.getRunningEnvironment()); + this.environments = List.copyOf(environments); } @Override @@ -275,15 +275,9 @@ private static void addUnit(DefaultP2ResolutionResult result, IInstallableUnit i } } - @Override - public void setEnvironments(List environments) { - Objects.requireNonNull(environments, "environments can't be null"); - this.environments = environments; - } - @Override public void setAdditionalFilterProperties(Map additionalFilterProperties) { - Objects.requireNonNull(environments, "additionalFilterProperties can't be null"); + Objects.requireNonNull(additionalFilterProperties, "additionalFilterProperties can't be null"); this.additionalFilterProperties = additionalFilterProperties; } diff --git a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverAdditionalRequirementsTest.java b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverAdditionalRequirementsTest.java index e43e75041d..c2da4a7637 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverAdditionalRequirementsTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverAdditionalRequirementsTest.java @@ -13,6 +13,7 @@ package org.eclipse.tycho.p2resolver; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import org.eclipse.equinox.p2.metadata.IInstallableUnit; @@ -22,6 +23,7 @@ import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.tycho.ArtifactType; +import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.test.util.LogVerifier; import org.junit.Assert; import org.junit.Before; @@ -43,7 +45,8 @@ public class P2ResolverAdditionalRequirementsTest { @Before public void initBlankResolver() { - impl = new P2ResolverImpl(null, null, logVerifier.getMavenLogger()); + impl = new P2ResolverImpl(null, null, logVerifier.getMavenLogger(), + Collections.singletonList(TargetEnvironment.getRunningEnvironment())); } @Test diff --git a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverTest.java b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverTest.java index 0f26a5181d..f2af9c9a1c 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverTest.java @@ -49,6 +49,7 @@ import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentStub; import org.eclipse.tycho.core.resolver.P2ResolutionResult; import org.eclipse.tycho.core.resolver.P2ResolutionResult.Entry; +import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.target.DuplicateReactorIUsException; import org.eclipse.tycho.core.resolver.target.P2TargetPlatform; import org.eclipse.tycho.p2.metadata.PublisherOptions; @@ -72,13 +73,18 @@ public class P2ResolverTest extends P2ResolverTestBase { private ReactorProject projectToResolve; private P2ResolutionResult result; private static final String LATEST_PLATFORM = "https://download.eclipse.org/eclipse/updates/latest/"; + protected P2Resolver impl; @Before public void initDefaultResolver() throws Exception { // org.eclipse.equinox.internal.p2.core.helpers.Tracing.DEBUG_PLANNER_PROJECTOR = true; pomDependencies = resolverFactory.newPomDependencyCollector(); - impl = new P2ResolverImpl(tpFactory, null, logVerifier.getMavenLogger()); - impl.setEnvironments(getEnvironments()); + List environments = getEnvironments(); + impl = createFor(environments); + } + + private P2ResolverImpl createFor(List environments) { + return new P2ResolverImpl(tpFactory, null, logVerifier.getMavenLogger(), environments); } @Test @@ -390,14 +396,14 @@ public void testFeatureMultienvP2Inf() throws Exception { List environments = new ArrayList<>(); environments.add(new TargetEnvironment("linux", "gtk", "x86_64")); environments.add(new TargetEnvironment("macosx", "cocoa", "x86_64")); - impl.setEnvironments(environments); + P2Resolver resolver = createFor(environments); String artifactId = "feature.multienv.p2-inf"; projectToResolve = createReactorProject(resourceFile("resolver/feature.multienv.p2-inf"), TYPE_ECLIPSE_FEATURE, artifactId); List results = new ArrayList<>( - impl.resolveTargetDependencies(getTargetPlatform(), projectToResolve).values()); + resolver.resolveTargetDependencies(getTargetPlatform(), projectToResolve).values()); assertEquals(2, results.size()); @@ -419,14 +425,14 @@ public void testProductMultienvP2Inf() throws Exception { List environments = new ArrayList<>(); environments.add(new TargetEnvironment("linux", "gtk", "x86_64")); environments.add(new TargetEnvironment("macosx", "cocoa", "x86_64")); - impl.setEnvironments(environments); + P2Resolver resolver = createFor(environments); String artifactId = "product.multienv.p2-inf"; projectToResolve = createReactorProject(resourceFile("resolver/product.multienv.p2-inf"), TYPE_ECLIPSE_REPOSITORY, artifactId); List results = new ArrayList<>( - impl.resolveTargetDependencies(getTargetPlatform(), projectToResolve).values()); + resolver.resolveTargetDependencies(getTargetPlatform(), projectToResolve).values()); assertEquals(2, results.size()); diff --git a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverTestBase.java b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverTestBase.java index 26f44d0297..dc08d60c49 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverTestBase.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/P2ResolverTestBase.java @@ -22,7 +22,6 @@ import org.eclipse.tycho.OptionalResolutionAction; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.TargetEnvironment; -import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.p2.metadata.PublisherOptions; import org.eclipse.tycho.p2.publisher.DependencyMetadata; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; @@ -48,7 +47,6 @@ public class P2ResolverTestBase extends TychoPlexusTestCase { private DefaultDependencyMetadataGenerator dependencyGenerator; protected TestResolverFactory resolverFactory; - protected P2Resolver impl; protected TargetPlatformConfigurationStub tpConfig; protected PomDependencyCollectorImpl pomDependencies; protected List reactorProjects = new ArrayList<>(); 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 865066f91b..949445cd2c 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 @@ -28,6 +28,7 @@ import org.eclipse.tycho.MavenArtifactRepositoryReference; import org.eclipse.tycho.MavenDependencyDescriptor; import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; import org.eclipse.tycho.core.shared.DependencyResolutionException; @@ -148,8 +149,8 @@ public TargetPlatformFactoryImpl getTargetPlatformFactoryImpl() { } @Override - public P2Resolver createResolver(MavenLogger logger) { - return new P2ResolverImpl(getTargetPlatformFactoryImpl(), null, mavenContext.getLogger()); + public P2Resolver createResolver(Collection environments) { + return new P2ResolverImpl(getTargetPlatformFactoryImpl(), null, mavenContext.getLogger(), environments); } @Override diff --git a/tycho-extras/target-platform-validation-plugin/src/main/java/org/eclipse/tycho/extras/tpvalidator/TPValidationMojo.java b/tycho-extras/target-platform-validation-plugin/src/main/java/org/eclipse/tycho/extras/tpvalidator/TPValidationMojo.java index f362ef8381..12b7052756 100644 --- a/tycho-extras/target-platform-validation-plugin/src/main/java/org/eclipse/tycho/extras/tpvalidator/TPValidationMojo.java +++ b/tycho-extras/target-platform-validation-plugin/src/main/java/org/eclipse/tycho/extras/tpvalidator/TPValidationMojo.java @@ -39,18 +39,18 @@ import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration; import org.eclipse.tycho.core.ee.shared.SystemCapability; +import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader; import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; -import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; import org.eclipse.tycho.p2.tools.RepositoryReferences; import org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime; -import org.eclipse.tycho.targetplatform.TargetDefinitionFile; import org.eclipse.tycho.targetplatform.TargetDefinition.InstallableUnitLocation; import org.eclipse.tycho.targetplatform.TargetDefinition.Location; import org.eclipse.tycho.targetplatform.TargetDefinition.Repository; import org.eclipse.tycho.targetplatform.TargetDefinition.Unit; +import org.eclipse.tycho.targetplatform.TargetDefinitionFile; /** * Validates that specified target platforms (.target files) contents can be resolved. @@ -188,9 +188,10 @@ private void validateTarget(File targetFile) throws TPError { TargetDefinitionFile targetDefinition = TargetDefinitionFile.read(targetFile); TargetPlatformConfigurationStub tpConfiguration = new TargetPlatformConfigurationStub(); tpConfiguration.addTargetDefinition(targetDefinition); - tpConfiguration.setEnvironments(Collections.singletonList(TargetEnvironment.getRunningEnvironment())); + tpConfiguration.setEnvironments(Collections + .singletonList(TargetEnvironment.getRunningEnvironment(DefaultReactorProject.adapt(project)))); - P2Resolver resolver = this.factory.createResolver(new MavenLoggerAdapter(this.logger, false)); + P2Resolver resolver = this.factory.createResolver(tpConfiguration.getEnvironments()); for (Location location : targetDefinition.getLocations()) { if (location instanceof InstallableUnitLocation p2Loc) { diff --git a/tycho-extras/tycho-eclipserun-plugin/src/main/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojo.java b/tycho-extras/tycho-eclipserun-plugin/src/main/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojo.java index 43487be800..17128dd7da 100644 --- a/tycho-extras/tycho-eclipserun-plugin/src/main/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojo.java +++ b/tycho-extras/tycho-eclipserun-plugin/src/main/java/org/eclipse/tycho/extras/eclipserun/EclipseRunMojo.java @@ -15,6 +15,7 @@ import java.io.File; import java.util.ArrayList; +import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Objects; @@ -46,15 +47,16 @@ import org.eclipse.tycho.ArtifactType; import org.eclipse.tycho.IllegalArtifactReferenceException; import org.eclipse.tycho.MavenRepositoryLocation; +import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.TargetPlatform; import org.eclipse.tycho.core.ee.ExecutionEnvironmentConfigurationImpl; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentConfiguration; import org.eclipse.tycho.core.maven.ToolchainProvider; +import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.resolver.P2ResolutionResult; import org.eclipse.tycho.core.resolver.P2ResolutionResult.Entry; import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; -import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; import org.eclipse.tycho.plugins.p2.extras.Repository; @@ -342,7 +344,8 @@ private EquinoxInstallation createEclipseInstallation() throws MojoFailureExcept eeConfiguration.setProfileConfiguration(executionEnvironment, "tycho-eclipserun-plugin "); TargetPlatform targetPlatform = resolverFactory.getTargetPlatformFactory().createTargetPlatform(tpConfiguration, eeConfiguration, null); - P2Resolver resolver = resolverFactory.createResolver(new MavenLoggerAdapter(logger, false)); + P2Resolver resolver = resolverFactory.createResolver(Collections + .singletonList(TargetEnvironment.getRunningEnvironment(DefaultReactorProject.adapt(project)))); for (Dependency dependency : dependencies) { try { resolver.addDependency(dependency.getType(), dependency.getArtifactId(), dependency.getVersion()); 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 7e6e91c270..db634a276e 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 @@ -43,7 +43,6 @@ import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; import org.eclipse.tycho.core.utils.TychoProjectUtils; -import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; import org.osgi.framework.Version; @@ -136,11 +135,13 @@ public void execute() throws MojoExecutionException, MojoFailureException { + this.artifactComparators.keySet()); } - P2Resolver resolver = resolverFactory.createResolver(new MavenLoggerAdapter(this.plexusLogger, true)); + P2Resolver resolver = resolverFactory.createResolver(Collections + .singletonList(TargetEnvironment.getRunningEnvironment(DefaultReactorProject.adapt(project)))); TargetPlatformConfigurationStub baselineTPStub = new TargetPlatformConfigurationStub(); baselineTPStub.setForceIgnoreLocalArtifacts(true); - baselineTPStub.setEnvironments(Collections.singletonList(TargetEnvironment.getRunningEnvironment())); + baselineTPStub.setEnvironments(Collections + .singletonList(TargetEnvironment.getRunningEnvironment(DefaultReactorProject.adapt(project)))); for (String baselineRepo : this.baselines) { baselineTPStub.addP2Repository(toRepoURI(baselineRepo)); } diff --git a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/AbstractUpdateMojo.java b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/AbstractUpdateMojo.java index 75e4c1d402..bb40d223aa 100644 --- a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/AbstractUpdateMojo.java +++ b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/AbstractUpdateMojo.java @@ -14,16 +14,19 @@ package org.eclipse.tycho.versionbump; import java.io.File; +import java.util.Collections; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.Component; import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; import org.codehaus.plexus.logging.Logger; +import org.eclipse.tycho.TargetEnvironment; +import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; -import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; public abstract class AbstractUpdateMojo extends AbstractMojo { @@ -38,6 +41,9 @@ public abstract class AbstractUpdateMojo extends AbstractMojo { protected TargetPlatformConfigurationStub resolutionContext; + @Parameter(property = "project") + protected MavenProject project; + @Component P2ResolverFactory factory; @@ -55,7 +61,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { protected abstract void doUpdate() throws Exception; private void createResolver() { - p2 = factory.createResolver(new MavenLoggerAdapter(logger, false)); + p2 = factory.createResolver(Collections + .singletonList(TargetEnvironment.getRunningEnvironment(DefaultReactorProject.adapt(project)))); resolutionContext = new TargetPlatformConfigurationStub(); } diff --git a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateProductMojo.java b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateProductMojo.java index 5c168613b1..16a17c4202 100644 --- a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateProductMojo.java +++ b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateProductMojo.java @@ -24,7 +24,6 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; import org.eclipse.tycho.ArtifactType; import org.eclipse.tycho.IllegalArtifactReferenceException; import org.eclipse.tycho.MavenRepositoryLocation; @@ -44,9 +43,6 @@ public class UpdateProductMojo extends AbstractUpdateMojo { @Parameter(defaultValue = "${project.artifactId}.product") private File productFile; - @Parameter(property = "project") - private MavenProject project; - @Override protected void doUpdate() throws IOException, URISyntaxException { diff --git a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateTargetMojo.java b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateTargetMojo.java index 5b9624b64f..306536162d 100644 --- a/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateTargetMojo.java +++ b/tycho-extras/tycho-version-bump-plugin/src/main/java/org/eclipse/tycho/versionbump/UpdateTargetMojo.java @@ -27,15 +27,15 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; import org.eclipse.tycho.TargetEnvironment; +import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.resolver.P2ResolutionResult; import org.eclipse.tycho.targetplatform.TargetDefinition; -import org.eclipse.tycho.targetplatform.TargetDefinitionFile; import org.eclipse.tycho.targetplatform.TargetDefinition.IncludeMode; import org.eclipse.tycho.targetplatform.TargetDefinition.InstallableUnitLocation; import org.eclipse.tycho.targetplatform.TargetDefinition.Repository; import org.eclipse.tycho.targetplatform.TargetDefinition.Unit; +import org.eclipse.tycho.targetplatform.TargetDefinitionFile; import org.w3c.dom.Document; import org.w3c.dom.Element; import org.w3c.dom.NodeList; @@ -47,8 +47,6 @@ */ @Mojo(name = "update-target") public class UpdateTargetMojo extends AbstractUpdateMojo { - @Parameter(property = "project") - private MavenProject project; @Parameter(property = "target") private File targetFile; @@ -59,7 +57,8 @@ protected void doUpdate() throws IOException, URISyntaxException, ParserConfigur try (FileInputStream input = new FileInputStream(targetFile)) { target = TargetDefinitionFile.parseDocument(input); TargetDefinitionFile parsedTarget = TargetDefinitionFile.parse(target, targetFile.getAbsolutePath()); - resolutionContext.setEnvironments(Collections.singletonList(TargetEnvironment.getRunningEnvironment())); + resolutionContext.setEnvironments(Collections + .singletonList(TargetEnvironment.getRunningEnvironment(DefaultReactorProject.adapt(project)))); resolutionContext.addTargetDefinition(new LatestVersionTarget(parsedTarget)); P2ResolutionResult result = p2.getTargetPlatformAsResolutionResult(resolutionContext, executionEnvironment); diff --git a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureMojo.java b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureMojo.java index 269c88c00c..993edf4c13 100644 --- a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureMojo.java +++ b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureMojo.java @@ -20,6 +20,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashSet; import java.util.LinkedHashSet; import java.util.List; @@ -51,8 +52,8 @@ import org.eclipse.tycho.BuildProperties; import org.eclipse.tycho.BuildPropertiesParser; import org.eclipse.tycho.PackagingType; +import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.TargetPlatform; -import org.eclipse.tycho.core.osgitools.DebugUtils; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.resolver.P2ResolutionResult; import org.eclipse.tycho.core.resolver.P2ResolutionResult.Entry; @@ -62,7 +63,6 @@ import org.eclipse.tycho.model.Feature; import org.eclipse.tycho.model.FeatureRef; import org.eclipse.tycho.model.PluginRef; -import org.eclipse.tycho.osgi.adapters.MavenLoggerAdapter; import org.eclipse.tycho.packaging.LicenseFeatureHelper; import de.pdark.decentxml.Document; @@ -455,8 +455,8 @@ private static String validateValue(String fieldValue, Properties sourceFeatureP */ private void fillReferences(Feature sourceFeature, Feature feature, TargetPlatform targetPlatform) throws MojoExecutionException { - P2Resolver p2 = factory.createResolver( - new MavenLoggerAdapter(this.logger, DebugUtils.isDebugEnabled(this.session, this.project))); + P2Resolver p2 = factory.createResolver(Collections + .singletonList(TargetEnvironment.getRunningEnvironment(DefaultReactorProject.adapt(project)))); List missingSourcePlugins = new ArrayList<>(); List missingSourceFeatures = new ArrayList<>(); From c43553a6c3b91246736c308fd79ddbf29da12666 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Fri, 23 Dec 2022 20:58:22 +0100 Subject: [PATCH 04/19] Choose a matching build environment to resolve test dependencies Currently Tycho resolves test dependencies for the execution with all configured environments. This is actually not what one wants, because the test will be executed in the context of the current build environment (at least in terms of os/ws/arch) and one can't change this. This changes the behavior in a way where Tycho is searching for a compatible target environment and only uses that if it matches the build environment. Just in the case nothing matches the old behavior (using all environments) is used and a warning is printed. --- .../tycho/core/DependencyResolver.java | 3 +- .../LocalDependencyResolver.java | 3 +- .../core/resolver/DefaultTychoResolver.java | 4 +- .../p2resolver/P2DependencyResolver.java | 4 +- .../p2tools/RepositoryReferenceTool.java | 2 +- .../test/ArtifactDependencyWalkerTest.java | 113 ------------------ .../test/LocalDependencyResolverTest.java | 95 --------------- .../tycho/surefire/AbstractTestMojo.java | 33 ++++- 8 files changed, 39 insertions(+), 218 deletions(-) delete mode 100644 tycho-core/src/test/java/org/eclipse/tycho/core/test/ArtifactDependencyWalkerTest.java delete mode 100644 tycho-core/src/test/java/org/eclipse/tycho/core/test/LocalDependencyResolverTest.java 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 63777c50a7..544c5a0c5c 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 @@ -20,6 +20,7 @@ import org.codehaus.plexus.logging.Logger; import org.eclipse.tycho.DependencyArtifacts; import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.TargetPlatform; import org.eclipse.tycho.core.osgitools.AbstractTychoProject; import org.eclipse.tycho.p2.target.facade.PomDependencyCollector; @@ -43,7 +44,7 @@ public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, Mav */ public DependencyArtifacts resolveDependencies(MavenSession session, MavenProject project, TargetPlatform targetPlatform, List reactorProjects, - DependencyResolverConfiguration resolverConfiguration); + DependencyResolverConfiguration resolverConfiguration, List environments); public void injectDependenciesIntoMavenModel(MavenProject project, AbstractTychoProject projectType, DependencyArtifacts resolvedDependencies, DependencyArtifacts testDepedencyArtifacts, Logger logger); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/targetplatform/LocalDependencyResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/targetplatform/LocalDependencyResolver.java index fcf02e6432..7dd06bbbdf 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/targetplatform/LocalDependencyResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/targetplatform/LocalDependencyResolver.java @@ -41,6 +41,7 @@ import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.DependencyArtifacts; import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.TargetPlatform; import org.eclipse.tycho.TychoConstants; import org.eclipse.tycho.core.ArtifactDependencyVisitor; @@ -122,7 +123,7 @@ public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, Mav @Override public DependencyArtifacts resolveDependencies(MavenSession session, MavenProject project, TargetPlatform resolutionContext, List reactorProjects, - DependencyResolverConfiguration resolverConfiguration) { + DependencyResolverConfiguration resolverConfiguration, List ignored) { ReactorProject reactorProject = DefaultReactorProject.adapt(project); Properties properties = reactorProject.getProperties(); if (properties != null) { diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoResolver.java index a1aeb39a78..b07768bd45 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTychoResolver.java @@ -140,7 +140,7 @@ public void resolveProject(MavenSession session, MavenProject project, List getExtraRequirements() { } }; testDependencyArtifacts = resolver.resolveDependencies(session, project, preliminaryTargetPlatform, - reactorProjects, testResolverConfiguration); + reactorProjects, testResolverConfiguration, configuration.getEnvironments()); } dr.setTestDependencyArtifacts(session, reactorProject, Objects.requireNonNullElse(testDependencyArtifacts, new DefaultDependencyArtifacts())); 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 e58c975fcd..fdf7bfe9d5 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 @@ -297,7 +297,7 @@ private void addEntireP2RepositoryToTargetPlatform(ArtifactRepository repository @Override public DependencyArtifacts resolveDependencies(final MavenSession session, final MavenProject project, TargetPlatform targetPlatform, List reactorProjects, - DependencyResolverConfiguration resolverConfiguration) { + DependencyResolverConfiguration resolverConfiguration, List environments) { ReactorProject reactorProject = DefaultReactorProject.adapt(project); if (targetPlatform == null) { targetPlatform = TychoProjectUtils.getTargetPlatform(reactorProject); @@ -307,7 +307,7 @@ public DependencyArtifacts resolveDependencies(final MavenSession session, final // --> split this information logically, e.g. through two distinct interfaces TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(reactorProject); - P2Resolver osgiResolverImpl = resolverFactory.createResolver(configuration.getEnvironments()); + P2Resolver osgiResolverImpl = resolverFactory.createResolver(environments); return doResolveDependencies(session, project, reactorProjects, resolverConfiguration, targetPlatform, osgiResolverImpl, configuration); 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 0e7cb088cd..1b9fd2c11b 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 @@ -123,7 +123,7 @@ private void addTargetPlatformRepository(RepositoryReferences sources, MavenSess .getDependencyResolverConfiguration(); DependencyArtifacts dependencyArtifacts = resolver.resolveDependencies(session, project, targetPlatform, - DefaultReactorProject.adapt(session), resolverConfiguration); + DefaultReactorProject.adapt(session), 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-core/src/test/java/org/eclipse/tycho/core/test/ArtifactDependencyWalkerTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/test/ArtifactDependencyWalkerTest.java deleted file mode 100644 index ce0b1e9d53..0000000000 --- a/tycho-core/src/test/java/org/eclipse/tycho/core/test/ArtifactDependencyWalkerTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2012 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 - *******************************************************************************/ -package org.eclipse.tycho.core.test; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; - -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.DefaultMavenExecutionResult; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionResult; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.tycho.DependencyArtifacts; -import org.eclipse.tycho.core.ArtifactDependencyVisitor; -import org.eclipse.tycho.core.ArtifactDependencyWalker; -import org.eclipse.tycho.core.DependencyResolver; -import org.eclipse.tycho.core.FeatureDescription; -import org.eclipse.tycho.core.PluginDescription; -import org.eclipse.tycho.core.osgitools.AbstractArtifactDependencyWalker; -import org.eclipse.tycho.core.osgitools.DefaultReactorProject; -import org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver; -import org.eclipse.tycho.model.ProductConfiguration; -import org.eclipse.tycho.testing.AbstractTychoMojoTestCase; - -public class ArtifactDependencyWalkerTest extends AbstractTychoMojoTestCase { - public void testProductDepdendencies() throws Exception { - final ArrayList plugins = new ArrayList<>(); - final ArrayList features = new ArrayList<>(); - walkProduct("src/test/resources/dependencywalker/plugin_based.product", plugins, features); - - assertEquals(0, features.size()); - - assertEquals(1, plugins.size()); - assertEquals("bundle01", plugins.get(0).getKey().getId()); - assertEquals("0.0.1", plugins.get(0).getKey().getVersion()); - - plugins.clear(); - features.clear(); - - walkProduct("src/test/resources/dependencywalker/feature_based.product", plugins, features); - assertEquals(1, features.size()); - assertEquals("feature01", features.get(0).getKey().getId()); - assertEquals("1.0.0", features.get(0).getKey().getVersion()); - - assertEquals(1, plugins.size()); - assertEquals("bundle01", plugins.get(0).getKey().getId()); - assertEquals("0.0.1", plugins.get(0).getKey().getVersion()); - } - - protected void walkProduct(String productFile, final ArrayList plugins, - final ArrayList features) throws Exception, IOException, XmlPullParserException { - DependencyArtifacts platform = getTargetPlatform(); - - final ProductConfiguration product = ProductConfiguration.read(new File(productFile)); - - ArtifactDependencyWalker walker = new AbstractArtifactDependencyWalker(platform) { - @Override - public void walk(ArtifactDependencyVisitor visitor) { - traverseProduct(product, visitor); - } - }; - - walker.walk(new ArtifactDependencyVisitor() { - @Override - public void visitPlugin(PluginDescription plugin) { - plugins.add(plugin); - } - - @Override - public boolean visitFeature(FeatureDescription feature) { - features.add(feature); - return true; - } - }); - } - - protected DependencyArtifacts getTargetPlatform() throws Exception { - LocalDependencyResolver resolver = (LocalDependencyResolver) lookup(DependencyResolver.class, - LocalDependencyResolver.ROLE_HINT); - - MavenExecutionRequest request = new DefaultMavenExecutionRequest(); - request.setLocalRepository(new StubArtifactRepository(System.getProperty("java.io.tmpdir"))); - MavenExecutionResult result = new DefaultMavenExecutionResult(); - DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - MavenSession session = new MavenSession(getContainer(), repositorySession, request, result); - session.setProjects(new ArrayList<>()); - lookup(LegacySupport.class).setSession(session); - - MavenProject project = new MavenProject(); - - resolver.setLocation(new File("src/test/resources/targetplatforms/basic")); - - DependencyArtifacts platform = resolver.resolveDependencies(session, project, null, - DefaultReactorProject.adapt(session), null); - return platform; - } -} diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/test/LocalDependencyResolverTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/test/LocalDependencyResolverTest.java deleted file mode 100644 index 3486efb49c..0000000000 --- a/tycho-core/src/test/java/org/eclipse/tycho/core/test/LocalDependencyResolverTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 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 - *******************************************************************************/ -package org.eclipse.tycho.core.test; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Map; - -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.DefaultMavenExecutionResult; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionResult; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; -import org.apache.maven.project.MavenProject; -import org.eclipse.aether.DefaultRepositorySystemSession; -import org.eclipse.tycho.ArtifactDescriptor; -import org.eclipse.tycho.ArtifactKey; -import org.eclipse.tycho.ArtifactType; -import org.eclipse.tycho.DependencyArtifacts; -import org.eclipse.tycho.core.DependencyResolver; -import org.eclipse.tycho.core.osgitools.DefaultReactorProject; -import org.eclipse.tycho.core.osgitools.targetplatform.LocalDependencyResolver; -import org.eclipse.tycho.testing.AbstractTychoMojoTestCase; - -public class LocalDependencyResolverTest extends AbstractTychoMojoTestCase { - public void testBundleIdParsing() throws Exception { - DependencyArtifacts platform = getTargetPlatform(new File("src/test/resources/targetplatforms/basic")); - - ArtifactDescriptor artifact = platform.getArtifact(ArtifactType.TYPE_ECLIPSE_PLUGIN, "bundle01", null); - ArtifactKey key = artifact.getKey(); - assertEquals("bundle01", key.getId()); - assertEquals("0.0.1", key.getVersion()); - - File file = artifact.getLocation(true); - assertEquals("bundle01_0.0.1", file.getName()); - } - - protected DependencyArtifacts getTargetPlatform(File location) throws Exception, IOException { - LocalDependencyResolver resolver = (LocalDependencyResolver) lookup(DependencyResolver.class, - LocalDependencyResolver.ROLE_HINT); - - MavenExecutionRequest request = new DefaultMavenExecutionRequest(); - request.setLocalRepository(new StubArtifactRepository(location.getAbsolutePath())); - MavenExecutionResult result = new DefaultMavenExecutionResult(); - DefaultRepositorySystemSession repositorySession = new DefaultRepositorySystemSession(); - MavenSession session = new MavenSession(getContainer(), repositorySession, request, result); - session.setProjects(new ArrayList<>()); - lookup(LegacySupport.class).setSession(session); - - MavenProject project = new MavenProject(); - resolver.setLocation(location); - - DependencyArtifacts platform = resolver.resolveDependencies(session, project, null, - DefaultReactorProject.adapt(session), null); - return platform; - } - - public void testPlatformRelativePath() throws Exception { - File platformPath = new File("src/test/resources/targetplatforms/basic"); - DependencyArtifacts platform = getTargetPlatform(platformPath); - - // absolute path to a bundle - File bundlePath = new File(platformPath, "plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20081125.jar") - .getAbsoluteFile(); - - Map artifact = platform.getArtifact(bundlePath); - - assertNotNull(artifact); - } - - public void testBundleRelativePath() throws Exception { - File platformPath = new File("src/test/resources/targetplatforms/basic").getAbsoluteFile(); - DependencyArtifacts platform = getTargetPlatform(platformPath); - - File bundlePath = new File( - "src/test/resources/targetplatforms/basic/plugins/org.eclipse.equinox.launcher_1.0.101.R34x_v20081125.jar"); - - Map artifact = platform.getArtifact(bundlePath); - - assertNotNull(artifact); - } -} 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 8ac279471e..37586336d3 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 @@ -72,7 +72,17 @@ import org.eclipse.sisu.equinox.launching.EquinoxLauncher; import org.eclipse.sisu.equinox.launching.LaunchConfiguration; import org.eclipse.sisu.equinox.launching.internal.EquinoxLaunchConfiguration; -import org.eclipse.tycho.*; +import org.eclipse.tycho.ArtifactDescriptor; +import org.eclipse.tycho.ArtifactKey; +import org.eclipse.tycho.ArtifactType; +import org.eclipse.tycho.BuildDirectory; +import org.eclipse.tycho.DefaultArtifactKey; +import org.eclipse.tycho.DependencyArtifacts; +import org.eclipse.tycho.OptionalResolutionAction; +import org.eclipse.tycho.PlatformPropertiesUtils; +import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.TargetEnvironment; +import org.eclipse.tycho.TychoConstants; import org.eclipse.tycho.core.BundleProject; import org.eclipse.tycho.core.DependencyResolver; import org.eclipse.tycho.core.DependencyResolverConfiguration; @@ -841,9 +851,8 @@ public List getExtraRequirements() { return extraDependencies; } }; - DependencyArtifacts testRuntimeArtifacts = platformResolver.resolveDependencies(session, project, null, - reactorProjects, resolverConfiguration); + reactorProjects, resolverConfiguration, getTestTargetEnvironments()); if (testRuntimeArtifacts == null) { throw new MojoExecutionException( @@ -890,6 +899,24 @@ public List getExtraRequirements() { return installationFactory.createInstallation(testRuntime, work); } + protected List getTestTargetEnvironments() { + TargetPlatformConfiguration configuration = TychoProjectUtils + .getTargetPlatformConfiguration(getReactorProject()); + List targetEnvironments = configuration.getEnvironments(); + TargetEnvironment runningEnvironment = TargetEnvironment.getRunningEnvironment(getReactorProject()); + for (TargetEnvironment targetEnvironment : targetEnvironments) { + if (targetEnvironment.equals(runningEnvironment)) { + getLog().debug("Using matching target environment " + targetEnvironment.toFilterProperties() + + " to resolve test artifacts..."); + return List.of(targetEnvironment); + } + } + getLog().warn("Your build environment " + runningEnvironment.toFilterProperties() + + " do not match any of the configured target environments " + targetEnvironments + + " test execution might vary!"); + return targetEnvironments; + } + private void addBundle(EquinoxInstallationDescription runtime, ArtifactKey artifact, File file) { runtime.addBundle(artifact.getId(), artifact.getVersion(), file); } From d78684cfc0e8033ea66f5a04b316b74cc7261011 Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Fri, 23 Dec 2022 19:30:33 +0100 Subject: [PATCH 05/19] fix several warnings --- .../tycho/p2maven/repository/P2RepositoryManager.java | 2 +- .../tycho/artifactcomparator/ComparatorInputStream.java | 8 +++----- .../tycho/zipcomparator/internal/ClassfileComparator.java | 1 - .../tycho/zipcomparator/internal/ZipComparatorImpl.java | 4 ++-- .../tycho/jarcomparator/tests/ContentsComparatorTest.java | 3 +-- .../tycho/baseline/BundleArtifactBaselineComparator.java | 4 ++-- .../eclipse/tycho/baseline/FeatureBaselineComparator.java | 4 ++-- .../eclipse/tycho/core/osgitools/OsgiBundleProject.java | 1 + .../core/osgitools/BuildPropertiesParserImplTest.java | 3 --- .../org/eclipse/tycho/plugins/p2/extras/MirrorMojo.java | 2 +- .../test/java/org/eclipse/tycho/test/util/HttpServer.java | 3 --- .../plugins/p2/repository/AssembleRepositoryMojo.java | 4 +--- .../tycho/plugins/p2/repository/MavenP2SiteMojo.java | 3 ++- .../eclipse/tycho/buildversion/BuildQualifierMojo.java | 1 - .../java/org/eclipse/tycho/source/OsgiSourceMojo.java | 4 ++-- .../java/org/eclipse/tycho/surefire/AbstractTestMojo.java | 2 +- .../tycho/targetplatform/TargetResolveException.java | 2 ++ 17 files changed, 21 insertions(+), 30 deletions(-) diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/P2RepositoryManager.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/P2RepositoryManager.java index f62e477ebe..e34ebd32b0 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/P2RepositoryManager.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/repository/P2RepositoryManager.java @@ -89,7 +89,7 @@ public IArtifactRepository getCompositeArtifactRepository(Collection if (repositories.size() == 1) { return getArtifactRepository(repositories.iterator().next()); } - ArrayList childs = new ArrayList(); + ArrayList childs = new ArrayList<>(); for (Repository repository : repositories) { childs.add(getArtifactRepository(repository)); } diff --git a/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/artifactcomparator/ComparatorInputStream.java b/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/artifactcomparator/ComparatorInputStream.java index 1db8029eca..3c11c3301e 100644 --- a/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/artifactcomparator/ComparatorInputStream.java +++ b/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/artifactcomparator/ComparatorInputStream.java @@ -30,16 +30,14 @@ public class ComparatorInputStream extends ByteArrayInputStream { private final byte[] content; - private final String name; - public ComparatorInputStream(InputStream stream, String name) throws IOException { - this(IOUtils.toByteArray(stream), name); + public ComparatorInputStream(InputStream stream) throws IOException { + this(IOUtils.toByteArray(stream)); } - public ComparatorInputStream(byte[] content, String name) { + public ComparatorInputStream(byte[] content) { super(content); this.content = content; - this.name = name; } /** diff --git a/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ClassfileComparator.java b/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ClassfileComparator.java index 63eecd1239..67ee86470e 100644 --- a/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ClassfileComparator.java +++ b/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ClassfileComparator.java @@ -41,7 +41,6 @@ public class ClassfileComparator implements ContentsComparator { @Override public ArtifactDelta getDelta(ComparatorInputStream baseline, ComparatorInputStream reactor, ComparisonData data) throws IOException { - boolean equal; try { String baselineDisassemble = disassemble(baseline.asBytes()); String reactorDisassemble = disassemble(reactor.asBytes()); diff --git a/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ZipComparatorImpl.java b/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ZipComparatorImpl.java index 2cd97cf20d..f5219bb45c 100644 --- a/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ZipComparatorImpl.java +++ b/tycho-artifactcomparator/src/main/java/org/eclipse/tycho/zipcomparator/internal/ZipComparatorImpl.java @@ -108,8 +108,8 @@ private ArtifactDelta getDelta(String name, Map baselineMap, M ContentsComparator comparator = comparators.get(getContentType(name)); if (comparator != null) { try { - return comparator.getDelta(new ComparatorInputStream(baselineBytes, name), - new ComparatorInputStream(reactorBytes, name), data); + return comparator.getDelta(new ComparatorInputStream(baselineBytes), + new ComparatorInputStream(reactorBytes), data); } catch (IOException e) { log.debug("comparing entry " + name + " (baseline = " + baselineJar.getName() + ", reactor=" + reactorJar.getName() + ") using " + comparator.getClass().getName() + " failed with: " + e diff --git a/tycho-artifactcomparator/src/test/java/org/eclipse/tycho/jarcomparator/tests/ContentsComparatorTest.java b/tycho-artifactcomparator/src/test/java/org/eclipse/tycho/jarcomparator/tests/ContentsComparatorTest.java index 31723204e7..07ef6a6046 100644 --- a/tycho-artifactcomparator/src/test/java/org/eclipse/tycho/jarcomparator/tests/ContentsComparatorTest.java +++ b/tycho-artifactcomparator/src/test/java/org/eclipse/tycho/jarcomparator/tests/ContentsComparatorTest.java @@ -61,8 +61,7 @@ private boolean isContentEqual(String type, String baseline, String reactor) thr ContentsComparator comparator = lookup(ContentsComparator.class, type); try (InputStream is = new FileInputStream(baseline)) { try (InputStream is2 = new FileInputStream(reactor)) { - return comparator.getDelta(new ComparatorInputStream(is, "base"), - new ComparatorInputStream(is2, "reactor"), null) == null; + return comparator.getDelta(new ComparatorInputStream(is), new ComparatorInputStream(is2), null) == null; } } } diff --git a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/BundleArtifactBaselineComparator.java b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/BundleArtifactBaselineComparator.java index fb2dc3bb0b..057d032aaa 100644 --- a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/BundleArtifactBaselineComparator.java +++ b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/BundleArtifactBaselineComparator.java @@ -352,8 +352,8 @@ private ArtifactDelta getDelta(Diff diff, Jar baselineJar, Jar projectJar, Basel if (baseResource != null && currenttResource != null) { try (InputStream baseStream = baseResource.openInputStream(); InputStream currentStream = currenttResource.openInputStream()) { - return comparator.getDelta(new ComparatorInputStream(baseStream, name), - new ComparatorInputStream(currentStream, name), + return comparator.getDelta(new ComparatorInputStream(baseStream), + new ComparatorInputStream(currentStream), new ComparisonData(baselineContext.getIgnores(), false)); } catch (Exception e) { } diff --git a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/FeatureBaselineComparator.java b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/FeatureBaselineComparator.java index 30c7c018d4..d21a1dbbbd 100644 --- a/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/FeatureBaselineComparator.java +++ b/tycho-baseline-plugin/src/main/java/org/eclipse/tycho/baseline/FeatureBaselineComparator.java @@ -333,7 +333,7 @@ private List computeJarDelta(MavenProject project, BaselineContext context // here! ignores.addAll(context.getIgnores()); ArtifactDelta artifactDelta = zipComparator.getDelta(getStream(baselineJarUnit, context), - new ComparatorInputStream(reactor, file.getAbsolutePath()), + new ComparatorInputStream(reactor), new ComparisonData(ignores, false)); if (artifactDelta == null) { return List.of(); @@ -347,7 +347,7 @@ private List computeJarDelta(MavenProject project, BaselineContext context private ComparatorInputStream getStream(IInstallableUnit unit, BaselineContext context) throws IOException { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); repositoryManager.downloadArtifact(unit, context.getArtifactRepository(), outputStream); - return new ComparatorInputStream(outputStream.toByteArray(), unit.getId()); + return new ComparatorInputStream(outputStream.toByteArray()); } private static final List computePropertyDiff(Map base, Map project) { 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 898eb581d4..17ec29b60c 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 @@ -433,6 +433,7 @@ private ModuleContainer getResolverState(ReactorProject project, DependencyArtif } } + @Override public EclipsePluginProject getEclipsePluginProject(ReactorProject otherProject) { EclipsePluginProjectImpl pdeProject = (EclipsePluginProjectImpl) otherProject .getContextValue(CTX_ECLIPSE_PLUGIN_PROJECT); diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/BuildPropertiesParserImplTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/BuildPropertiesParserImplTest.java index 092e1989e7..81202ea4b6 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/BuildPropertiesParserImplTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/core/osgitools/BuildPropertiesParserImplTest.java @@ -23,7 +23,6 @@ import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.logging.Logger; import org.eclipse.tycho.testing.TestUtil; import org.junit.Assert; import org.junit.Before; @@ -36,7 +35,6 @@ public class BuildPropertiesParserImplTest { private MavenSession mavenSession; private MavenProject project1; private MavenProject project2; - private Logger logger; @Before public void setup() throws IllegalArgumentException, IllegalAccessException { @@ -44,7 +42,6 @@ public void setup() throws IllegalArgumentException, IllegalAccessException { mavenSession = mock(MavenSession.class); project1 = mock(MavenProject.class); project2 = mock(MavenProject.class); - logger = mock(Logger.class); when(legacySupport.getSession()).thenReturn(mavenSession); when(mavenSession.getProjects()).thenReturn(Arrays.asList(project1, project2)); diff --git a/tycho-extras/tycho-p2-extras-plugin/src/main/java/org/eclipse/tycho/plugins/p2/extras/MirrorMojo.java b/tycho-extras/tycho-p2-extras-plugin/src/main/java/org/eclipse/tycho/plugins/p2/extras/MirrorMojo.java index dec3d84ce2..6c17b59154 100644 --- a/tycho-extras/tycho-p2-extras-plugin/src/main/java/org/eclipse/tycho/plugins/p2/extras/MirrorMojo.java +++ b/tycho-extras/tycho-p2-extras-plugin/src/main/java/org/eclipse/tycho/plugins/p2/extras/MirrorMojo.java @@ -67,7 +67,7 @@ public class MirrorMojo extends AbstractMojo { /** * Source repositori(es) to mirror from. * - * @see also {@link #targetPlatformAsSource} and {@link #currentModuleAsSource} + * @see {@link #targetPlatformAsSource} and {@link #currentModuleAsSource} */ @Parameter(required = false) private List source; diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/util/HttpServer.java b/tycho-its/src/test/java/org/eclipse/tycho/test/util/HttpServer.java index 7a636f8e1f..682e6fb942 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/util/HttpServer.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/util/HttpServer.java @@ -18,7 +18,6 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.Random; import java.util.concurrent.TimeUnit; import javax.servlet.ServletException; @@ -77,8 +76,6 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response) private static final int BIND_ATTEMPTS = 20; - private static final Random rnd = new Random(); - private final Server server; private final int port; diff --git a/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java b/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java index a6eee29553..9d7e0ae19c 100644 --- a/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java +++ b/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/AssembleRepositoryMojo.java @@ -24,7 +24,6 @@ import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.FileUtils; import org.eclipse.tycho.PackagingType; import org.eclipse.tycho.ReactorProject; @@ -213,8 +212,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { RepositoryReferences sources = repositoryReferenceTool.getVisibleRepositories(getProject(), getSession(), RepositoryReferenceTool.REPOSITORIES_INCLUDE_CURRENT_MODULE); - List repositoryReferences = getCategories(categoriesDirectory) - .stream()// + List repositoryReferences = getCategories(categoriesDirectory).stream()// .map(Category::getRepositoryReferences)// .flatMap(List::stream)// .map(ref -> new RepositoryReference(ref.getName(), ref.getLocation(), ref.isEnabled()))// diff --git a/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/MavenP2SiteMojo.java b/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/MavenP2SiteMojo.java index a56d47c235..815ceaa722 100644 --- a/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/MavenP2SiteMojo.java +++ b/tycho-p2/tycho-p2-repository-plugin/src/main/java/org/eclipse/tycho/plugins/p2/repository/MavenP2SiteMojo.java @@ -195,7 +195,8 @@ public class MavenP2SiteMojo extends AbstractMojo { /** * Configures the key servers that are used to fetch the public keys, if not specified, - * {@value #UBUNTU_KEY_SERVER} and {@value #MAVEN_CENTRAL_KEY_SERVER} are used in this order. + * {@value PGPService#UBUNTU_KEY_SERVER} and {@value PGPService#MAVEN_CENTRAL_KEY_SERVER} are + * used in this order. */ @Parameter private List keyServerUrls; diff --git a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java index 0bd15cb94c..9d18f8ebfd 100644 --- a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java +++ b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/buildversion/BuildQualifierMojo.java @@ -86,7 +86,6 @@ */ @Mojo(name = "build-qualifier", defaultPhase = LifecyclePhase.VALIDATE, threadSafe = true) public class BuildQualifierMojo extends AbstractVersionMojo { - private static final Object LOCK = new Object(); @Parameter(property = "session", readonly = true) protected MavenSession session; diff --git a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/OsgiSourceMojo.java b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/OsgiSourceMojo.java index 6ee5488bc4..c4bd51ff30 100644 --- a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/OsgiSourceMojo.java +++ b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/OsgiSourceMojo.java @@ -113,8 +113,8 @@ public class OsgiSourceMojo extends AbstractSourceJarMojo { private String qualifier; /** - * Whether default source excludes for SCM files defined in - * {@see AbstractScanner#DEFAULTEXCLUDES} should be used. + * Whether default source excludes for SCM files defined in {AbstractScanner#DEFAULTEXCLUDES} + * should be used. */ @Parameter(defaultValue = "true") protected boolean useDefaultSourceExcludes; 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 37586336d3..38444883cb 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 @@ -157,7 +157,7 @@ public abstract class AbstractTestMojo extends AbstractMojo { /** * Set this parameter to suspend the test JVM waiting for a client to open a remote debug * session on the specified port. If further customization of JVM debug parameters is required - * then {@link argLine} can be used instead. + * then {@link #argLine} can be used instead. */ @Parameter(property = "debugPort") private int debugPort; diff --git a/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetResolveException.java b/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetResolveException.java index 27b960201e..09895a32a3 100644 --- a/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetResolveException.java +++ b/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetResolveException.java @@ -14,6 +14,8 @@ public class TargetResolveException extends Exception { + private static final long serialVersionUID = 1L; + public TargetResolveException(String message) { super(message); } From ee1128eb66141f4dd0580fe04da00264b2e1b17b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 28 Dec 2022 23:09:20 +0000 Subject: [PATCH 06/19] Bump mockito-core from 4.10.0 to 4.11.0 Bumps [mockito-core](https://github.com/mockito/mockito) from 4.10.0 to 4.11.0. - [Release notes](https://github.com/mockito/mockito/releases) - [Commits](https://github.com/mockito/mockito/compare/v4.10.0...v4.11.0) --- updated-dependencies: - dependency-name: org.mockito:mockito-core dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b44afaf330..d40762bd1c 100644 --- a/pom.xml +++ b/pom.xml @@ -207,7 +207,7 @@ org.mockito mockito-core - 4.10.0 + 4.11.0 test From 0add61b484f6eb914459c4cb6630cf1ae8d85451 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 30 Dec 2022 23:11:53 +0000 Subject: [PATCH 07/19] Bump maven-version from 3.8.6 to 3.8.7 Bumps `maven-version` from 3.8.6 to 3.8.7. Updates `maven-plugin-api` from 3.8.6 to 3.8.7 - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.8.6...maven-3.8.7) Updates `maven-core` from 3.8.6 to 3.8.7 - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.8.6...maven-3.8.7) Updates `maven-artifact` from 3.8.6 to 3.8.7 - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.8.6...maven-3.8.7) Updates `maven-compat` from 3.8.6 to 3.8.7 - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.8.6...maven-3.8.7) Updates `maven-model` from 3.8.6 to 3.8.7 - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.8.6...maven-3.8.7) Updates `maven-settings` from 3.8.6 to 3.8.7 - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.8.6...maven-3.8.7) Updates `maven-model-builder` from 3.8.6 to 3.8.7 - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.8.6...maven-3.8.7) Updates `apache-maven` from 3.8.6 to 3.8.7 - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.8.6...maven-3.8.7) Updates `maven-embedder` from 3.8.6 to 3.8.7 - [Release notes](https://github.com/apache/maven/releases) - [Commits](https://github.com/apache/maven/compare/maven-3.8.6...maven-3.8.7) --- updated-dependencies: - dependency-name: org.apache.maven:maven-plugin-api dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven:maven-core dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven:maven-artifact dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven:maven-compat dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven:maven-model dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven:maven-settings dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven:maven-model-builder dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven:apache-maven:bin dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.apache.maven:maven-embedder dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d40762bd1c..08385f1967 100644 --- a/pom.xml +++ b/pom.xml @@ -67,7 +67,7 @@ 2.0 3.7.0 6.4.0.202211300538-r - 3.8.6 + 3.8.7 3.0.0-M5 From 9b5b21bd3b9c17c08625a552ae740afee6f791e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sat, 31 Dec 2022 11:44:08 +0100 Subject: [PATCH 08/19] Add commons-io previously transitively required --- pom.xml | 5 ++ tycho-artifactcomparator/pom.xml | 4 + tycho-extras/tycho-pomless/pom.xml | 113 ++++++++++++++--------------- tycho-targetplatform/pom.xml | 5 +- 4 files changed, 67 insertions(+), 60 deletions(-) diff --git a/pom.xml b/pom.xml index 08385f1967..809e4ef079 100644 --- a/pom.xml +++ b/pom.xml @@ -192,6 +192,11 @@ ${project.version} test + + commons-io + commons-io + 2.11.0 + junit junit diff --git a/tycho-artifactcomparator/pom.xml b/tycho-artifactcomparator/pom.xml index 9f07992aec..c73440e2e7 100644 --- a/tycho-artifactcomparator/pom.xml +++ b/tycho-artifactcomparator/pom.xml @@ -54,6 +54,10 @@ org.apache.maven maven-core + + commons-io + commons-io + org.xmlunit xmlunit-core diff --git a/tycho-extras/tycho-pomless/pom.xml b/tycho-extras/tycho-pomless/pom.xml index bbe3619b30..5f14c4ff6f 100644 --- a/tycho-extras/tycho-pomless/pom.xml +++ b/tycho-extras/tycho-pomless/pom.xml @@ -9,77 +9,72 @@ - Contributors: - SAP SE - initial API and implementation --> - - 4.0.0 - + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 org.eclipse.tycho.extras tycho-extras 4.0.0-SNAPSHOT - - tycho-pomless - - Tycho POM-less build extension - A build extension which allows to omit pom.xml files for all Eclipse PDE projects, Plug-ins(Bundles) and Features + tycho-pomless + Tycho POM-less build extension + A build extension which allows to omit pom.xml files for all Eclipse PDE projects, Plug-ins(Bundles) and Features as well as Eclipse Products, Target-Platforms and p2-repository definitions (category.xml). - - - - - - org.codehaus.plexus - plexus-component-metadata - - - - - - - - org.codehaus.plexus - plexus-utils - provided - - - io.takari.polyglot - polyglot-common - 0.4.9 - - - org.eclipse.sisu - org.eclipse.sisu.plexus - provided - - - org.apache.maven - maven-model - provided - - - org.apache.maven - maven-model-builder - provided - - - org.apache.maven - maven-core - provided - + + + + org.codehaus.plexus + plexus-component-metadata + + + + + + org.codehaus.plexus + plexus-utils + provided + + + io.takari.polyglot + polyglot-common + 0.4.9 + + + org.eclipse.sisu + org.eclipse.sisu.plexus + provided + + + org.apache.maven + maven-model + provided + + + org.apache.maven + maven-model-builder + provided + + + org.apache.maven + maven-core + provided + + + commons-io + commons-io + org.apache.maven maven-embedder ${maven-version} provided - - junit - junit - test - - - + + junit + junit + test + + diff --git a/tycho-targetplatform/pom.xml b/tycho-targetplatform/pom.xml index c56763be08..8b0f8fdde2 100644 --- a/tycho-targetplatform/pom.xml +++ b/tycho-targetplatform/pom.xml @@ -22,8 +22,11 @@ org.apache.maven maven-core + + commons-io + commons-io + - From 1818ba8d8adbb875f4270caef469697cc7d284a4 Mon Sep 17 00:00:00 2001 From: Michael Keppler Date: Sun, 1 Jan 2023 15:38:48 +0100 Subject: [PATCH 09/19] Fix #1789: Avoid wrong archive entry warnings Upgrade plexus archiver which contains a fix now. --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 809e4ef079..0d9d446809 100644 --- a/pom.xml +++ b/pom.xml @@ -148,7 +148,7 @@ org.codehaus.plexus plexus-archiver - 4.6.0 + 4.6.1 org.codehaus.plexus From 99be68a56f798f82cfdabef3a1aeaecd51f60920 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 2 Jan 2023 07:22:45 +0100 Subject: [PATCH 10/19] Delete unused Adapter interface --- .../compiler/AbstractOsgiCompilerMojo.java | 13 +------------ .../compiler}/JavaCompilerConfiguration.java | 10 +++++----- .../org/eclipse/tycho/runtime/Adaptable.java | 17 ----------------- 3 files changed, 6 insertions(+), 34 deletions(-) rename {tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath => tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler}/JavaCompilerConfiguration.java (84%) delete mode 100644 tycho-embedder-api/src/main/java/org/eclipse/tycho/runtime/Adaptable.java diff --git a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java index 0d4db27133..4a0a3d1a94 100644 --- a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java @@ -68,7 +68,6 @@ import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; -import org.eclipse.tycho.classpath.JavaCompilerConfiguration; import org.eclipse.tycho.classpath.SourcepathEntry; import org.eclipse.tycho.core.BundleProject; import org.eclipse.tycho.core.TychoProject; @@ -89,7 +88,6 @@ import org.eclipse.tycho.core.osgitools.project.EclipsePluginProject; import org.eclipse.tycho.core.resolver.shared.PomDependencies; import org.eclipse.tycho.core.utils.TychoProjectUtils; -import org.eclipse.tycho.runtime.Adaptable; import org.osgi.framework.Constants; import org.osgi.framework.Filter; import org.osgi.framework.FrameworkUtil; @@ -100,8 +98,7 @@ import copied.org.apache.maven.plugin.AbstractCompilerMojo; -public abstract class AbstractOsgiCompilerMojo extends AbstractCompilerMojo - implements JavaCompilerConfiguration, Adaptable { +public abstract class AbstractOsgiCompilerMojo extends AbstractCompilerMojo implements JavaCompilerConfiguration { public static final String RULE_SEPARATOR = File.pathSeparator; @@ -985,12 +982,4 @@ private void checkTargetLevelCompatibleWithManifestBREEs(String effectiveTargetL } } - @Override - public T getAdapter(Class adapter) { - if (adapter.isAssignableFrom(JavaCompilerConfiguration.class)) { - return adapter.cast(this); - } - return null; - } - } diff --git a/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/JavaCompilerConfiguration.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/JavaCompilerConfiguration.java similarity index 84% rename from tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/JavaCompilerConfiguration.java rename to tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/JavaCompilerConfiguration.java index 7a68186f33..6e9b573318 100644 --- a/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/JavaCompilerConfiguration.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/JavaCompilerConfiguration.java @@ -10,18 +10,18 @@ * Contributors: * Sonatype Inc. - initial API and implementation *******************************************************************************/ -package org.eclipse.tycho.classpath; +package org.eclipse.tycho.compiler; import java.util.List; import org.apache.maven.plugin.MojoExecutionException; -import org.eclipse.tycho.runtime.Adaptable; +import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.classpath.SourcepathEntry; /** * Computes and returns Tycho java compiler configuration, i.e. compile or test-compile mojos of - * org.eclipse.tycho:tycho-compiler-plugin - * Use {@link Adaptable#getAdapter(Class)} on compile or test-compile mojos to get instance of this - * intergace + * org.eclipse.tycho:tycho-compiler-plugin Use {@link Adaptable#getAdapter(Class)} on compile or + * test-compile mojos to get instance of this intergace * * @author igor * @noimplement This interface is not intended to be implemented by clients. diff --git a/tycho-embedder-api/src/main/java/org/eclipse/tycho/runtime/Adaptable.java b/tycho-embedder-api/src/main/java/org/eclipse/tycho/runtime/Adaptable.java deleted file mode 100644 index 7dfd51ec78..0000000000 --- a/tycho-embedder-api/src/main/java/org/eclipse/tycho/runtime/Adaptable.java +++ /dev/null @@ -1,17 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 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 - *******************************************************************************/ -package org.eclipse.tycho.runtime; - -public interface Adaptable { - public T getAdapter(Class adapter); -} From 603ec4e76fc8e70018bae63c990b4df49da1fc4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 2 Jan 2023 07:25:37 +0100 Subject: [PATCH 11/19] Remove unused DependencyVisitor interface --- .../tycho/resolver/DependencyVisitor.java | 22 ------------------- 1 file changed, 22 deletions(-) delete mode 100644 tycho-embedder-api/src/main/java/org/eclipse/tycho/resolver/DependencyVisitor.java diff --git a/tycho-embedder-api/src/main/java/org/eclipse/tycho/resolver/DependencyVisitor.java b/tycho-embedder-api/src/main/java/org/eclipse/tycho/resolver/DependencyVisitor.java deleted file mode 100644 index 0928dc785e..0000000000 --- a/tycho-embedder-api/src/main/java/org/eclipse/tycho/resolver/DependencyVisitor.java +++ /dev/null @@ -1,22 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 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 - *******************************************************************************/ -package org.eclipse.tycho.resolver; - -import org.eclipse.tycho.ArtifactDescriptor; - -public interface DependencyVisitor { - /** - * @TODO internally, we distinguish between bundles, features, etc - */ - public boolean visit(ArtifactDescriptor artifact); -} From dcbcc3e407b853e4d33d3bfd285d9bcd3c66e00e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 2 Jan 2023 11:54:05 +0100 Subject: [PATCH 12/19] Support classpath contributors Currently classpath computation is deeply bound to the OsgiProject, but espcially for "compile only" it becomes more harder to manage and add new features the more we support here. This adds a new extension point to Tycho that allows to contribute additional compile classpath entries, for example by DS. --- .../p2maven/helper/PluginRealmHelper.java | 42 +++++ .../org.eclipse.tycho.embedder.shared/pom.xml | 5 + .../org/eclipse/tycho/TargetPlatform.java | 32 ++++ .../compiler/AbstractOsgiCompilerMojo.java | 160 +++++++++++++---- .../tycho/compiler/OsgiTestCompilerMojo.java | 6 - .../tycho/core/TychoProjectManager.java | 27 +++ .../core/maven/MavenDependenciesResolver.java | 55 +++++- ...ractSpecificationClasspathContributor.java | 123 +++++++++++++ ...BundleAnnotationsClasspathContributor.java | 44 +++++ .../core/osgitools/DefaultClasspathEntry.java | 5 + .../core/osgitools/OsgiBundleProject.java | 162 +----------------- ...ioningAnnotationsClasspathContributor.java | 44 +++++ tycho-ds-plugin/pom.xml | 30 ++-- ...DeclarativeServiceConfigurationReader.java | 12 +- ...clarativeServicesClasspathContributor.java | 60 +++++++ .../tycho/ds/DeclarativeServicesMojo.java | 6 +- .../tycho/classpath/ClasspathContributor.java | 10 ++ .../extras/pde/ListDependenciesMojo.java | 41 ++++- .../META-INF/MANIFEST.MF | 3 +- .../lib/osgi.annotation-7.0.0.jar | Bin 35266 -> 0 bytes .../test.bundle/META-INF/MANIFEST.MF | 2 +- .../test.bundle/src/test/TestClass.java | 7 - tycho-its/projects/tycho-ds/pom.xml | 23 +++ .../compiler/CompilerClasspathEntryTest.java | 11 +- .../target/TargetPlatformLocationsTest.java | 6 +- 25 files changed, 672 insertions(+), 244 deletions(-) create mode 100644 tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractSpecificationClasspathContributor.java create mode 100644 tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleAnnotationsClasspathContributor.java create mode 100644 tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/VersioningAnnotationsClasspathContributor.java rename {tycho-core/src/main/java/org/eclipse/tycho/artifacts/configuration => tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds}/DeclarativeServiceConfigurationReader.java (92%) create mode 100644 tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesClasspathContributor.java create mode 100644 tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java delete mode 100644 tycho-its/projects/target.artifact.caching/target.test/plugins/osgi.annotation.bundle_0.0.1/lib/osgi.annotation-7.0.0.jar delete mode 100644 tycho-its/projects/target.artifact.caching/test.bundle/src/test/TestClass.java diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java index af9bf65f7e..3cdb49014c 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java @@ -13,6 +13,7 @@ package org.eclipse.tycho.p2maven.helper; import java.util.Objects; +import java.util.function.Consumer; import org.apache.maven.execution.MavenSession; import org.apache.maven.lifecycle.internal.LifecyclePluginResolver; @@ -27,9 +28,12 @@ import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.plugin.version.PluginVersionResolutionException; import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.classworlds.realm.ClassRealm; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.component.repository.ComponentDependency; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; /** @@ -88,10 +92,35 @@ public static interface PluginFilter { @Requirement protected MavenPluginManager mavenPluginManager; + @Requirement + private PlexusContainer plexus; + + public void visitPluginExtensions(MavenSession session, MavenProject project, Class type, + Consumer consumer) throws PluginVersionResolutionException, PluginDescriptorParsingException, + InvalidPluginDescriptorException, PluginResolutionException, PluginManagerException { + execute(session, project, () -> { + try { + plexus.lookupList(type).forEach(consumer); + } catch (ComponentLookupException e) { + logger.debug("Can't lookup any item of " + type); + } + }); + } + + public void execute(MavenSession session, MavenProject project, Runnable runnable) + throws PluginVersionResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, + PluginResolutionException, PluginManagerException { + execute(session, project, runnable, PluginRealmHelper::isTychoEmbedderPlugin); + } + public void execute(MavenSession session, MavenProject project, Runnable runnable, PluginFilter filter) throws PluginVersionResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, PluginResolutionException, PluginManagerException { Objects.requireNonNull(session); + if (session.getLocalRepository() == null) { + // This happens in some test-code ... but should never happen in real maven... + return; + } MavenSession executeSession = session.clone(); executeSession.setCurrentProject(project); for (Plugin plugin : project.getBuildPlugins()) { @@ -135,4 +164,17 @@ public void execute(MavenSession session, MavenProject project, Runnable runnabl } } + + private static boolean isTychoEmbedderPlugin(PluginDescriptor pluginDescriptor) { + if (pluginDescriptor.getArtifactMap().containsKey("org.eclipse.tycho:tycho-embedder-api")) { + return true; + } + for (ComponentDependency dependency : pluginDescriptor.getDependencies()) { + if ("org.eclipse.tycho".equals(dependency.getGroupId()) + && "tycho-embedder-api".equals(dependency.getArtifactId())) { + return true; + } + } + return false; + } } diff --git a/tycho-bundles/org.eclipse.tycho.embedder.shared/pom.xml b/tycho-bundles/org.eclipse.tycho.embedder.shared/pom.xml index e2e2df7fa0..e27a8da2e8 100644 --- a/tycho-bundles/org.eclipse.tycho.embedder.shared/pom.xml +++ b/tycho-bundles/org.eclipse.tycho.embedder.shared/pom.xml @@ -31,6 +31,11 @@ org.eclipse.equinox.p2.metadata 2.6.300 + + org.eclipse.platform + org.eclipse.equinox.p2.publisher + 1.7.200 + diff --git a/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetPlatform.java b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetPlatform.java index 823c698a75..a23ba626d9 100644 --- a/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetPlatform.java +++ b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/TargetPlatform.java @@ -14,6 +14,8 @@ import java.io.File; +import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; + /** * Set of artifacts which can be used by the build of a project, e.g. to resolve the project's * dependencies. @@ -71,4 +73,34 @@ ArtifactKey resolveArtifact(String type, String id, String versionRef) boolean isFileAlreadyAvailable(ArtifactKey artifactKey); + default ResolvedArtifactKey resolvePackage(String packageName, String versionRef) + throws DependencyResolutionException, IllegalArtifactReferenceException { + ArtifactKey annotationJar = resolveArtifact(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, packageName, + versionRef); + File location = getArtifactLocation(new DefaultArtifactKey(ArtifactType.TYPE_ECLIPSE_PLUGIN, + annotationJar.getId(), annotationJar.getVersion())); + return new ResolvedArtifactKey() { + + @Override + public String getVersion() { + return annotationJar.getVersion(); + } + + @Override + public String getType() { + return annotationJar.getType(); + } + + @Override + public String getId() { + return annotationJar.getId(); + } + + @Override + public File getLocation() { + return location; + } + }; + } + } diff --git a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java index 4a0a3d1a94..c3ceb506a6 100644 --- a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java @@ -27,6 +27,7 @@ import java.util.Comparator; import java.util.HashSet; import java.util.LinkedHashMap; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -35,11 +36,10 @@ import java.util.Set; import java.util.StringJoiner; import java.util.stream.Collectors; +import java.util.stream.Stream; import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.repository.ArtifactRepository; -import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; -import org.apache.maven.artifact.resolver.ArtifactResolutionResult; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; @@ -48,7 +48,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.project.MavenProject; import org.apache.maven.project.artifact.ProjectArtifact; -import org.apache.maven.repository.RepositorySystem; import org.apache.maven.toolchain.ToolchainManager; import org.apache.maven.toolchain.ToolchainManagerPrivate; import org.apache.maven.toolchain.java.DefaultJavaToolChain; @@ -61,11 +60,15 @@ import org.codehaus.plexus.util.DirectoryScanner; import org.codehaus.plexus.util.FileUtils; import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.eclipse.aether.collection.DependencyCollectionException; +import org.eclipse.aether.resolution.DependencyResolutionException; import org.eclipse.jdt.internal.compiler.util.CtSym; import org.eclipse.jdt.internal.compiler.util.JRTUtil; import org.eclipse.osgi.util.ManifestElement; +import org.eclipse.tycho.ArtifactKey; import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.classpath.ClasspathContributor; import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; import org.eclipse.tycho.classpath.SourcepathEntry; @@ -77,6 +80,7 @@ import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils; import org.eclipse.tycho.core.ee.StandardExecutionEnvironment; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment; +import org.eclipse.tycho.core.maven.MavenDependenciesResolver; import org.eclipse.tycho.core.maven.ToolchainProvider; import org.eclipse.tycho.core.maven.ToolchainProvider.JDKUsage; import org.eclipse.tycho.core.osgitools.BundleReader; @@ -88,6 +92,7 @@ import org.eclipse.tycho.core.osgitools.project.EclipsePluginProject; import org.eclipse.tycho.core.resolver.shared.PomDependencies; import org.eclipse.tycho.core.utils.TychoProjectUtils; +import org.eclipse.tycho.p2maven.helper.PluginRealmHelper; import org.osgi.framework.Constants; import org.osgi.framework.Filter; import org.osgi.framework.FrameworkUtil; @@ -129,9 +134,6 @@ public abstract class AbstractOsgiCompilerMojo extends AbstractCompilerMojo impl @Parameter(property = "session", readonly = true) private MavenSession session; - @Component - private RepositorySystem repositorySystem; - /** * Which JDK to use for compilation. Default value is SYSTEM which means the currently running * JDK. If BREE is specified, MANIFEST header Bundle-RequiredExecutionEnvironment @@ -343,9 +345,15 @@ public abstract class AbstractOsgiCompilerMojo extends AbstractCompilerMojo impl @Component private ToolchainManager toolchainManager; + @Component + private PluginRealmHelper pluginRealmHelper; + @Component private Logger logger; + @Component + private MavenDependenciesResolver dependenciesResolver; + private StandardExecutionEnvironment[] manifestBREEs; private File currentOutputDirectory; @@ -816,36 +824,25 @@ private ExecutionEnvironment getTargetExecutionEnvironment() { @Override public List getClasspath() throws MojoExecutionException { - TychoProject projectType = getBundleProject(); - List classpath = new ArrayList<>( - ((BundleProject) projectType).getClasspath(DefaultReactorProject.adapt(project))); - + ReactorProject reactorProject = DefaultReactorProject.adapt(project); + List classpath; + String dependencyScope = getDependencyScope(); + if (Artifact.SCOPE_TEST.equals(dependencyScope)) { + classpath = new ArrayList<>(getBundleProject().getTestClasspath(DefaultReactorProject.adapt(project))); + } else { + classpath = new ArrayList<>(getBundleProject().getClasspath(reactorProject)); + } if (extraClasspathElements != null) { - ArtifactRepository localRepository = session.getLocalRepository(); - List remoteRepositories = project.getRemoteArtifactRepositories(); - for (Dependency extraDependency : extraClasspathElements) { - Artifact artifact = repositorySystem.createDependencyArtifact(extraDependency); - - ArtifactResolutionRequest request = new ArtifactResolutionRequest(); - request.setArtifact(artifact); - request.setLocalRepository(localRepository); - request.setRemoteRepositories(remoteRepositories); - request.setResolveRoot(true); - request.setResolveTransitively(true); - ArtifactResolutionResult result = repositorySystem.resolve(request); - - if (result.hasExceptions()) { - throw new MojoExecutionException("Could not resolve extra classpath entry", - result.getExceptions().get(0)); - } - - for (Artifact b : result.getArtifacts()) { + try { + Collection resolved = dependenciesResolver.resolve(project, + Arrays.asList(extraClasspathElements), List.of(dependencyScope), session); + for (Artifact b : resolved) { ReactorProject bProject = null; if (b instanceof ProjectArtifact projectArtifact) { bProject = DefaultReactorProject.adapt(projectArtifact.getProject()); } ArrayList bLocations = new ArrayList<>(); - bLocations.add(b.getFile()); // TODO properly handle multiple project locations maybe + bLocations.add(b.getFile()); classpath .add(new DefaultClasspathEntry(bProject, ((OsgiBundleProject) getBundleProject()).readOrCreateArtifactKey(b.getFile(), @@ -853,9 +850,82 @@ public List getClasspath() throws MojoExecutionException { b.getGroupId() + "." + b.getArtifactId(), b.getVersion())), bLocations, null)); } + } catch (DependencyCollectionException | DependencyResolutionException e) { + throw new MojoExecutionException("Could not resolve extra classpath entry", e); } } - return classpath; + + try { + pluginRealmHelper.visitPluginExtensions(session, project, ClasspathContributor.class, cpc -> { + List list = cpc.getAdditionalClasspathEntries(reactorProject, dependencyScope); + if (list != null && !list.isEmpty()) { + classpath.addAll(list); + } + }); + } catch (Exception e) { + throw new MojoExecutionException("can't call classpath contributors", e); + } + LinkedHashMap> classpathMap = classpath.stream().collect( + Collectors.groupingBy(ClasspathEntry::getArtifactKey, LinkedHashMap::new, Collectors.toList())); + if (logger.isDebugEnabled()) { + for (var entry : classpathMap.entrySet()) { + List list = entry.getValue(); + if (list.size() > 1) { + logger.info("The following classpath entries are not unique for the artifact key " + entry.getKey() + + " and will be merged:"); + for (ClasspathEntry cpe : list) { + logger.info("\tLocations: " + cpe.getLocations()); + Collection rules = cpe.getAccessRules(); + logger.info("\tRules: " + (rules == null ? "-access all-" : rules.toString())); + } + } + } + } + List uniqueClasspath = classpathMap.entrySet().stream().flatMap(entry -> { + List list = entry.getValue(); + if (list.isEmpty()) { + return Stream.empty(); + } + if (list.size() == 1) { + return list.stream(); + } + ArtifactKey key = entry.getKey(); + ReactorProject compositeProject = findProjectForKey(reactorProject, key); + List compositeFiles = list.stream().flatMap(cpe -> cpe.getLocations().stream()).toList(); + Collection compositeRules = mergeRules(list); + return Stream.of(new ClasspathEntry() { + + @Override + public ArtifactKey getArtifactKey() { + return key; + } + + @Override + public ReactorProject getMavenProject() { + return compositeProject; + } + + @Override + public List getLocations() { + return compositeFiles; + } + + @Override + public Collection getAccessRules() { + return compositeRules; + } + + @Override + public String toString() { + ReactorProject mavenProject = getMavenProject(); + return "MergedClasspathEntry [key=" + getArtifactKey() + ", project=" + + (mavenProject != null ? mavenProject.getId() : "null") + ", locations=" + getLocations() + + ", rules=" + getAccessRules() + "]"; + } + + }); + }).toList(); + return uniqueClasspath; } protected abstract String getDependencyScope(); @@ -865,6 +935,34 @@ public String getExecutionEnvironment() throws MojoExecutionException { return getTargetExecutionEnvironment().getProfileName(); } + private Collection mergeRules(List list) { + Set joinedRules = new LinkedHashSet<>(); + for (ClasspathEntry cpe : list) { + Collection rules = cpe.getAccessRules(); + if (rules == null) { + //according to API null means = export all packages... + return null; + } + joinedRules.addAll(rules); + } + return joinedRules; + } + + private ReactorProject findProjectForKey(ReactorProject root, ArtifactKey key) { + for (MavenProject p : session.getProjects()) { + ReactorProject rp = DefaultReactorProject.adapt(p); + try { + //TODO should we not use equals here?? + if (getBundleProject().getArtifactKey(rp) == key) { + return rp; + } + } catch (RuntimeException | MojoExecutionException e) { + //can't find the artifact key then! + } + } + return null; + } + @Override public String getSourceLevel() throws MojoExecutionException { // first, explicit POM configuration diff --git a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiTestCompilerMojo.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiTestCompilerMojo.java index d590d3ff6f..4729aa8f5f 100644 --- a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiTestCompilerMojo.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiTestCompilerMojo.java @@ -27,7 +27,6 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.eclipse.tycho.ReactorProject; -import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.classpath.SourcepathEntry; import org.eclipse.tycho.core.dotClasspath.SourceFolderClasspathEntry; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; @@ -84,11 +83,6 @@ private Stream getSourceFolders() throws MojoExecutionException { .map(SourceFolderClasspathEntry::getSourcePath); } - @Override - public List getClasspath() throws MojoExecutionException { - return getBundleProject().getTestClasspath(DefaultReactorProject.adapt(project)); - } - @Override protected String getDependencyScope() { return Artifact.SCOPE_TEST; diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProjectManager.java b/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProjectManager.java index fa0a7508cd..884b316b4f 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProjectManager.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/TychoProjectManager.java @@ -15,12 +15,18 @@ import java.util.Map; import java.util.Optional; +import org.apache.maven.artifact.Artifact; import org.apache.maven.project.MavenProject; +import org.apache.maven.project.artifact.ProjectArtifact; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.eclipse.tycho.ArtifactKey; +import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.core.osgitools.BundleReader; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; +import org.eclipse.tycho.core.osgitools.OsgiManifest; +import org.eclipse.tycho.core.osgitools.OsgiManifestParserException; @Component(role = TychoProjectManager.class) public class TychoProjectManager { @@ -28,6 +34,9 @@ public class TychoProjectManager { @Requirement(role = TychoProject.class) Map projectTypes; + @Requirement + BundleReader bundleReader; + public Optional getTychoProject(MavenProject project) { if (project == null) { return Optional.empty(); @@ -50,4 +59,22 @@ public Optional getArtifactKey(ReactorProject project) { return getTychoProject(project).map(tp -> tp.getArtifactKey(project)); } + public ArtifactKey getArtifactKey(Artifact artifact) { + if (artifact instanceof ProjectArtifact) { + ProjectArtifact projectArtifact = (ProjectArtifact) artifact; + Optional key = getArtifactKey(projectArtifact.getProject()); + if (key.isPresent()) { + return key.get(); + } + } + try { + OsgiManifest loadManifest = bundleReader.loadManifest(artifact.getFile()); + return loadManifest.toArtifactKey(); + } catch (OsgiManifestParserException e) { + // not an bundle then... + } + return new DefaultArtifactKey("maven", artifact.getGroupId() + ":" + artifact.getArtifactId(), + artifact.getVersion()); + } + } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/MavenDependenciesResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/MavenDependenciesResolver.java index 7ea721bfee..b433877a14 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/maven/MavenDependenciesResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/maven/MavenDependenciesResolver.java @@ -31,15 +31,22 @@ import org.eclipse.aether.RepositorySystem; import org.eclipse.aether.RepositorySystemSession; import org.eclipse.aether.artifact.ArtifactTypeRegistry; +import org.eclipse.aether.artifact.DefaultArtifact; import org.eclipse.aether.collection.CollectRequest; import org.eclipse.aether.collection.CollectResult; import org.eclipse.aether.collection.DependencyCollectionException; import org.eclipse.aether.graph.DependencyFilter; import org.eclipse.aether.graph.DependencyNode; +import org.eclipse.aether.resolution.ArtifactRequest; +import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.ArtifactResult; import org.eclipse.aether.resolution.DependencyRequest; import org.eclipse.aether.resolution.DependencyResolutionException; import org.eclipse.aether.resolution.DependencyResult; +import org.eclipse.aether.resolution.VersionRangeRequest; +import org.eclipse.aether.resolution.VersionRangeResolutionException; +import org.eclipse.aether.resolution.VersionRangeResult; +import org.eclipse.aether.version.Version; @Component(role = MavenDependenciesResolver.class) public class MavenDependenciesResolver { @@ -78,13 +85,7 @@ public Collection resolve(MavenProject proje Set resultSet = new HashSet<>(); CollectRequest collect = new CollectRequest(); - RepositorySystemSession repositorySession = session.getRepositorySession(); - for (RepositorySessionDecorator decorator : decorators) { - RepositorySystemSession decorated = decorator.decorate(project, repositorySession); - if (decorated != null) { - repositorySession = decorated; - } - } + RepositorySystemSession repositorySession = getRepositorySession(project, session); ArtifactTypeRegistry stereotypes = repositorySession.getArtifactTypeRegistry(); for (org.apache.maven.model.Dependency dependency : dependencies) { collect.addDependency(RepositoryUtils.toDependency(dependency, stereotypes)); @@ -132,4 +133,44 @@ public boolean accept(DependencyNode node, List parents) { } return resultSet; } + + private RepositorySystemSession getRepositorySession(MavenProject project, MavenSession session) { + RepositorySystemSession repositorySession = session.getRepositorySession(); + for (RepositorySessionDecorator decorator : decorators) { + RepositorySystemSession decorated = decorator.decorate(project, repositorySession); + if (decorated != null) { + repositorySession = decorated; + } + } + return repositorySession; + } + + /** + * Resolves the highest version of the given dependency + * + * @param project + * @param session + * @param dependency + * @return + * @throws VersionRangeResolutionException + * @throws ArtifactResolutionException + */ + public Artifact resolveHighestVersion(MavenProject project, MavenSession session, + org.apache.maven.model.Dependency dependency) + throws VersionRangeResolutionException, ArtifactResolutionException { + RepositorySystemSession repositorySession = getRepositorySession(project, session); + ArtifactTypeRegistry stereotypes = repositorySession.getArtifactTypeRegistry(); + DefaultArtifact artifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), + stereotypes.get(dependency.getType()).getExtension(), dependency.getVersion()); + VersionRangeRequest request = new VersionRangeRequest(artifact, project.getRemoteProjectRepositories(), null); + VersionRangeResult versionResult = repoSystem.resolveVersionRange(repositorySession, request); + Version highestVersion = versionResult.getHighestVersion(); + if (highestVersion != null) { + ArtifactRequest artifactRequest = new ArtifactRequest(artifact.setVersion(highestVersion.toString()), + project.getRemoteProjectRepositories(), null); + ArtifactResult result = repoSystem.resolveArtifact(repositorySession, artifactRequest); + return RepositoryUtils.toArtifact(result.getArtifact()); + } + return null; + } } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractSpecificationClasspathContributor.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractSpecificationClasspathContributor.java new file mode 100644 index 0000000000..a28222c0c6 --- /dev/null +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractSpecificationClasspathContributor.java @@ -0,0 +1,123 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich 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: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.core.osgitools; + +import java.util.Collections; +import java.util.List; + +import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; +import org.apache.maven.model.Dependency; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.logging.Logger; +import org.eclipse.aether.resolution.ArtifactResolutionException; +import org.eclipse.aether.resolution.VersionRangeResolutionException; +import org.eclipse.tycho.ArtifactKey; +import org.eclipse.tycho.DependencyResolutionException; +import org.eclipse.tycho.IllegalArtifactReferenceException; +import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.ResolvedArtifactKey; +import org.eclipse.tycho.TargetPlatform; +import org.eclipse.tycho.classpath.ClasspathContributor; +import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; +import org.eclipse.tycho.core.TychoProjectManager; +import org.eclipse.tycho.core.maven.MavenDependenciesResolver; +import org.eclipse.tycho.core.osgitools.DefaultClasspathEntry.DefaultAccessRule; +import org.eclipse.tycho.core.utils.TychoProjectUtils; +import org.osgi.framework.Version; +import org.osgi.framework.VersionRange; + +/** + * Abstract implementation that contributes a "specification package" to the compile classpath in + * two ways: + *
    + *
  1. First the target platform is searched for a suitable artifact and this one is used
  2. + *
  3. If nothing is found, a well known maven artifact is searched and used as an alternative
  4. + *
+ */ +public abstract class AbstractSpecificationClasspathContributor implements ClasspathContributor { + @Requirement + private MavenDependenciesResolver dependenciesResolver; + + @Requirement + protected Logger logger; + + @Requirement + private TychoProjectManager projectManager; + + protected final MavenSession session; + + protected final String packageName; + + protected final String mavenGroupId; + + protected final String mavenArtifactId; + + private final AccessRule accessRule; + + protected AbstractSpecificationClasspathContributor(MavenSession session, String packageName, String mavenGroupId, + String mavenArtifactId) { + this.session = session; + this.packageName = packageName; + this.mavenGroupId = mavenGroupId; + this.mavenArtifactId = mavenArtifactId; + this.accessRule = new DefaultAccessRule(packageName.replace('.', '/') + "/*", false); + + } + + @Override + public final List getAdditionalClasspathEntries(ReactorProject project, String scope) { + Version specificationVersion = getSpecificationVersion(project); + Version nextMajor = new Version(specificationVersion.getMajor() + 1, 0, 0); + TargetPlatform tp = TychoProjectUtils.getTargetPlatformIfAvailable(project); + // try to resolve from TP first... + if (tp != null) { + try { + VersionRange versionRange = new VersionRange(VersionRange.LEFT_CLOSED, specificationVersion, nextMajor, + VersionRange.RIGHT_OPEN); + ResolvedArtifactKey resolvePackage = tp.resolvePackage(packageName, versionRange.toString()); + logger.debug("Resolved " + packageName + " to " + resolvePackage.getId() + " " + + resolvePackage.getVersion() + " @ " + resolvePackage.getLocation()); + return List.of(new DefaultClasspathEntry(resolvePackage, List.of(accessRule))); + } catch (DependencyResolutionException | IllegalArtifactReferenceException e) { + logger.debug("Cannot find package " + packageName + " in target platform: " + e); + } + } + if (mavenGroupId != null && mavenArtifactId != null) { + try { + // then fallback to maven artifact ... + Dependency dependency = new Dependency(); + dependency.setGroupId(mavenGroupId); + dependency.setArtifactId(mavenArtifactId); + dependency.setVersion(String.format("[%d.%d,%d)", specificationVersion.getMajor(), + specificationVersion.getMinor(), nextMajor.getMajor())); + Artifact artifact = dependenciesResolver.resolveHighestVersion(project.adapt(MavenProject.class), + session, dependency); + ArtifactKey artifactKey = projectManager.getArtifactKey(artifact); + logger.debug("Resolved " + packageName + " to " + artifact.getId() + " @ " + artifact.getFile()); + return List.of( + new DefaultClasspathEntry(null, artifactKey, List.of(artifact.getFile()), List.of(accessRule))); + } catch (VersionRangeResolutionException | ArtifactResolutionException e) { + logger.debug("Can't find maven artifact " + mavenGroupId + ":" + mavenArtifactId + " for package " + + packageName + ": " + e); + } + } + logger.warn("Can't resolve specification package " + packageName + + " neither from the target platform nor from maven artifacts, classpath might be incomplete!"); + return Collections.emptyList(); + } + + protected abstract Version getSpecificationVersion(ReactorProject project); +} diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleAnnotationsClasspathContributor.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleAnnotationsClasspathContributor.java new file mode 100644 index 0000000000..90ea6f49ca --- /dev/null +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleAnnotationsClasspathContributor.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich 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: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.core.osgitools; + +import javax.inject.Inject; + +import org.apache.maven.SessionScoped; +import org.apache.maven.execution.MavenSession; +import org.codehaus.plexus.component.annotations.Component; +import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.classpath.ClasspathContributor; +import org.osgi.framework.Version; + +@Component(role = ClasspathContributor.class, hint = "bundle-annotations") +@SessionScoped +public class BundleAnnotationsClasspathContributor extends AbstractSpecificationClasspathContributor + implements ClasspathContributor { + + private static final String PACKAGE_NAME = "org.osgi.annotation.bundle"; + private static final String GROUP_ID = "org.osgi"; + private static final String ARTIFACT_ID = "org.osgi.annotation.bundle"; + private static final Version VERSION = new Version(1, 0, 0); + + @Inject + protected BundleAnnotationsClasspathContributor(MavenSession session) { + super(session, PACKAGE_NAME, GROUP_ID, ARTIFACT_ID); + } + + @Override + protected Version getSpecificationVersion(ReactorProject project) { + return VERSION; + } + +} diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultClasspathEntry.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultClasspathEntry.java index 8c555a5104..7be6b3c42c 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultClasspathEntry.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultClasspathEntry.java @@ -21,6 +21,7 @@ import org.eclipse.tycho.ArtifactKey; import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.ResolvedArtifactKey; import org.eclipse.tycho.classpath.ClasspathEntry; public class DefaultClasspathEntry implements ClasspathEntry { @@ -79,6 +80,10 @@ public boolean isDiscouraged() { } + public DefaultClasspathEntry(ResolvedArtifactKey key, Collection rules) { + this(null, key, List.of(key.getLocation()), rules); + } + public DefaultClasspathEntry(ReactorProject project, ArtifactKey key, List locations, Collection rules) { this.key = Objects.requireNonNull(key); 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 17ec29b60c..d7f1288057 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 @@ -24,17 +24,14 @@ import java.util.Collections; import java.util.HashMap; import java.util.Iterator; -import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; import java.util.Properties; -import java.util.Set; import java.util.function.Supplier; import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.stream.Collectors; -import java.util.stream.Stream; import org.apache.maven.execution.MavenSession; import org.apache.maven.project.MavenProject; @@ -43,7 +40,6 @@ import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.eclipse.equinox.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.spi.p2.publisher.PublisherHelper; import org.eclipse.osgi.container.Module; import org.eclipse.osgi.container.ModuleContainer; import org.eclipse.osgi.container.ModuleRevision; @@ -55,16 +51,12 @@ import org.eclipse.tycho.BuildPropertiesParser; import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.DependencyArtifacts; -import org.eclipse.tycho.DependencyResolutionException; -import org.eclipse.tycho.IllegalArtifactReferenceException; import org.eclipse.tycho.PackagingType; import org.eclipse.tycho.PlatformPropertiesUtils; import org.eclipse.tycho.ReactorProject; -import org.eclipse.tycho.ResolvedArtifactKey; import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.TargetPlatform; import org.eclipse.tycho.TychoConstants; -import org.eclipse.tycho.artifacts.configuration.DeclarativeServiceConfigurationReader; import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; import org.eclipse.tycho.core.ArtifactDependencyVisitor; @@ -99,13 +91,10 @@ import org.osgi.framework.Filter; import org.osgi.framework.FrameworkUtil; import org.osgi.framework.InvalidSyntaxException; -import org.osgi.framework.Version; @Component(role = TychoProject.class, hint = PackagingType.TYPE_ECLIPSE_PLUGIN) public class OsgiBundleProject extends AbstractTychoProject implements BundleProject { - private static final Collection OSGI_ANNOTATION_PACKAGES = List.of("org.osgi.annotation.bundle", - "org.osgi.annotation.versioning", "org.osgi.service.component.annotations"); private static final String CTX_OSGI_BUNDLE_BASENAME = TychoConstants.CTX_BASENAME + "/osgiBundle"; private static final String CTX_ARTIFACT_KEY = CTX_OSGI_BUNDLE_BASENAME + "/artifactKey"; private static final String CTX_CLASSPATH = CTX_OSGI_BUNDLE_BASENAME + "/classPath"; @@ -132,9 +121,6 @@ public class OsgiBundleProject extends AbstractTychoProject implements BundlePro @Requirement P2ResolverFactory resolverFactory; - @Requirement - private DeclarativeServiceConfigurationReader dsConfigReader; - @Requirement private BuildPropertiesParser buildPropertiesParser; @@ -268,96 +254,7 @@ private BundleClassPath resolveClassPath(MavenSession session, MavenProject proj List bootClasspathExtraAccessRules = dependencyComputer.computeBootClasspathExtraAccessRules(state); addPDESourceRoots(project); - LinkedHashMap> classpathMap = classpath.stream().collect( - Collectors.groupingBy(ClasspathEntry::getArtifactKey, LinkedHashMap::new, Collectors.toList())); - if (logger.isDebugEnabled()) { - for (var entry : classpathMap.entrySet()) { - List list = entry.getValue(); - if (list.size() > 1) { - logger.info("The following classpath entries are not unique for the artifact key " + entry.getKey() - + " and will be merged:"); - for (ClasspathEntry cpe : list) { - logger.info("\tLocations: " + cpe.getLocations()); - Collection rules = cpe.getAccessRules(); - logger.info("\tRules: " + (rules == null ? "-access all-" : rules.toString())); - } - } - } - } - List uniqueClasspath = classpathMap.entrySet().stream().flatMap(entry -> { - List list = entry.getValue(); - if (list.isEmpty()) { - return Stream.empty(); - } - if (list.size() == 1) { - return list.stream(); - } - ArtifactKey key = entry.getKey(); - ReactorProject compositeProject = findProjectForKey(reactorProject, key); - List compositeFiles = list.stream().flatMap(cpe -> cpe.getLocations().stream()).toList(); - Collection compositeRules = mergeRules(list); - return Stream.of(new ClasspathEntry() { - - @Override - public ArtifactKey getArtifactKey() { - return key; - } - - @Override - public ReactorProject getMavenProject() { - return compositeProject; - } - - @Override - public List getLocations() { - return compositeFiles; - } - - @Override - public Collection getAccessRules() { - return compositeRules; - } - - @Override - public String toString() { - ReactorProject mavenProject = getMavenProject(); - return "MergedClasspathEntry [key=" + getArtifactKey() + ", project=" - + (mavenProject != null ? mavenProject.getId() : "null") + ", locations=" + getLocations() - + ", rules=" + getAccessRules() + "]"; - } - - }); - }).toList(); - return new BundleClassPath(uniqueClasspath, strictBootClasspathAccessRules, bootClasspathExtraAccessRules); - } - - private Collection mergeRules(List list) { - Set joinedRules = new LinkedHashSet<>(); - for (ClasspathEntry cpe : list) { - Collection rules = cpe.getAccessRules(); - if (rules == null) { - //according to API null means = export all packages... - return null; - } - joinedRules.addAll(rules); - } - return joinedRules; - } - - private ReactorProject findProjectForKey(ReactorProject root, ArtifactKey key) { - MavenSession mavenSession = getMavenSession(root); - for (MavenProject p : mavenSession.getProjects()) { - ReactorProject rp = DefaultReactorProject.adapt(p); - try { - //TODO should we not use equals here?? - if (getArtifactKey(rp) == key) { - return rp; - } - } catch (RuntimeException e) { - //can't find the artifact key then! - } - } - return null; + return new BundleClassPath(classpath, strictBootClasspathAccessRules, bootClasspathExtraAccessRules); } private Collection computeExtraTestClasspath(ReactorProject reactorProject) { @@ -597,63 +494,6 @@ private void addExtraClasspathEntries(List classpath, ReactorPro Collections.singletonList(location), null)); } } - for (var entry : getAnnotationArtifacts(project).entrySet()) { - String pkg = entry.getKey(); - ResolvedArtifactKey artifactKey = entry.getValue(); - DefaultAccessRule rule = new DefaultAccessRule(pkg.replace('.', '/') + "/*", false); - logger.debug("Resolved " + pkg + " to " + artifactKey.getId() + " " + artifactKey.getVersion() + " " - + artifactKey.getLocation()); - classpath.add(new DefaultClasspathEntry(null, artifactKey, - Collections.singletonList(artifactKey.getLocation()), List.of(rule))); - } - } - - /** - * Resolves the default OSGi annotation artifacts for this project depending on the projects - * target platform - * - * @param project - * the project to resolve the annotation artifacts for - * @return a mapping of a package name to a resolved artifactkey - */ - public Map getAnnotationArtifacts(ReactorProject project) { - Map map = new LinkedHashMap<>(); - TargetPlatform tp = TychoProjectUtils.getTargetPlatformIfAvailable(project); - if (tp != null) { - for (String annotationPackage : OSGI_ANNOTATION_PACKAGES) { - try { - ArtifactKey annotationJar = tp.resolveArtifact(PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE, - annotationPackage, Version.emptyVersion.toString()); - File location = tp.getArtifactLocation(new DefaultArtifactKey(ArtifactType.TYPE_ECLIPSE_PLUGIN, - annotationJar.getId(), annotationJar.getVersion())); - map.put(annotationPackage, new ResolvedArtifactKey() { - - @Override - public String getVersion() { - return annotationJar.getVersion(); - } - - @Override - public String getType() { - return annotationJar.getType(); - } - - @Override - public String getId() { - return annotationJar.getId(); - } - - @Override - public File getLocation() { - return location; - } - }); - } catch (DependencyResolutionException | IllegalArtifactReferenceException e) { - logger.debug("Cannot find package " + annotationPackage + " in target platform"); - } - } - } - return map; } protected DefaultClasspathEntry addBundleToClasspath(ArtifactDescriptor matchingBundle, String path) { diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/VersioningAnnotationsClasspathContributor.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/VersioningAnnotationsClasspathContributor.java new file mode 100644 index 0000000000..09734dac26 --- /dev/null +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/VersioningAnnotationsClasspathContributor.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich 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: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.core.osgitools; + +import javax.inject.Inject; + +import org.apache.maven.SessionScoped; +import org.apache.maven.execution.MavenSession; +import org.codehaus.plexus.component.annotations.Component; +import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.classpath.ClasspathContributor; +import org.osgi.framework.Version; + +@Component(role = ClasspathContributor.class, hint = "versioning-annotations") +@SessionScoped +public class VersioningAnnotationsClasspathContributor extends AbstractSpecificationClasspathContributor + implements ClasspathContributor { + + private static final String PACKAGE_NAME = "org.osgi.annotation.versioning"; + private static final String GROUP_ID = "org.osgi"; + private static final String ARTIFACT_ID = "org.osgi.annotation.versioning"; + private static final Version VERSION = new Version(1, 0, 0); + + @Inject + protected VersioningAnnotationsClasspathContributor(MavenSession session) { + super(session, PACKAGE_NAME, GROUP_ID, ARTIFACT_ID); + } + + @Override + protected Version getSpecificationVersion(ReactorProject project) { + return VERSION; + } + +} diff --git a/tycho-ds-plugin/pom.xml b/tycho-ds-plugin/pom.xml index 090d75616e..4444bc5330 100644 --- a/tycho-ds-plugin/pom.xml +++ b/tycho-ds-plugin/pom.xml @@ -1,16 +1,14 @@ - 4.0.0 - - org.eclipse.tycho - tycho - 4.0.0-SNAPSHOT - - tycho-ds-plugin - maven-plugin - + 4.0.0 + + org.eclipse.tycho + tycho + 4.0.0-SNAPSHOT + + tycho-ds-plugin + maven-plugin Tycho OSGi Declarative Services Plugin A plugin for handling OSGi Declarative Services - org.apache.maven @@ -34,8 +32,16 @@ ${project.version} - biz.aQute.bnd - biz.aQute.bndlib + biz.aQute.bnd + biz.aQute.bndlib + + + + org.codehaus.plexus + plexus-component-metadata + + + \ No newline at end of file diff --git a/tycho-core/src/main/java/org/eclipse/tycho/artifacts/configuration/DeclarativeServiceConfigurationReader.java b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServiceConfigurationReader.java similarity index 92% rename from tycho-core/src/main/java/org/eclipse/tycho/artifacts/configuration/DeclarativeServiceConfigurationReader.java rename to tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServiceConfigurationReader.java index 88193494a1..824fc9ab52 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/artifacts/configuration/DeclarativeServiceConfigurationReader.java +++ b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServiceConfigurationReader.java @@ -10,12 +10,13 @@ * Contributors: * Christoph Läubrich - initial API and implementation *******************************************************************************/ -package org.eclipse.tycho.artifacts.configuration; +package org.eclipse.tycho.ds; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; +import java.util.Objects; import java.util.Properties; import org.apache.maven.model.Plugin; @@ -24,6 +25,7 @@ import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.util.xml.Xpp3Dom; +import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.core.DeclarativeServicesConfiguration; import org.osgi.framework.Version; @@ -31,6 +33,7 @@ public class DeclarativeServiceConfigurationReader { private static final String DS_PLUGIN = "org.eclipse.tycho:tycho-ds-plugin"; + public static final String DEFAULT_ENABLED = "false"; public static final String DEFAULT_ADD_TO_CLASSPATH = "true"; public static final String DEFAULT_DS_VERSION = "1.3"; public static final String DEFAULT_PATH = "OSGI-INF"; @@ -44,10 +47,14 @@ public class DeclarativeServiceConfigurationReader { @Requirement private Logger logger; + public DeclarativeServicesConfiguration getConfiguration(ReactorProject reactorProject) throws IOException { + return getConfiguration(Objects.requireNonNull(reactorProject.adapt(MavenProject.class))); + } + public DeclarativeServicesConfiguration getConfiguration(MavenProject mavenProject) throws IOException { Properties settings = getProjectSettings(mavenProject.getBasedir(), getMojoSettings(mavenProject, logger), mavenProject, logger); - if (Boolean.parseBoolean(settings.getProperty(PROPERTY_ENABLED))) { + if (Boolean.parseBoolean(settings.getProperty(PROPERTY_ENABLED, DEFAULT_ENABLED))) { return new DeclarativeServicesConfiguration() { @Override @@ -120,4 +127,5 @@ private static void setProperty(Properties properties, String key, Xpp3Dom xpp3D } } } + } diff --git a/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesClasspathContributor.java b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesClasspathContributor.java new file mode 100644 index 0000000000..0f0af0580a --- /dev/null +++ b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesClasspathContributor.java @@ -0,0 +1,60 @@ +/******************************************************************************* + * Copyright (c) 2023 Christoph Läubrich 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: + * Christoph Läubrich - initial API and implementation + *******************************************************************************/ +package org.eclipse.tycho.ds; + +import java.io.IOException; + +import javax.inject.Inject; + +import org.apache.maven.SessionScoped; +import org.apache.maven.execution.MavenSession; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.classpath.ClasspathContributor; +import org.eclipse.tycho.core.DeclarativeServicesConfiguration; +import org.eclipse.tycho.core.osgitools.AbstractSpecificationClasspathContributor; +import org.osgi.framework.Version; + +@Component(role = ClasspathContributor.class, hint = "ds-annotations") +@SessionScoped +public class DeclarativeServicesClasspathContributor extends AbstractSpecificationClasspathContributor + implements ClasspathContributor { + + private static final String DS_ANNOTATIONS_PACKAGE = "org.osgi.service.component.annotations"; + + private static final String DS_ANNOTATIONS_GROUP_ID = "org.osgi"; + private static final String DS_ANNOTATIONS_ARTIFACT_ID = "org.osgi.service.component.annotations"; + + @Requirement + DeclarativeServiceConfigurationReader configurationReader; + + @Inject + public DeclarativeServicesClasspathContributor(MavenSession session) { + super(session, DS_ANNOTATIONS_PACKAGE, DS_ANNOTATIONS_GROUP_ID, DS_ANNOTATIONS_ARTIFACT_ID); + } + + @Override + protected Version getSpecificationVersion(ReactorProject project) { + try { + DeclarativeServicesConfiguration configuration = configurationReader.getConfiguration(project); + if (configuration != null) { + return configuration.getSpecificationVersion(); + } + } catch (IOException e) { + // can't determine the minimum specification version then... + } + return Version.parseVersion(DeclarativeServiceConfigurationReader.DEFAULT_DS_VERSION); + } + +} diff --git a/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java index 74d1ef6aca..275616c2f8 100644 --- a/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java +++ b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java @@ -26,7 +26,6 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; -import org.eclipse.tycho.artifacts.configuration.DeclarativeServiceConfigurationReader; import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.core.DeclarativeServicesConfiguration; import org.eclipse.tycho.core.TychoProject; @@ -104,11 +103,12 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (projectType instanceof OsgiBundleProject bundleProject) { try { DeclarativeServicesConfiguration configuration = configurationReader.getConfiguration(project); - if (configuration == null) { + File outputDirectory = new File(project.getBuild().getOutputDirectory()); + if (configuration == null || !outputDirectory.exists()) { // nothing to do return; } - File outputDirectory = new File(project.getBuild().getOutputDirectory()); + String childPath = configuration.getPath(); File targetDirectory = new File(outputDirectory, childPath); File projectBaseDir = new File(project.getBasedir(), childPath); diff --git a/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java b/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java new file mode 100644 index 0000000000..6bb3e647b2 --- /dev/null +++ b/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java @@ -0,0 +1,10 @@ +package org.eclipse.tycho.classpath; + +import java.util.List; + +import org.eclipse.tycho.ReactorProject; + +public interface ClasspathContributor { + + List getAdditionalClasspathEntries(ReactorProject reactorProject, String scope); +} diff --git a/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java b/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java index d3084111a9..791de6e131 100644 --- a/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java +++ b/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java @@ -18,6 +18,8 @@ import java.util.Map; import java.util.Set; +import org.apache.maven.artifact.Artifact; +import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; @@ -29,11 +31,13 @@ import org.apache.maven.project.MavenProject; import org.eclipse.tycho.ArtifactDescriptor; import org.eclipse.tycho.ReactorProject; -import org.eclipse.tycho.ResolvedArtifactKey; +import org.eclipse.tycho.classpath.ClasspathContributor; +import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.osgitools.OsgiBundleProject; import org.eclipse.tycho.core.utils.TychoProjectUtils; +import org.eclipse.tycho.p2maven.helper.PluginRealmHelper; /** * Builds a .target file describing the dependencies for current project. It differs from @@ -52,6 +56,12 @@ public class ListDependenciesMojo extends AbstractMojo { @Component(role = TychoProject.class) private Map projectTypes; + @Component + private PluginRealmHelper pluginRealmHelper; + + @Parameter(property = "session", readonly = true) + private MavenSession session; + @Override public void execute() throws MojoExecutionException, MojoFailureException { if (skip) { @@ -67,9 +77,9 @@ public void execute() throws MojoExecutionException, MojoFailureException { } Set written = new HashSet<>(); try (BufferedWriter writer = Files.newBufferedWriter(outputFile.toPath())) { - List dependencies = TychoProjectUtils - .getDependencyArtifacts(DefaultReactorProject.adapt(project)).getArtifacts().stream() - .filter(desc -> !desc.getLocation(true).equals(project.getBasedir())) // remove self + ReactorProject reactorProject = DefaultReactorProject.adapt(project); + List dependencies = TychoProjectUtils.getDependencyArtifacts(reactorProject) + .getArtifacts().stream().filter(desc -> !desc.getLocation(true).equals(project.getBasedir())) // remove self .toList(); for (ArtifactDescriptor dependnecy : dependencies) { if (dependnecy.getMavenProject() == null) { @@ -82,10 +92,25 @@ public void execute() throws MojoExecutionException, MojoFailureException { } TychoProject projectType = projectTypes.get(project.getPackaging()); if (projectType instanceof OsgiBundleProject bundleProject) { - Map artifacts = bundleProject - .getAnnotationArtifacts(DefaultReactorProject.adapt(project)); - for (ResolvedArtifactKey artifactDescriptor : artifacts.values()) { - writeLocation(writer, artifactDescriptor.getLocation(), written); + + try { + pluginRealmHelper.visitPluginExtensions(session, project, ClasspathContributor.class, cpc -> { + List list = cpc.getAdditionalClasspathEntries(reactorProject, + Artifact.SCOPE_COMPILE); + if (list != null && !list.isEmpty()) { + for (ClasspathEntry entry : list) { + for (File locations : entry.getLocations()) { + try { + writeLocation(writer, locations, written); + } catch (IOException e) { + //ignore... + } + } + } + } + }); + } catch (Exception e) { + throw new MojoExecutionException("can't call classpath contributors", e); } } } catch (IOException e) { diff --git a/tycho-its/projects/target.artifact.caching/target.test/plugins/osgi.annotation.bundle_0.0.1/META-INF/MANIFEST.MF b/tycho-its/projects/target.artifact.caching/target.test/plugins/osgi.annotation.bundle_0.0.1/META-INF/MANIFEST.MF index fedb9fd278..08c2abab91 100644 --- a/tycho-its/projects/target.artifact.caching/target.test/plugins/osgi.annotation.bundle_0.0.1/META-INF/MANIFEST.MF +++ b/tycho-its/projects/target.artifact.caching/target.test/plugins/osgi.annotation.bundle_0.0.1/META-INF/MANIFEST.MF @@ -4,5 +4,4 @@ Bundle-Name: Bundle Bundle-SymbolicName: osgi.annotation.bundle Bundle-Version: 0.0.1 Bundle-RequiredExecutionEnvironment: J2SE-1.5 -Export-Package: org.osgi.annotation.versioning -Bundle-ClassPath: lib/osgi.annotation-7.0.0.jar \ No newline at end of file +Export-Package: tycho.test.package diff --git a/tycho-its/projects/target.artifact.caching/target.test/plugins/osgi.annotation.bundle_0.0.1/lib/osgi.annotation-7.0.0.jar b/tycho-its/projects/target.artifact.caching/target.test/plugins/osgi.annotation.bundle_0.0.1/lib/osgi.annotation-7.0.0.jar deleted file mode 100644 index 317c0f95ee53cae6dd4e1296185f760e213faccc..0000000000000000000000000000000000000000 GI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$$@9|>y1Bl9Zin_SpndH?*o3);txSkAKZ2l2JXFj z(@FR){MF6nUSDBgEH~*o!2Mxv`n2A{I=~S5qiZYhpg%PM;D3L>P1e9I1R?|VgZb64 zo5nG>&f=;-fbXrp9XMCj+@>ux4;F+zxeBO-&_CvncvU=bb`5q{Et2qfB!+70NpbF zdL{O&VQ{w-0{ra)c-T!di(d`B>F99_%;-QA|LlYDtKk4rK;ZCq!+*5V_!SO(APf&4 z)c+$6prGEb(B0iy@PPgL7Z3kj(LZ$d0LFS#P!_nX{@tym{~xg4=DghW^#G=EQ>O^H zp83t2?prv*{{5K?0H=4{Cv#IA9k^=ljYsJgJ_F3j-(}EWWPX-P2VTn!zkmy2-sRUk z(eD$v4Uykp$PK@MYppTdt^)8kD?sS|cNYRwU=w%|Hw1u7O5G)3P5b)<{s`9m-3owf z`rHJqZ($oi?{`=5X9VItg`1BJTtVQ*wSEhq0H5V|DFEGNf4m#G&nVz0+;?|w6Zij# z%Fo&az+`UTg9AU-y-OyO@At{vu}ALn?7mvPu_SMSK=3!n02!IU3%GgW2K@N#CWZVK z-2WryJJ+!Li?|^L{CMOpsYucPxQP32>ws5v^BM&>W&Z9SYmoeJr2aI@?=R>k{T?{g z`R;-kUj8>KzuW*f#u#vJ=S}YPEiB3bXHo+*;{L|DYY3_;{d7Dgg*wc68`nUyX zn}0=iM`!=fTyM|=d$;bQH?aLz^#AKT1l}4q=z(22celo{-M^y$Q#b$Z#DN_ocPGy2 d@UNKv?i+#uo>c&f1OWc%B0YE@;&}6~{|8GHAeR6D diff --git a/tycho-its/projects/target.artifact.caching/test.bundle/META-INF/MANIFEST.MF b/tycho-its/projects/target.artifact.caching/test.bundle/META-INF/MANIFEST.MF index 19329ff87e..159368a3fa 100644 --- a/tycho-its/projects/target.artifact.caching/test.bundle/META-INF/MANIFEST.MF +++ b/tycho-its/projects/target.artifact.caching/test.bundle/META-INF/MANIFEST.MF @@ -5,4 +5,4 @@ Bundle-SymbolicName: test.bundle Bundle-Version: 0.0.1.qualifier Automatic-Module-Name: test.bundle Bundle-RequiredExecutionEnvironment: JavaSE-11 -Require-Bundle: osgi.annotation.bundle;bundle-version="0.0.1" \ No newline at end of file +Import-Package: tycho.test.package diff --git a/tycho-its/projects/target.artifact.caching/test.bundle/src/test/TestClass.java b/tycho-its/projects/target.artifact.caching/test.bundle/src/test/TestClass.java deleted file mode 100644 index f581d670c5..0000000000 --- a/tycho-its/projects/target.artifact.caching/test.bundle/src/test/TestClass.java +++ /dev/null @@ -1,7 +0,0 @@ -package test; - -import org.osgi.annotation.versioning.Version; - -public class TestClass { - -} diff --git a/tycho-its/projects/tycho-ds/pom.xml b/tycho-its/projects/tycho-ds/pom.xml index 12468e7d5f..337e53607d 100644 --- a/tycho-its/projects/tycho-ds/pom.xml +++ b/tycho-its/projects/tycho-ds/pom.xml @@ -17,6 +17,29 @@ ${repo-url}
+ + + filtered + + + + org.eclipse.tycho + target-platform-configuration + ${tycho-version} + + + + java-package + org.osgi.service.component.annotations + + + + + + + + + diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/compiler/CompilerClasspathEntryTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/compiler/CompilerClasspathEntryTest.java index 614de7f22d..299c594fe3 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/compiler/CompilerClasspathEntryTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/compiler/CompilerClasspathEntryTest.java @@ -20,6 +20,7 @@ import java.util.List; import java.util.stream.Collectors; +import org.apache.maven.it.VerificationException; import org.apache.maven.it.Verifier; import org.eclipse.tycho.test.AbstractTychoIntegrationTest; import org.eclipse.tycho.test.util.EnvironmentUtil; @@ -52,7 +53,15 @@ public void testLibEntry() throws Exception { public void testDSComponents() throws Exception { Verifier verifier = getVerifier("tycho-ds", false, true); verifier.setSystemProperty("repo-url", EnvironmentUtil.ECLIPSE_LATEST); - verifier.executeGoal("verify"); + // first test to consume from target platform + verifyDs(verifier); + // now test consume from maven directly + verifier.addCliOption("-Pfiltered"); + verifyDs(verifier); + } + + private void verifyDs(Verifier verifier) throws VerificationException { + verifier.executeGoals(List.of("clean", "verify")); verifier.verifyErrorFreeLog(); File generated = new File(verifier.getBasedir(), "target/classes/OSGI-INF"); assertTrue(new File(generated, "tycho.ds.TestComponent.xml").isFile()); diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/target/TargetPlatformLocationsTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/target/TargetPlatformLocationsTest.java index 29614e8df7..9b276eb97d 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/target/TargetPlatformLocationsTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/target/TargetPlatformLocationsTest.java @@ -110,7 +110,7 @@ public void testTargetPlatformArtifactCaching() throws Exception { "target.test/plugins/osgi.annotation.bundle_0.0.1/META-INF/MANIFEST.MF"); DefaultBundleReader reader = new DefaultBundleReader(); OsgiManifest annotBundleManifest = reader.loadManifest(annotBundleManifestFile); - Assert.assertEquals("org.osgi.annotation.versioning", annotBundleManifest.getValue("Export-Package")); + Assert.assertEquals("tycho.test.package", annotBundleManifest.getValue("Export-Package")); verifier.executeGoal("verify"); verifier.verifyErrorFreeLog(); @@ -121,10 +121,10 @@ public void testTargetPlatformArtifactCaching() throws Exception { try { verifier.executeGoal("verify"); - Assert.fail("Reference to the restricted package did not fail the build"); + Assert.fail("Reference to the not exported package did not fail the build"); } catch (VerificationException expected) { verifier.verifyTextInLog( - "Access restriction: The type 'Version' is not API (restriction on classpath entry"); + " Missing requirement: test.bundle 0.0.1.qualifier requires 'java.package; tycho.test.package 0.0.0' but it could not be found"); } } From f9bf302e89e273bdd0928c566ded6fbd8cc0bc68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Wed, 4 Jan 2023 08:59:33 +0100 Subject: [PATCH 13/19] Rename tycho-embedder-api to tycho spi Fix https://github.com/eclipse-tycho/tycho/issues/1696 --- p2-maven-plugin/pom.xml | 2 +- .../tycho/p2maven/helper/PluginRealmHelper.java | 4 ++-- pom.xml | 2 +- tycho-build/pom.xml | 2 +- tycho-buildtimestamp-jgit/pom.xml | 2 +- .../org.eclipse.tycho.embedder.shared/pom.xml | 2 +- .../main/java/org/eclipse/tycho}/ClasspathEntry.java | 5 +---- .../main/java/org/eclipse/tycho}/SourcepathEntry.java | 2 +- .../tycho/compiler/AbstractOsgiCompilerMojo.java | 6 +++--- .../tycho/compiler/JavaCompilerConfiguration.java | 4 ++-- .../org/eclipse/tycho/compiler/OsgiCompilerMojo.java | 2 +- .../eclipse/tycho/compiler/OsgiTestCompilerMojo.java | 2 +- .../tycho/osgicompiler/test/OsgiCompilerTest.java | 2 +- tycho-core/pom.xml | 2 +- .../java/org/eclipse/tycho/core/BundleProject.java | 4 ++-- .../AbstractSpecificationClasspathContributor.java | 4 ++-- .../eclipse/tycho/core/osgitools/BundleClassPath.java | 4 ++-- .../tycho/core/osgitools/DefaultClasspathEntry.java | 2 +- .../tycho/core/osgitools/DependencyComputer.java | 2 +- .../tycho/core/osgitools/OsgiBundleProject.java | 4 ++-- .../tycho/core/test/DependencyComputerTest.java | 2 +- .../java/org/eclipse/tycho/core/test/TychoTest.java | 2 +- .../org/eclipse/tycho/ds/DeclarativeServicesMojo.java | 2 +- .../tycho/extras/pde/ListDependenciesMojo.java | 2 +- .../eclipse/tycho/extras/docbundle/JavadocMojo.java | 2 +- {tycho-embedder-api => tycho-spi}/.gitignore | 0 .../.settings/org.eclipse.jdt.core.prefs | 0 .../.settings/org.eclipse.jdt.ui.prefs | 0 {tycho-embedder-api => tycho-spi}/pom.xml | 11 +++-------- .../eclipse/tycho/build/BuildTimestampProvider.java | 0 .../eclipse/tycho/classpath/ClasspathContributor.java | 1 + .../org/eclipse/tycho/resolver/TychoResolver.java | 0 .../tycho/surefire/TychoIntegrationTestMojo.java | 2 +- .../surefire/provider/impl/AbstractJUnitProvider.java | 2 +- .../tycho/surefire/provider/impl/JUnit47Provider.java | 2 +- .../tycho/surefire/provider/impl/JUnit57Provider.java | 2 +- .../provider/impl/JUnit57WithVintageProvider.java | 2 +- .../tycho/surefire/provider/impl/JUnit58Provider.java | 2 +- .../provider/impl/JUnit58WithVintageProvider.java | 2 +- .../tycho/surefire/provider/impl/JUnit59Provider.java | 2 +- .../provider/impl/JUnit59WithVintageProvider.java | 2 +- .../provider/impl/NoopTestFrameworkProvider.java | 2 +- .../tycho/surefire/provider/impl/ProviderHelper.java | 2 +- .../tycho/surefire/provider/impl/TestNGProvider.java | 2 +- .../surefire/provider/spi/TestFrameworkProvider.java | 2 +- .../provider/impl/AbstractJUnitProviderTest.java | 2 +- .../surefire/provider/impl/ProviderHelperTest.java | 2 +- tycho-testing-harness/pom.xml | 2 +- 48 files changed, 53 insertions(+), 60 deletions(-) rename {tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath => tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho}/ClasspathEntry.java (93%) rename {tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath => tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho}/SourcepathEntry.java (96%) rename {tycho-embedder-api => tycho-spi}/.gitignore (100%) rename {tycho-embedder-api => tycho-spi}/.settings/org.eclipse.jdt.core.prefs (100%) rename {tycho-embedder-api => tycho-spi}/.settings/org.eclipse.jdt.ui.prefs (100%) rename {tycho-embedder-api => tycho-spi}/pom.xml (85%) rename {tycho-embedder-api => tycho-spi}/src/main/java/org/eclipse/tycho/build/BuildTimestampProvider.java (100%) rename {tycho-embedder-api => tycho-spi}/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java (85%) rename {tycho-embedder-api => tycho-spi}/src/main/java/org/eclipse/tycho/resolver/TychoResolver.java (100%) diff --git a/p2-maven-plugin/pom.xml b/p2-maven-plugin/pom.xml index a70d961026..d3a8ae2647 100644 --- a/p2-maven-plugin/pom.xml +++ b/p2-maven-plugin/pom.xml @@ -104,7 +104,7 @@ org.eclipse.tycho - tycho-embedder-api + tycho-spi ${project.version} diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java index 3cdb49014c..43f42ddc29 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java @@ -166,12 +166,12 @@ public void execute(MavenSession session, MavenProject project, Runnable runnabl } private static boolean isTychoEmbedderPlugin(PluginDescriptor pluginDescriptor) { - if (pluginDescriptor.getArtifactMap().containsKey("org.eclipse.tycho:tycho-embedder-api")) { + if (pluginDescriptor.getArtifactMap().containsKey("org.eclipse.tycho:tycho-spi")) { return true; } for (ComponentDependency dependency : pluginDescriptor.getDependencies()) { if ("org.eclipse.tycho".equals(dependency.getGroupId()) - && "tycho-embedder-api".equals(dependency.getArtifactId())) { + && "tycho-spi".equals(dependency.getArtifactId())) { return true; } } diff --git a/pom.xml b/pom.xml index 0d9d446809..6064e2a799 100644 --- a/pom.xml +++ b/pom.xml @@ -507,7 +507,7 @@ sisu-osgi p2-maven-plugin tycho-metadata-model - tycho-embedder-api + tycho-spi tycho-core tycho-testing-harness tycho-compiler-jdt diff --git a/tycho-build/pom.xml b/tycho-build/pom.xml index 90aac68344..cc78e78d72 100644 --- a/tycho-build/pom.xml +++ b/tycho-build/pom.xml @@ -42,7 +42,7 @@ org.eclipse.tycho - tycho-embedder-api + tycho-spi ${project.version} diff --git a/tycho-buildtimestamp-jgit/pom.xml b/tycho-buildtimestamp-jgit/pom.xml index 09f8af6d99..bbe70c3ca7 100644 --- a/tycho-buildtimestamp-jgit/pom.xml +++ b/tycho-buildtimestamp-jgit/pom.xml @@ -33,7 +33,7 @@ org.eclipse.tycho - tycho-embedder-api + tycho-spi ${project.version} diff --git a/tycho-bundles/org.eclipse.tycho.embedder.shared/pom.xml b/tycho-bundles/org.eclipse.tycho.embedder.shared/pom.xml index e27a8da2e8..598699f5dc 100644 --- a/tycho-bundles/org.eclipse.tycho.embedder.shared/pom.xml +++ b/tycho-bundles/org.eclipse.tycho.embedder.shared/pom.xml @@ -24,7 +24,7 @@ jar Tycho Embedder API Maven/OSGi Shared Classes - Classes shared between the tycho-embedder-api module and Tycho's OSGi bundles. + Classes shared between the tycho-spi module and Tycho's OSGi bundles. org.eclipse.platform diff --git a/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathEntry.java b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/ClasspathEntry.java similarity index 93% rename from tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathEntry.java rename to tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/ClasspathEntry.java index 2478a8114d..829984868c 100644 --- a/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathEntry.java +++ b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/ClasspathEntry.java @@ -10,15 +10,12 @@ * Contributors: * Sonatype Inc. - initial API and implementation *******************************************************************************/ -package org.eclipse.tycho.classpath; +package org.eclipse.tycho; import java.io.File; import java.util.Collection; import java.util.List; -import org.eclipse.tycho.ArtifactKey; -import org.eclipse.tycho.ReactorProject; - /** * @author igor * @noimplement This interface is not intended to be implemented by clients. diff --git a/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/SourcepathEntry.java b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/SourcepathEntry.java similarity index 96% rename from tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/SourcepathEntry.java rename to tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/SourcepathEntry.java index 95817058d8..f67b29eb28 100644 --- a/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/SourcepathEntry.java +++ b/tycho-bundles/org.eclipse.tycho.embedder.shared/src/main/java/org/eclipse/tycho/SourcepathEntry.java @@ -10,7 +10,7 @@ * Contributors: * Sonatype Inc. - initial API and implementation *******************************************************************************/ -package org.eclipse.tycho.classpath; +package org.eclipse.tycho; import java.io.File; import java.util.List; diff --git a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java index c3ceb506a6..ebab6e3cdc 100644 --- a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java @@ -66,12 +66,12 @@ import org.eclipse.jdt.internal.compiler.util.JRTUtil; import org.eclipse.osgi.util.ManifestElement; import org.eclipse.tycho.ArtifactKey; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.SourcepathEntry; +import org.eclipse.tycho.ClasspathEntry.AccessRule; import org.eclipse.tycho.classpath.ClasspathContributor; -import org.eclipse.tycho.classpath.ClasspathEntry; -import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; -import org.eclipse.tycho.classpath.SourcepathEntry; import org.eclipse.tycho.core.BundleProject; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.dotClasspath.JREClasspathEntry; diff --git a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/JavaCompilerConfiguration.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/JavaCompilerConfiguration.java index 6e9b573318..53a27ae9dd 100644 --- a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/JavaCompilerConfiguration.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/JavaCompilerConfiguration.java @@ -15,8 +15,8 @@ import java.util.List; import org.apache.maven.plugin.MojoExecutionException; -import org.eclipse.tycho.classpath.ClasspathEntry; -import org.eclipse.tycho.classpath.SourcepathEntry; +import org.eclipse.tycho.ClasspathEntry; +import org.eclipse.tycho.SourcepathEntry; /** * Computes and returns Tycho java compiler configuration, i.e. compile or test-compile mojos of diff --git a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiCompilerMojo.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiCompilerMojo.java index ebb7d07495..31e101dd73 100644 --- a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiCompilerMojo.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiCompilerMojo.java @@ -25,7 +25,7 @@ import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; -import org.eclipse.tycho.classpath.SourcepathEntry; +import org.eclipse.tycho.SourcepathEntry; import org.eclipse.tycho.core.osgitools.project.BuildOutputJar; /** diff --git a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiTestCompilerMojo.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiTestCompilerMojo.java index 4729aa8f5f..90b882fb03 100644 --- a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiTestCompilerMojo.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/OsgiTestCompilerMojo.java @@ -27,7 +27,7 @@ import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.ResolutionScope; import org.eclipse.tycho.ReactorProject; -import org.eclipse.tycho.classpath.SourcepathEntry; +import org.eclipse.tycho.SourcepathEntry; import org.eclipse.tycho.core.dotClasspath.SourceFolderClasspathEntry; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; diff --git a/tycho-compiler-plugin/src/test/java/org/eclipse/tycho/osgicompiler/test/OsgiCompilerTest.java b/tycho-compiler-plugin/src/test/java/org/eclipse/tycho/osgicompiler/test/OsgiCompilerTest.java index a7e576665e..e948f3479a 100644 --- a/tycho-compiler-plugin/src/test/java/org/eclipse/tycho/osgicompiler/test/OsgiCompilerTest.java +++ b/tycho-compiler-plugin/src/test/java/org/eclipse/tycho/osgicompiler/test/OsgiCompilerTest.java @@ -34,7 +34,7 @@ import org.apache.maven.plugin.logging.SystemStreamLog; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.util.FileUtils; -import org.eclipse.tycho.classpath.SourcepathEntry; +import org.eclipse.tycho.SourcepathEntry; import org.eclipse.tycho.compiler.AbstractOsgiCompilerMojo; import org.eclipse.tycho.core.ee.StandardExecutionEnvironment; import org.eclipse.tycho.testing.AbstractTychoMojoTestCase; diff --git a/tycho-core/pom.xml b/tycho-core/pom.xml index 58b056bc2b..38c22ece2b 100644 --- a/tycho-core/pom.xml +++ b/tycho-core/pom.xml @@ -208,7 +208,7 @@ org.eclipse.tycho - tycho-embedder-api + tycho-spi ${project.version} diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/BundleProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/BundleProject.java index dfc387751a..87107e10df 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/BundleProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/BundleProject.java @@ -16,9 +16,9 @@ import org.apache.maven.project.MavenProject; import org.eclipse.tycho.ArtifactKey; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.ReactorProject; -import org.eclipse.tycho.classpath.ClasspathEntry; -import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; +import org.eclipse.tycho.ClasspathEntry.AccessRule; import org.eclipse.tycho.core.osgitools.project.EclipsePluginProject; public interface BundleProject extends TychoProject { diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractSpecificationClasspathContributor.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractSpecificationClasspathContributor.java index a28222c0c6..eaf3c90a03 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractSpecificationClasspathContributor.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractSpecificationClasspathContributor.java @@ -24,14 +24,14 @@ import org.eclipse.aether.resolution.ArtifactResolutionException; import org.eclipse.aether.resolution.VersionRangeResolutionException; import org.eclipse.tycho.ArtifactKey; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.DependencyResolutionException; import org.eclipse.tycho.IllegalArtifactReferenceException; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.ResolvedArtifactKey; import org.eclipse.tycho.TargetPlatform; +import org.eclipse.tycho.ClasspathEntry.AccessRule; import org.eclipse.tycho.classpath.ClasspathContributor; -import org.eclipse.tycho.classpath.ClasspathEntry; -import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; import org.eclipse.tycho.core.TychoProjectManager; import org.eclipse.tycho.core.maven.MavenDependenciesResolver; import org.eclipse.tycho.core.osgitools.DefaultClasspathEntry.DefaultAccessRule; diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleClassPath.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleClassPath.java index 6ec2135df4..2ebd499230 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleClassPath.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleClassPath.java @@ -15,8 +15,8 @@ import java.util.Collections; import java.util.List; -import org.eclipse.tycho.classpath.ClasspathEntry; -import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; +import org.eclipse.tycho.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry.AccessRule; public class BundleClassPath { diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultClasspathEntry.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultClasspathEntry.java index 7be6b3c42c..7058a6b59e 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultClasspathEntry.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultClasspathEntry.java @@ -20,9 +20,9 @@ import javax.annotation.Nonnull; import org.eclipse.tycho.ArtifactKey; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.ResolvedArtifactKey; -import org.eclipse.tycho.classpath.ClasspathEntry; public class DefaultClasspathEntry implements ClasspathEntry { private final ReactorProject project; diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DependencyComputer.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DependencyComputer.java index 0c2554e3cd..2f11d01cb9 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DependencyComputer.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DependencyComputer.java @@ -34,7 +34,7 @@ import org.eclipse.osgi.container.ModuleRevision; import org.eclipse.osgi.container.ModuleWire; import org.eclipse.osgi.container.ModuleWiring; -import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; +import org.eclipse.tycho.ClasspathEntry.AccessRule; import org.eclipse.tycho.core.osgitools.DefaultClasspathEntry.DefaultAccessRule; import org.osgi.framework.Constants; import org.osgi.framework.namespace.BundleNamespace; 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 d7f1288057..f1614d6866 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 @@ -49,6 +49,7 @@ import org.eclipse.tycho.ArtifactKey; import org.eclipse.tycho.ArtifactType; import org.eclipse.tycho.BuildPropertiesParser; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.DependencyArtifacts; import org.eclipse.tycho.PackagingType; @@ -57,8 +58,7 @@ import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.TargetPlatform; import org.eclipse.tycho.TychoConstants; -import org.eclipse.tycho.classpath.ClasspathEntry; -import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; +import org.eclipse.tycho.ClasspathEntry.AccessRule; import org.eclipse.tycho.core.ArtifactDependencyVisitor; import org.eclipse.tycho.core.ArtifactDependencyWalker; import org.eclipse.tycho.core.BundleProject; diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/test/DependencyComputerTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/test/DependencyComputerTest.java index 3df64db4eb..89da6ed1d5 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/core/test/DependencyComputerTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/core/test/DependencyComputerTest.java @@ -35,7 +35,7 @@ import org.eclipse.tycho.DependencyArtifacts; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.TychoConstants; -import org.eclipse.tycho.classpath.ClasspathEntry.AccessRule; +import org.eclipse.tycho.ClasspathEntry.AccessRule; import org.eclipse.tycho.core.ee.CustomExecutionEnvironment; import org.eclipse.tycho.core.ee.ExecutionEnvironmentUtils; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironment; diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/test/TychoTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/test/TychoTest.java index 00db74276b..14a196b306 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/core/test/TychoTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/core/test/TychoTest.java @@ -22,9 +22,9 @@ import org.apache.maven.project.MavenProject; import org.codehaus.plexus.logging.Logger; import org.eclipse.tycho.ArtifactType; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.DependencyArtifacts; import org.eclipse.tycho.TargetEnvironment; -import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.core.TargetPlatformConfiguration; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; diff --git a/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java index 275616c2f8..eb22f3ce8c 100644 --- a/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java +++ b/tycho-ds-plugin/src/main/java/org/eclipse/tycho/ds/DeclarativeServicesMojo.java @@ -26,7 +26,7 @@ import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.core.DeclarativeServicesConfiguration; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; diff --git a/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java b/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java index 791de6e131..e3f052d135 100644 --- a/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java +++ b/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java @@ -30,9 +30,9 @@ import org.apache.maven.plugins.annotations.ResolutionScope; import org.apache.maven.project.MavenProject; import org.eclipse.tycho.ArtifactDescriptor; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.classpath.ClasspathContributor; -import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.osgitools.OsgiBundleProject; diff --git a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/JavadocMojo.java b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/JavadocMojo.java index cc660dd427..6a556fc893 100644 --- a/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/JavadocMojo.java +++ b/tycho-extras/tycho-document-bundle-plugin/src/main/java/org/eclipse/tycho/extras/docbundle/JavadocMojo.java @@ -33,7 +33,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.toolchain.ToolchainManager; import org.codehaus.plexus.util.FileUtils; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.core.BundleProject; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.osgitools.BundleReader; diff --git a/tycho-embedder-api/.gitignore b/tycho-spi/.gitignore similarity index 100% rename from tycho-embedder-api/.gitignore rename to tycho-spi/.gitignore diff --git a/tycho-embedder-api/.settings/org.eclipse.jdt.core.prefs b/tycho-spi/.settings/org.eclipse.jdt.core.prefs similarity index 100% rename from tycho-embedder-api/.settings/org.eclipse.jdt.core.prefs rename to tycho-spi/.settings/org.eclipse.jdt.core.prefs diff --git a/tycho-embedder-api/.settings/org.eclipse.jdt.ui.prefs b/tycho-spi/.settings/org.eclipse.jdt.ui.prefs similarity index 100% rename from tycho-embedder-api/.settings/org.eclipse.jdt.ui.prefs rename to tycho-spi/.settings/org.eclipse.jdt.ui.prefs diff --git a/tycho-embedder-api/pom.xml b/tycho-spi/pom.xml similarity index 85% rename from tycho-embedder-api/pom.xml rename to tycho-spi/pom.xml index 805cb46b77..d2c07ea4b7 100644 --- a/tycho-embedder-api/pom.xml +++ b/tycho-spi/pom.xml @@ -19,14 +19,10 @@ tycho 4.0.0-SNAPSHOT - tycho-embedder-api - - Tycho Embedder API - - - 0.11.0 - + tycho-spi + Tycho Service Provider Interfaces + This contains interfaces that might be used to enahnce Tycho itself with plugins org.apache.maven @@ -38,5 +34,4 @@ ${project.version} - diff --git a/tycho-embedder-api/src/main/java/org/eclipse/tycho/build/BuildTimestampProvider.java b/tycho-spi/src/main/java/org/eclipse/tycho/build/BuildTimestampProvider.java similarity index 100% rename from tycho-embedder-api/src/main/java/org/eclipse/tycho/build/BuildTimestampProvider.java rename to tycho-spi/src/main/java/org/eclipse/tycho/build/BuildTimestampProvider.java diff --git a/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java b/tycho-spi/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java similarity index 85% rename from tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java rename to tycho-spi/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java index 6bb3e647b2..4f00a1f097 100644 --- a/tycho-embedder-api/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java +++ b/tycho-spi/src/main/java/org/eclipse/tycho/classpath/ClasspathContributor.java @@ -2,6 +2,7 @@ import java.util.List; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.ReactorProject; public interface ClasspathContributor { diff --git a/tycho-embedder-api/src/main/java/org/eclipse/tycho/resolver/TychoResolver.java b/tycho-spi/src/main/java/org/eclipse/tycho/resolver/TychoResolver.java similarity index 100% rename from tycho-embedder-api/src/main/java/org/eclipse/tycho/resolver/TychoResolver.java rename to tycho-spi/src/main/java/org/eclipse/tycho/resolver/TychoResolver.java diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TychoIntegrationTestMojo.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TychoIntegrationTestMojo.java index 60415f6cf3..d946b61542 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TychoIntegrationTestMojo.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/TychoIntegrationTestMojo.java @@ -38,9 +38,9 @@ import org.apache.maven.surefire.booter.PropertiesWrapper; import org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription; import org.eclipse.tycho.BuildPropertiesParser; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.PackagingType; import org.eclipse.tycho.ReactorProject; -import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.surefire.provider.impl.NoopTestFrameworkProvider; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/AbstractJUnitProvider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/AbstractJUnitProvider.java index 2f19a28a83..36b7a3c83d 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/AbstractJUnitProvider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/AbstractJUnitProvider.java @@ -18,7 +18,7 @@ import java.util.Set; import org.eclipse.tycho.ArtifactKey; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; import org.osgi.framework.VersionRange; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java index b36a48e8a5..3df81eabda 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit47Provider.java @@ -25,7 +25,7 @@ import org.apache.maven.model.Dependency; import org.apache.maven.surefire.api.booter.ProviderParameterNames; import org.codehaus.plexus.component.annotations.Component; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; import org.osgi.framework.VersionRange; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit57Provider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit57Provider.java index 9c791c1aeb..91eeb4c8ee 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit57Provider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit57Provider.java @@ -22,7 +22,7 @@ import org.apache.maven.model.Dependency; import org.codehaus.plexus.component.annotations.Component; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; import org.osgi.framework.VersionRange; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit57WithVintageProvider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit57WithVintageProvider.java index 572b6a68cd..70c6f56638 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit57WithVintageProvider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit57WithVintageProvider.java @@ -22,7 +22,7 @@ import org.apache.maven.model.Dependency; import org.codehaus.plexus.component.annotations.Component; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; import org.osgi.framework.VersionRange; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit58Provider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit58Provider.java index cf618f3649..2276a175f3 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit58Provider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit58Provider.java @@ -22,7 +22,7 @@ import org.apache.maven.model.Dependency; import org.codehaus.plexus.component.annotations.Component; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; import org.osgi.framework.VersionRange; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit58WithVintageProvider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit58WithVintageProvider.java index a1a8599d84..a95aeedf9b 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit58WithVintageProvider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit58WithVintageProvider.java @@ -22,7 +22,7 @@ import org.apache.maven.model.Dependency; import org.codehaus.plexus.component.annotations.Component; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; import org.osgi.framework.VersionRange; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit59Provider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit59Provider.java index 02370d2233..d3dcf95da5 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit59Provider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit59Provider.java @@ -22,7 +22,7 @@ import org.apache.maven.model.Dependency; import org.codehaus.plexus.component.annotations.Component; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; import org.osgi.framework.VersionRange; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit59WithVintageProvider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit59WithVintageProvider.java index 46d19aef0b..98162b5c23 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit59WithVintageProvider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/JUnit59WithVintageProvider.java @@ -22,7 +22,7 @@ import org.apache.maven.model.Dependency; import org.codehaus.plexus.component.annotations.Component; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; import org.osgi.framework.VersionRange; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/NoopTestFrameworkProvider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/NoopTestFrameworkProvider.java index bec1778e22..bdc8d2d42a 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/NoopTestFrameworkProvider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/NoopTestFrameworkProvider.java @@ -17,7 +17,7 @@ import java.util.Properties; import org.apache.maven.model.Dependency; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelper.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelper.java index 40a38a703e..d7e575c6ef 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelper.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelper.java @@ -27,7 +27,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.core.osgitools.BundleReader; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/TestNGProvider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/TestNGProvider.java index d827a5cf59..31fbe9e635 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/TestNGProvider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/impl/TestNGProvider.java @@ -21,7 +21,7 @@ import org.apache.maven.model.Dependency; import org.codehaus.plexus.component.annotations.Component; import org.eclipse.tycho.ArtifactKey; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; diff --git a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/spi/TestFrameworkProvider.java b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/spi/TestFrameworkProvider.java index 7c9fd94549..3b24d5a71d 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/spi/TestFrameworkProvider.java +++ b/tycho-surefire/tycho-surefire-plugin/src/main/java/org/eclipse/tycho/surefire/provider/spi/TestFrameworkProvider.java @@ -18,7 +18,7 @@ import org.apache.maven.model.Dependency; import org.codehaus.plexus.component.annotations.Component; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.osgi.framework.Version; /** diff --git a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/AbstractJUnitProviderTest.java b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/AbstractJUnitProviderTest.java index e2150912a3..9189c2eb32 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/AbstractJUnitProviderTest.java +++ b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/AbstractJUnitProviderTest.java @@ -20,8 +20,8 @@ import java.util.List; import org.eclipse.tycho.ArtifactType; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.DefaultArtifactKey; -import org.eclipse.tycho.classpath.ClasspathEntry; import org.eclipse.tycho.core.osgitools.DefaultClasspathEntry; import org.junit.Before; import org.junit.Test; diff --git a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelperTest.java b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelperTest.java index dcde626d8a..61d069d943 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelperTest.java +++ b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelperTest.java @@ -30,7 +30,7 @@ import org.apache.maven.plugin.MojoExecutionException; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.PlexusTestCase; -import org.eclipse.tycho.classpath.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; import org.osgi.framework.Version; diff --git a/tycho-testing-harness/pom.xml b/tycho-testing-harness/pom.xml index 65d9857ff7..5ea676a083 100644 --- a/tycho-testing-harness/pom.xml +++ b/tycho-testing-harness/pom.xml @@ -67,7 +67,7 @@ org.eclipse.tycho ${project.version} - tycho-embedder-api + tycho-spi org.eclipse.tycho From a042eb271415e716e659fd68b312419b2f938644 Mon Sep 17 00:00:00 2001 From: Gregor Latuske Date: Wed, 4 Jan 2023 14:21:24 +0100 Subject: [PATCH 14/19] Fix typo in release notes --- RELEASE_NOTES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 9249d1ae8c..be94417be2 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -409,7 +409,7 @@ While for an IDE that might be sufficient as target resolution is only performed - If there is a temporary server outage one might want to fall back to the previous state for this build instead of failing completely. - Build times are often a rare resource one doesn't want to waste waiting for servers, bandwidth might even be limited or you have to pay for it. -Because of this, Tycho now includes a brand new caching P2 transport that allows advanced caching, offline handling and fallback to cache in case of server failures. The transport is enabled by default so nothing has to be done, just in case you want the old behavior you can set `-D=tycho.p2.transport=ecf` beside that the following properties might be interesting: +Because of this, Tycho now includes a brand new caching P2 transport that allows advanced caching, offline handling and fallback to cache in case of server failures. The transport is enabled by default so nothing has to be done, just in case you want the old behavior you can set `-Dtycho.p2.transport=ecf` beside that the following properties might be interesting: #### Force cache-revalidation From 5a4ab46fd4a0c88f39d319761600340fe2a901d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Wed, 4 Jan 2023 11:46:16 +0100 Subject: [PATCH 15/19] Move InstallableUnitProvider to the SPI --- .../tycho/p2maven/InstallableUnitGenerator.java | 13 +++---------- ...latformConfigurationInstallableUnitProvider.java | 2 +- ...alBundleRequirementsInstallableUnitProvider.java | 2 +- .../TestPluginPackagingInstallableUnitProvider.java | 2 +- .../CustomBundleInstallableUnitProvider.java | 2 +- .../tycho/source/SourceInstallableUnitProvider.java | 2 +- .../tycho/resolver}/InstallableUnitProvider.java | 2 +- 7 files changed, 9 insertions(+), 16 deletions(-) rename {p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven => tycho-spi/src/main/java/org/eclipse/tycho/resolver}/InstallableUnitProvider.java (95%) diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java index 4b325ead72..b721ad10e3 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java @@ -37,7 +37,6 @@ import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.Logger; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IStatus; @@ -61,6 +60,7 @@ import org.eclipse.tycho.p2maven.actions.ProductFile2; import org.eclipse.tycho.p2maven.helper.PluginRealmHelper; import org.eclipse.tycho.p2maven.io.MetadataIO; +import org.eclipse.tycho.resolver.InstallableUnitProvider; import org.osgi.framework.Constants; import org.xml.sax.SAXException; @@ -263,15 +263,8 @@ private Collection getProvider(MavenProject project, Ma throws CoreException { Set unitProviders = new HashSet<>(additionalUnitProviders.values()); try { - pluginRealmHelper.execute(mavenSession, project, () -> { - try { - for (InstallableUnitProvider provider : plexus.lookupList(InstallableUnitProvider.class)) { - unitProviders.add(provider); - } - } catch (ComponentLookupException e) { - // ignore, nothing was found... - } - }, InstallableUnitGenerator::hasPluginDependency); + pluginRealmHelper.visitPluginExtensions(mavenSession, project, InstallableUnitProvider.class, + unitProviders::add); } catch (Exception e) { throw new CoreException(Status.error("Can't lookup InstallableUnitProviders", e)); } diff --git a/target-platform-configuration/src/main/java/org/eclipse/tycho/target/TargetPlatformConfigurationInstallableUnitProvider.java b/target-platform-configuration/src/main/java/org/eclipse/tycho/target/TargetPlatformConfigurationInstallableUnitProvider.java index b732cc4ff6..78ee0577ca 100644 --- a/target-platform-configuration/src/main/java/org/eclipse/tycho/target/TargetPlatformConfigurationInstallableUnitProvider.java +++ b/target-platform-configuration/src/main/java/org/eclipse/tycho/target/TargetPlatformConfigurationInstallableUnitProvider.java @@ -37,7 +37,7 @@ import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.TychoProjectManager; import org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader; -import org.eclipse.tycho.p2maven.InstallableUnitProvider; +import org.eclipse.tycho.resolver.InstallableUnitProvider; /** * Provides additional requirements defined in the target platform configuration diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/AdditionalBundleRequirementsInstallableUnitProvider.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/AdditionalBundleRequirementsInstallableUnitProvider.java index 8086913cad..6a267bc041 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/AdditionalBundleRequirementsInstallableUnitProvider.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/AdditionalBundleRequirementsInstallableUnitProvider.java @@ -37,7 +37,7 @@ import org.eclipse.tycho.core.BundleProject; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; -import org.eclipse.tycho.p2maven.InstallableUnitProvider; +import org.eclipse.tycho.resolver.InstallableUnitProvider; /** * This provides P2 visible meta-data for bundles that are not expressed in the manifest (e.g. diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/TestPluginPackagingInstallableUnitProvider.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/TestPluginPackagingInstallableUnitProvider.java index 0cf7d1c98d..b2daeb6121 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/TestPluginPackagingInstallableUnitProvider.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/TestPluginPackagingInstallableUnitProvider.java @@ -30,8 +30,8 @@ import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription; import org.eclipse.equinox.p2.metadata.Version; import org.eclipse.tycho.PackagingType; -import org.eclipse.tycho.p2maven.InstallableUnitProvider; import org.eclipse.tycho.p2resolver.P2ResolverImpl; +import org.eclipse.tycho.resolver.InstallableUnitProvider; /** * This provides P2 visible meta-data for bundles that are not expressed in the manifest (e.g. diff --git a/tycho-extras/tycho-custom-bundle-plugin/src/main/java/org/eclipse/tycho/extras/custombundle/CustomBundleInstallableUnitProvider.java b/tycho-extras/tycho-custom-bundle-plugin/src/main/java/org/eclipse/tycho/extras/custombundle/CustomBundleInstallableUnitProvider.java index ca65ed95b9..f04d589e63 100644 --- a/tycho-extras/tycho-custom-bundle-plugin/src/main/java/org/eclipse/tycho/extras/custombundle/CustomBundleInstallableUnitProvider.java +++ b/tycho-extras/tycho-custom-bundle-plugin/src/main/java/org/eclipse/tycho/extras/custombundle/CustomBundleInstallableUnitProvider.java @@ -22,9 +22,9 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.tycho.OptionalResolutionAction; -import org.eclipse.tycho.p2maven.InstallableUnitProvider; import org.eclipse.tycho.p2maven.InstallableUnitPublisher; import org.eclipse.tycho.p2maven.actions.BundleDependenciesAction; +import org.eclipse.tycho.resolver.InstallableUnitProvider; @Component(role = InstallableUnitProvider.class, hint = "custom-bundle") public class CustomBundleInstallableUnitProvider implements InstallableUnitProvider { diff --git a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceInstallableUnitProvider.java b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceInstallableUnitProvider.java index 0f111566f2..86b205ce30 100644 --- a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceInstallableUnitProvider.java +++ b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceInstallableUnitProvider.java @@ -38,8 +38,8 @@ import org.eclipse.tycho.core.osgitools.BundleReader; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.model.Feature; -import org.eclipse.tycho.p2maven.InstallableUnitProvider; import org.eclipse.tycho.p2maven.InstallableUnitPublisher; +import org.eclipse.tycho.resolver.InstallableUnitProvider; import org.osgi.framework.Constants; /** diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitProvider.java b/tycho-spi/src/main/java/org/eclipse/tycho/resolver/InstallableUnitProvider.java similarity index 95% rename from p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitProvider.java rename to tycho-spi/src/main/java/org/eclipse/tycho/resolver/InstallableUnitProvider.java index 4a7f8ab40f..4813bde1b2 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitProvider.java +++ b/tycho-spi/src/main/java/org/eclipse/tycho/resolver/InstallableUnitProvider.java @@ -1,4 +1,4 @@ -package org.eclipse.tycho.p2maven; +package org.eclipse.tycho.resolver; import java.util.Collection; From 998f4f5f70443935cb6edecce8d6d5faa33130d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Wed, 4 Jan 2023 11:50:34 +0100 Subject: [PATCH 16/19] Move P2MetadataProvider to the SPI --- .../p2maven/InstallableUnitGenerator.java | 9 ----- .../p2resolver/P2DependencyResolver.java | 35 ++++--------------- .../CustomBundleP2MetadataProvider.java | 2 +- .../SourceFeatureP2MetadataProvider.java | 2 +- .../source/SourcesP2MetadataProvider.java | 2 +- .../tycho/resolver}/P2MetadataProvider.java | 2 +- 6 files changed, 11 insertions(+), 41 deletions(-) rename {tycho-core/src/main/java/org/eclipse/tycho/p2resolver => tycho-spi/src/main/java/org/eclipse/tycho/resolver}/P2MetadataProvider.java (97%) diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java index b721ad10e3..17f89216a8 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java @@ -32,7 +32,6 @@ import org.apache.maven.artifact.Artifact; import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager; import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; @@ -285,14 +284,6 @@ private static boolean isCompatible(Collection collection) { return true; } - private static boolean hasPluginDependency(PluginDescriptor pluginDescriptor) { - if (pluginDescriptor.getArtifactMap().containsKey(P2Plugin.KEY)) { - return true; - } - return pluginDescriptor.getDependencies().stream().filter(dep -> P2Plugin.GROUP_ID.equals(dep.getGroupId())) - .filter(dep -> P2Plugin.ARTIFACT_ID.equals(dep.getArtifactId())).findAny().isPresent(); - } - private final class ArtifactUnits { private Collection units; 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 fdf7bfe9d5..672f685a9a 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 @@ -35,14 +35,11 @@ import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.plugin.LegacySupport; -import org.apache.maven.plugin.descriptor.PluginDescriptor; import org.apache.maven.project.MavenProject; import org.apache.maven.repository.RepositorySystem; import org.codehaus.plexus.PlexusContainer; import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.component.repository.ComponentDependency; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; import org.codehaus.plexus.logging.AbstractLogEnabled; import org.codehaus.plexus.logging.Logger; import org.codehaus.plexus.personality.plexus.lifecycle.phase.Initializable; @@ -87,6 +84,7 @@ import org.eclipse.tycho.p2maven.helper.PluginRealmHelper; import org.eclipse.tycho.p2maven.repository.P2ArtifactRepositoryLayout; import org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManager; +import org.eclipse.tycho.resolver.P2MetadataProvider; import org.eclipse.tycho.targetplatform.TargetDefinitionFile; @Component(role = DependencyResolver.class, hint = P2DependencyResolver.ROLE_HINT, instantiationStrategy = "per-lookup") @@ -166,19 +164,13 @@ protected Map getDependencyMetadata(final MavenSess // let external providers contribute additional metadata try { - pluginRealmHelper.execute(session, project, () -> { - try { - for (P2MetadataProvider provider : plexus.lookupList(P2MetadataProvider.class)) { - Map providedMetadata = provider.getDependencyMetadata(session, - project, null, optionalAction); - if (providedMetadata != null) { - metadata.putAll(providedMetadata); - } - } - } catch (ComponentLookupException e) { - // have not found anything + pluginRealmHelper.visitPluginExtensions(session, project, P2MetadataProvider.class, provider -> { + Map providedMetadata = provider.getDependencyMetadata(session, project, + null, optionalAction); + if (providedMetadata != null) { + metadata.putAll(providedMetadata); } - }, this::isTychoP2Plugin); + }); } catch (Exception e) { throw new RuntimeException(e); } @@ -186,19 +178,6 @@ protected Map getDependencyMetadata(final MavenSess return metadata; } - protected boolean isTychoP2Plugin(PluginDescriptor pluginDescriptor) { - if (pluginDescriptor.getArtifactMap().containsKey("org.eclipse.tycho:tycho-core")) { - return true; - } - for (ComponentDependency dependency : pluginDescriptor.getDependencies()) { - if ("org.eclipse.tycho".equals(dependency.getGroupId()) - && "tycho-core".equals(dependency.getArtifactId())) { - return true; - } - } - return false; - } - @Override public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project, List reactorProjects) { diff --git a/tycho-extras/tycho-custom-bundle-plugin/src/main/java/org/eclipse/tycho/extras/custombundle/CustomBundleP2MetadataProvider.java b/tycho-extras/tycho-custom-bundle-plugin/src/main/java/org/eclipse/tycho/extras/custombundle/CustomBundleP2MetadataProvider.java index 6c43340388..2e35d5a1cd 100644 --- a/tycho-extras/tycho-custom-bundle-plugin/src/main/java/org/eclipse/tycho/extras/custombundle/CustomBundleP2MetadataProvider.java +++ b/tycho-extras/tycho-custom-bundle-plugin/src/main/java/org/eclipse/tycho/extras/custombundle/CustomBundleP2MetadataProvider.java @@ -38,7 +38,7 @@ import org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator; import org.eclipse.tycho.p2.metadata.PublisherOptions; import org.eclipse.tycho.p2resolver.AttachedArtifact; -import org.eclipse.tycho.p2resolver.P2MetadataProvider; +import org.eclipse.tycho.resolver.P2MetadataProvider; /** * This component is invoked during Tycho dependency resolution and provides P2 diff --git a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureP2MetadataProvider.java b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureP2MetadataProvider.java index fdb936050c..9583e3d81f 100644 --- a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureP2MetadataProvider.java +++ b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourceFeatureP2MetadataProvider.java @@ -35,7 +35,7 @@ import org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator; import org.eclipse.tycho.p2.metadata.PublisherOptions; import org.eclipse.tycho.p2resolver.AttachedArtifact; -import org.eclipse.tycho.p2resolver.P2MetadataProvider; +import org.eclipse.tycho.resolver.P2MetadataProvider; import de.pdark.decentxml.Document; import de.pdark.decentxml.Element; diff --git a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourcesP2MetadataProvider.java b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourcesP2MetadataProvider.java index 2b67bbd4c7..a332d4f65b 100644 --- a/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourcesP2MetadataProvider.java +++ b/tycho-source-plugin/src/main/java/org/eclipse/tycho/source/SourcesP2MetadataProvider.java @@ -30,7 +30,7 @@ import org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator; import org.eclipse.tycho.p2.metadata.PublisherOptions; import org.eclipse.tycho.p2resolver.AttachedArtifact; -import org.eclipse.tycho.p2resolver.P2MetadataProvider; +import org.eclipse.tycho.resolver.P2MetadataProvider; @Component(role = P2MetadataProvider.class, hint = "SourcesP2MetadataProvider") public class SourcesP2MetadataProvider implements P2MetadataProvider, Initializable { diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2MetadataProvider.java b/tycho-spi/src/main/java/org/eclipse/tycho/resolver/P2MetadataProvider.java similarity index 97% rename from tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2MetadataProvider.java rename to tycho-spi/src/main/java/org/eclipse/tycho/resolver/P2MetadataProvider.java index dfb3f9c87e..1a5d6e964e 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/P2MetadataProvider.java +++ b/tycho-spi/src/main/java/org/eclipse/tycho/resolver/P2MetadataProvider.java @@ -10,7 +10,7 @@ * Contributors: * Sonatype Inc. - initial API and implementation *******************************************************************************/ -package org.eclipse.tycho.p2resolver; +package org.eclipse.tycho.resolver; import java.util.List; import java.util.Map; From 1015f020e3352026a3b509a204c2be2ccead1a95 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Wed, 4 Jan 2023 17:12:06 +0100 Subject: [PATCH 17/19] Move the PluginRealmHelper to the spi-module --- .../p2maven/InstallableUnitGenerator.java | 4 +- .../p2maven/helper/PluginRealmHelper.java | 180 ------------------ .../compiler/AbstractOsgiCompilerMojo.java | 6 +- .../DefaultDependencyResolverFactory.java | 12 +- .../p2resolver/P2DependencyResolver.java | 4 +- .../test/EclipseInstallationLayoutTest.java | 106 ----------- .../extras/pde/ListDependenciesMojo.java | 4 +- .../SourceReferenceComputerTest.java | 16 +- tycho-spi/pom.xml | 15 +- .../tycho/helper/PluginRealmHelper.java | 168 ++++++++++++++++ .../provider/impl/ProviderHelperTest.java | 30 ++- .../testing/AbstractTychoMojoTestCase.java | 12 ++ .../tycho/testing/TychoPlexusTestCase.java | 12 +- 13 files changed, 252 insertions(+), 317 deletions(-) delete mode 100644 p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java delete mode 100644 tycho-core/src/test/java/org/eclipse/tycho/core/test/EclipseInstallationLayoutTest.java create mode 100644 tycho-spi/src/main/java/org/eclipse/tycho/helper/PluginRealmHelper.java diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java index 17f89216a8..d67d755208 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/InstallableUnitGenerator.java @@ -52,12 +52,12 @@ import org.eclipse.equinox.p2.publisher.eclipse.Feature; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.tycho.PackagingType; +import org.eclipse.tycho.helper.PluginRealmHelper; import org.eclipse.tycho.p2maven.actions.AuthoredIUAction; import org.eclipse.tycho.p2maven.actions.CategoryDependenciesAction; import org.eclipse.tycho.p2maven.actions.FeatureDependenciesAction; import org.eclipse.tycho.p2maven.actions.ProductDependenciesAction; import org.eclipse.tycho.p2maven.actions.ProductFile2; -import org.eclipse.tycho.p2maven.helper.PluginRealmHelper; import org.eclipse.tycho.p2maven.io.MetadataIO; import org.eclipse.tycho.resolver.InstallableUnitProvider; import org.osgi.framework.Constants; @@ -262,7 +262,7 @@ private Collection getProvider(MavenProject project, Ma throws CoreException { Set unitProviders = new HashSet<>(additionalUnitProviders.values()); try { - pluginRealmHelper.visitPluginExtensions(mavenSession, project, InstallableUnitProvider.class, + pluginRealmHelper.visitPluginExtensions(project, mavenSession, InstallableUnitProvider.class, unitProviders::add); } catch (Exception e) { throw new CoreException(Status.error("Can't lookup InstallableUnitProviders", e)); diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java deleted file mode 100644 index 43f42ddc29..0000000000 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/helper/PluginRealmHelper.java +++ /dev/null @@ -1,180 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2022 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 - *******************************************************************************/ -package org.eclipse.tycho.p2maven.helper; - -import java.util.Objects; -import java.util.function.Consumer; - -import org.apache.maven.execution.MavenSession; -import org.apache.maven.lifecycle.internal.LifecyclePluginResolver; -import org.apache.maven.model.Plugin; -import org.apache.maven.plugin.BuildPluginManager; -import org.apache.maven.plugin.InvalidPluginDescriptorException; -import org.apache.maven.plugin.MavenPluginManager; -import org.apache.maven.plugin.PluginDescriptorCache; -import org.apache.maven.plugin.PluginDescriptorParsingException; -import org.apache.maven.plugin.PluginManagerException; -import org.apache.maven.plugin.PluginResolutionException; -import org.apache.maven.plugin.descriptor.PluginDescriptor; -import org.apache.maven.plugin.version.PluginVersionResolutionException; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.component.repository.ComponentDependency; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.logging.Logger; - -/** - * Helper class that allows execution of components from maven plugin class - * realms. Normally, these components are not visible from tycho-core extensions - * plugin and require treatment. Typical usage - * - *
- * @Requirement
- * private EquinoxServiceFactory equinox;
- * 
- * @Requirement
- * private PluginRealmHelper pluginRealmHelper;
- * 
- * ...
- * 
- * public void someMethod(final MavenSession session, final MavenProject project) throws MavenExecutionException {
- *    pluginRealmHelper..execute(session, project, new Runnable() {
- *        public void run() {
- *            try {
- *                equinox.lookup(SomeComponent.class).someComponentMethod();
- *            } catch (ComponentLookupException e) {
- *                // have not found anything
- *            }
- *        }
- *    }, new PluginFilter() {
- *        public boolean accept(PluginDescriptor descriptor) {
- *            return true if the plugin is relevant;
- *        }
- *    });
- * }
- * 
- * - */ -@Component(role = PluginRealmHelper.class) -public class PluginRealmHelper { - public static interface PluginFilter { - public boolean accept(PluginDescriptor descriptor); - } - - @Requirement - private Logger logger; - - @Requirement - private MavenPluginManager pluginManager; - - @Requirement - private BuildPluginManager buildPluginManager; - - @Requirement - private PluginDescriptorCache pluginDescriptorCache; - - @Requirement - private LifecyclePluginResolver lifecyclePluginResolver; - - @Requirement - protected MavenPluginManager mavenPluginManager; - - @Requirement - private PlexusContainer plexus; - - public void visitPluginExtensions(MavenSession session, MavenProject project, Class type, - Consumer consumer) throws PluginVersionResolutionException, PluginDescriptorParsingException, - InvalidPluginDescriptorException, PluginResolutionException, PluginManagerException { - execute(session, project, () -> { - try { - plexus.lookupList(type).forEach(consumer); - } catch (ComponentLookupException e) { - logger.debug("Can't lookup any item of " + type); - } - }); - } - - public void execute(MavenSession session, MavenProject project, Runnable runnable) - throws PluginVersionResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, - PluginResolutionException, PluginManagerException { - execute(session, project, runnable, PluginRealmHelper::isTychoEmbedderPlugin); - } - - public void execute(MavenSession session, MavenProject project, Runnable runnable, PluginFilter filter) - throws PluginVersionResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, - PluginResolutionException, PluginManagerException { - Objects.requireNonNull(session); - if (session.getLocalRepository() == null) { - // This happens in some test-code ... but should never happen in real maven... - return; - } - MavenSession executeSession = session.clone(); - executeSession.setCurrentProject(project); - for (Plugin plugin : project.getBuildPlugins()) { - if (plugin.isExtensions()) { - // due to maven classloading model limitations, build extensions plugins cannot - // share classes - // since tycho core, i.e. this code, is loaded as a build extension, no other - // extensions plugin - // can load classes from tycho core - // https://cwiki.apache.org/MAVEN/maven-3x-class-loading.html - continue; - } - lifecyclePluginResolver.resolveMissingPluginVersions(project, executeSession); - PluginDescriptor pluginDescriptor; - try { - pluginDescriptor = mavenPluginManager.getPluginDescriptor(plugin, project.getRemotePluginRepositories(), - executeSession.getRepositorySession()); // compatibilityHelper.getPluginDescriptor(plugin, - // project, - // session); - } catch (PluginResolutionException e) { - // if the plugin really does not exist, the Maven build will fail later on - // anyway -> ignore for now (cf. bug #432957) - logger.debug("PluginResolutionException while looking for components from " + plugin, e); - continue; - } - - if (pluginDescriptor != null) { - if (filter == null || filter.accept(pluginDescriptor)) { - ClassRealm pluginRealm = buildPluginManager.getPluginRealm(executeSession, pluginDescriptor); - if (pluginRealm != null) { - ClassLoader origTCCL = Thread.currentThread().getContextClassLoader(); - try { - Thread.currentThread().setContextClassLoader(pluginRealm); - runnable.run(); - } finally { - Thread.currentThread().setContextClassLoader(origTCCL); - } - } - } - } - } - - } - - private static boolean isTychoEmbedderPlugin(PluginDescriptor pluginDescriptor) { - if (pluginDescriptor.getArtifactMap().containsKey("org.eclipse.tycho:tycho-spi")) { - return true; - } - for (ComponentDependency dependency : pluginDescriptor.getDependencies()) { - if ("org.eclipse.tycho".equals(dependency.getGroupId()) - && "tycho-spi".equals(dependency.getArtifactId())) { - return true; - } - } - return false; - } -} diff --git a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java index ebab6e3cdc..70b1006eff 100644 --- a/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java +++ b/tycho-compiler-plugin/src/main/java/org/eclipse/tycho/compiler/AbstractOsgiCompilerMojo.java @@ -67,10 +67,10 @@ import org.eclipse.osgi.util.ManifestElement; import org.eclipse.tycho.ArtifactKey; import org.eclipse.tycho.ClasspathEntry; +import org.eclipse.tycho.ClasspathEntry.AccessRule; import org.eclipse.tycho.DefaultArtifactKey; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.SourcepathEntry; -import org.eclipse.tycho.ClasspathEntry.AccessRule; import org.eclipse.tycho.classpath.ClasspathContributor; import org.eclipse.tycho.core.BundleProject; import org.eclipse.tycho.core.TychoProject; @@ -92,7 +92,7 @@ import org.eclipse.tycho.core.osgitools.project.EclipsePluginProject; import org.eclipse.tycho.core.resolver.shared.PomDependencies; import org.eclipse.tycho.core.utils.TychoProjectUtils; -import org.eclipse.tycho.p2maven.helper.PluginRealmHelper; +import org.eclipse.tycho.helper.PluginRealmHelper; import org.osgi.framework.Constants; import org.osgi.framework.Filter; import org.osgi.framework.FrameworkUtil; @@ -856,7 +856,7 @@ public List getClasspath() throws MojoExecutionException { } try { - pluginRealmHelper.visitPluginExtensions(session, project, ClasspathContributor.class, cpc -> { + pluginRealmHelper.visitPluginExtensions(project, session, ClasspathContributor.class, cpc -> { List list = cpc.getAdditionalClasspathEntries(reactorProject, dependencyScope); if (list != null && !list.isEmpty()) { classpath.addAll(list); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultDependencyResolverFactory.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultDependencyResolverFactory.java index a4102afda2..74c79713a2 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultDependencyResolverFactory.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultDependencyResolverFactory.java @@ -13,7 +13,6 @@ *******************************************************************************/ package org.eclipse.tycho.core.resolver; -import java.util.Objects; import java.util.Properties; import org.apache.maven.project.MavenProject; @@ -37,6 +36,8 @@ public class DefaultDependencyResolverFactory { @Requirement private PlexusContainer container; + @Requirement(hint = DEFAULT_RESOLVER_HINT) + private DependencyResolver dependencyResolver; public DependencyResolver lookupDependencyResolver(MavenProject project) { return lookupDependencyResolver(DefaultReactorProject.adapt(project)); @@ -59,13 +60,6 @@ public DependencyResolver lookupDependencyResolver(ReactorProject reactorProject throw new RuntimeException("Could not instantiate required component", e); } } - String resolverRole = Objects.requireNonNullElse(configuration.getTargetPlatformResolver(), - DEFAULT_RESOLVER_HINT); - try { - return container.lookup(DependencyResolver.class, resolverRole); - } catch (ComponentLookupException e) { - throw new RuntimeException( - "Could not instantiate requested DependencyResolver component with role = " + resolverRole, e); - } + return dependencyResolver; } } 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 672f685a9a..d6b228948f 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 @@ -76,12 +76,12 @@ 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; import org.eclipse.tycho.p2.repository.LocalRepositoryP2Indices; import org.eclipse.tycho.p2.target.facade.PomDependencyCollector; import org.eclipse.tycho.p2.target.facade.TargetPlatformConfigurationStub; -import org.eclipse.tycho.p2maven.helper.PluginRealmHelper; import org.eclipse.tycho.p2maven.repository.P2ArtifactRepositoryLayout; import org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManager; import org.eclipse.tycho.resolver.P2MetadataProvider; @@ -164,7 +164,7 @@ protected Map getDependencyMetadata(final MavenSess // let external providers contribute additional metadata try { - pluginRealmHelper.visitPluginExtensions(session, project, P2MetadataProvider.class, provider -> { + pluginRealmHelper.visitPluginExtensions(project, session, P2MetadataProvider.class, provider -> { Map providedMetadata = provider.getDependencyMetadata(session, project, null, optionalAction); if (providedMetadata != null) { diff --git a/tycho-core/src/test/java/org/eclipse/tycho/core/test/EclipseInstallationLayoutTest.java b/tycho-core/src/test/java/org/eclipse/tycho/core/test/EclipseInstallationLayoutTest.java deleted file mode 100644 index d9950eeb5e..0000000000 --- a/tycho-core/src/test/java/org/eclipse/tycho/core/test/EclipseInstallationLayoutTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2008, 2011 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 - *******************************************************************************/ -package org.eclipse.tycho.core.test; - -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - -import org.codehaus.plexus.PlexusTestCase; -import org.eclipse.tycho.core.osgitools.targetplatform.EclipseInstallationLayout; - -public class EclipseInstallationLayoutTest extends PlexusTestCase { - - public void testTargetPlatform() throws Exception { - File targetPlatform = new File("src/test/resources/targetplatforms/wtp-2.0").getCanonicalFile(); - EclipseInstallationLayout finder = getPluginFinder(targetPlatform); - - List sites = getCannonicalFiles(finder.getSites()); - - assertEquals(4, sites.size()); - assertTrue(sites.toString(), sites.contains(targetPlatform)); - assertTrue(sites.toString(), sites.contains(new File(targetPlatform, "dropins/zest-3.4"))); - assertTrue(sites.toString(), sites.contains(new File(targetPlatform, "../subclipse-1.3").getCanonicalFile())); - } - - private EclipseInstallationLayout getPluginFinder(File location) throws Exception { - EclipseInstallationLayout layout = lookup(EclipseInstallationLayout.class); - layout.setLocation(location); - return layout; - } - - public void testPlugins33() throws Exception { - File targetPlatform = new File("src/test/resources/targetplatforms/wtp-2.0").getCanonicalFile(); - EclipseInstallationLayout finder = getPluginFinder(targetPlatform); - - List plugins = getCannonicalFiles(finder.getPlugins(targetPlatform)); - - assertEquals(2, plugins.size()); - assertTrue(plugins.contains(new File(targetPlatform, "plugins/com.ibm.icu.source_3.6.1.v20070906") - .getCanonicalFile())); - assertTrue(plugins.contains(new File(targetPlatform, - "plugins/org.eclipse.datatools.enablement.sybase.asa.models_1.0.0.200706071.jar").getCanonicalFile())); - } - - public void testPlugins34() throws Exception { - File targetPlatform = new File("src/test/resources/targetplatforms/wtp-3.0").getCanonicalFile(); - EclipseInstallationLayout finder = getPluginFinder(targetPlatform); - - List plugins = new ArrayList<>(); - for (File site : finder.getSites()) { - plugins.addAll(getCannonicalFiles(finder.getPlugins(site))); - } - - assertEquals(2, plugins.size()); -// assertTrue(plugins.contains(new File(targetPlatform, "plugins/com.ibm.icu_3.8.1.v20080402.jar").getCanonicalFile())); -// assertTrue(plugins.contains(new File(targetPlatform, "plugins/org.junit4_4.3.1").getCanonicalFile())); - assertTrue(plugins.contains(new File(targetPlatform, "dropins/com.ibm.icu.source_3.6.1.v20070906") - .getCanonicalFile())); - assertTrue(plugins.contains(new File(targetPlatform, - "dropins/org.eclipse.datatools.enablement.sybase.asa.models_1.0.0.200706071.jar").getCanonicalFile())); - } - - public void testSites34() throws Exception { - File targetPlatform = new File("src/test/resources/targetplatforms/wtp-3.0").getCanonicalFile(); - EclipseInstallationLayout finder = getPluginFinder(targetPlatform); - - List sites = getCannonicalFiles(finder.getSites()); - - assertEquals(6, sites.size()); - assertTrue(sites.toString(), sites.contains(targetPlatform)); - assertTrue(sites.toString(), sites.contains(new File(targetPlatform, "dropins/ajdt"))); - assertTrue(sites.toString(), sites.contains(new File(targetPlatform, "dropins/eclipse"))); - assertTrue(sites.toString(), sites.contains(new File(targetPlatform, "dropins/emf/eclipse"))); - assertTrue(sites.toString(), sites.contains(new File(targetPlatform, "../subclipse-1.3").getCanonicalFile())); - } - - private List getCannonicalFiles(Set files) throws IOException { - ArrayList result = new ArrayList<>(); - for (File file : files) { - result.add(file.getCanonicalFile()); - } - return result; - } - - public void testSitesSimple() throws Exception { - File targetPlatform = new File("src/test/resources/targetplatforms/simple").getCanonicalFile(); - EclipseInstallationLayout finder = getPluginFinder(targetPlatform); - - List sites = new ArrayList<>(finder.getSites()); - - assertEquals(2, sites.size()); - assertEquals(targetPlatform, sites.get(0)); - } -} diff --git a/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java b/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java index e3f052d135..809e8ae8ce 100644 --- a/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java +++ b/tycho-extras/tycho-dependency-tools-plugin/src/main/java/org/eclipse/tycho/extras/pde/ListDependenciesMojo.java @@ -37,7 +37,7 @@ import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.osgitools.OsgiBundleProject; import org.eclipse.tycho.core.utils.TychoProjectUtils; -import org.eclipse.tycho.p2maven.helper.PluginRealmHelper; +import org.eclipse.tycho.helper.PluginRealmHelper; /** * Builds a .target file describing the dependencies for current project. It differs from @@ -94,7 +94,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { if (projectType instanceof OsgiBundleProject bundleProject) { try { - pluginRealmHelper.visitPluginExtensions(session, project, ClasspathContributor.class, cpc -> { + pluginRealmHelper.visitPluginExtensions(project, session, ClasspathContributor.class, cpc -> { List list = cpc.getAdditionalClasspathEntries(reactorProject, Artifact.SCOPE_COMPILE); if (list != null && !list.isEmpty()) { diff --git a/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/packaging/sourceref/SourceReferenceComputerTest.java b/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/packaging/sourceref/SourceReferenceComputerTest.java index 4ebd1735cc..de34b5de31 100644 --- a/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/packaging/sourceref/SourceReferenceComputerTest.java +++ b/tycho-packaging-plugin/src/test/java/org/eclipse/tycho/packaging/sourceref/SourceReferenceComputerTest.java @@ -13,42 +13,50 @@ package org.eclipse.tycho.packaging.sourceref; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; import static org.junit.Assert.assertThrows; import java.util.jar.Manifest; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.PlexusTestCase; import org.eclipse.tycho.packaging.SourceReferences; +import org.eclipse.tycho.testing.TychoPlexusTestCase; +import org.junit.Before; +import org.junit.Test; -public class SourceReferenceComputerTest extends PlexusTestCase { +public class SourceReferenceComputerTest extends TychoPlexusTestCase { private SourceReferenceComputer sourceRefComputer; private Manifest manifest; - @Override - protected void setUp() throws Exception { + @Before + public void testSetUp() throws Exception { sourceRefComputer = lookup(SourceReferenceComputer.class); manifest = new Manifest(); } + @Test public void testAddSourceReferenceDummyProvider() throws Exception { sourceRefComputer.addSourceReferenceHeader(manifest, createSourceRefConfig(true, null), createProjectStub()); assertEquals("scm:dummy:aDummySCMURL;path=\"dummy/path\"", getSourceRefsHeaderValue()); } + @Test public void testAddSourceReferenceCustomValue() throws Exception { sourceRefComputer.addSourceReferenceHeader(manifest, createSourceRefConfig(true, "scm:myvalue"), createProjectStub()); assertEquals("scm:myvalue", getSourceRefsHeaderValue()); } + @Test public void testAddSourceReferenceNoGenerate() throws Exception { sourceRefComputer.addSourceReferenceHeader(manifest, createSourceRefConfig(false, null), createProjectStub()); assertNull(getSourceRefsHeaderValue()); } + @Test public void testAddSourceReferenceNoProvider() { assertThrows(MojoExecutionException.class, () -> diff --git a/tycho-spi/pom.xml b/tycho-spi/pom.xml index d2c07ea4b7..0fa8b518ca 100644 --- a/tycho-spi/pom.xml +++ b/tycho-spi/pom.xml @@ -9,18 +9,15 @@ - Contributors: - Sonatype Inc. - initial API and implementation --> - 4.0.0 - org.eclipse.tycho tycho 4.0.0-SNAPSHOT tycho-spi - Tycho Service Provider Interfaces This contains interfaces that might be used to enahnce Tycho itself with plugins @@ -34,4 +31,16 @@ ${project.version}
+ + + + org.codehaus.plexus + plexus-component-metadata + + + org.apache.maven.plugins + maven-plugin-plugin + + + diff --git a/tycho-spi/src/main/java/org/eclipse/tycho/helper/PluginRealmHelper.java b/tycho-spi/src/main/java/org/eclipse/tycho/helper/PluginRealmHelper.java new file mode 100644 index 0000000000..674353d421 --- /dev/null +++ b/tycho-spi/src/main/java/org/eclipse/tycho/helper/PluginRealmHelper.java @@ -0,0 +1,168 @@ +/******************************************************************************* + * Copyright (c) 2008, 2022 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 + *******************************************************************************/ +package org.eclipse.tycho.helper; + +import java.util.function.Consumer; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.lifecycle.internal.LifecyclePluginResolver; +import org.apache.maven.model.Plugin; +import org.apache.maven.plugin.BuildPluginManager; +import org.apache.maven.plugin.InvalidPluginDescriptorException; +import org.apache.maven.plugin.MavenPluginManager; +import org.apache.maven.plugin.PluginDescriptorCache; +import org.apache.maven.plugin.PluginDescriptorParsingException; +import org.apache.maven.plugin.PluginManagerException; +import org.apache.maven.plugin.PluginResolutionException; +import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.apache.maven.plugin.version.PluginVersionResolutionException; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.PlexusContainer; +import org.codehaus.plexus.classworlds.realm.ClassRealm; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.component.annotations.Requirement; +import org.codehaus.plexus.component.repository.ComponentDependency; +import org.codehaus.plexus.component.repository.exception.ComponentLookupException; +import org.codehaus.plexus.logging.Logger; + +/** + * Helper class that allows execution of components from maven plugin class realms. Normally, these + * components are not visible from tycho-core extensions plugin and require treatment. Typical usage + * + *
+ * @Requirement
+ * private EquinoxServiceFactory equinox;
+ * 
+ * @Requirement
+ * private PluginRealmHelper pluginRealmHelper;
+ * 
+ * ...
+ * 
+ * public void someMethod(final MavenSession session, final MavenProject project) throws MavenExecutionException {
+ *    pluginRealmHelper..execute(session, project, new Runnable() {
+ *        public void run() {
+ *            try {
+ *                equinox.lookup(SomeComponent.class).someComponentMethod();
+ *            } catch (ComponentLookupException e) {
+ *                // have not found anything
+ *            }
+ *        }
+ *    }, new PluginFilter() {
+ *        public boolean accept(PluginDescriptor descriptor) {
+ *            return true if the plugin is relevant;
+ *        }
+ *    });
+ * }
+ * 
+ * + */ +@Component(role = PluginRealmHelper.class) +public class PluginRealmHelper { + public static interface PluginFilter { + public boolean accept(PluginDescriptor descriptor); + } + + @Requirement + private Logger logger; + + @Requirement + private MavenPluginManager pluginManager; + + @Requirement + private BuildPluginManager buildPluginManager; + + @Requirement + private PluginDescriptorCache pluginDescriptorCache; + + @Requirement + private LifecyclePluginResolver lifecyclePluginResolver; + + @Requirement + protected MavenPluginManager mavenPluginManager; + + @Requirement + private PlexusContainer plexus; + + public void visitPluginExtensions(MavenProject project, MavenSession mavenSession, Class type, + Consumer consumer) throws PluginVersionResolutionException, PluginDescriptorParsingException, + InvalidPluginDescriptorException, PluginResolutionException, PluginManagerException { + execute(project, mavenSession, () -> { + try { + plexus.lookupList(type).forEach(consumer); + } catch (ComponentLookupException e) { + logger.debug("Can't lookup any item of " + type); + } + }, PluginRealmHelper::isTychoEmbedderPlugin); + } + + public void execute(MavenProject project, MavenSession mavenSession, Runnable runnable, PluginFilter filter) + throws PluginVersionResolutionException, PluginDescriptorParsingException, InvalidPluginDescriptorException, + PluginResolutionException, PluginManagerException { + if (mavenSession.getLocalRepository() == null) { + // This happens in some test-code ... but should never happen in real maven... + return; + } + MavenSession executeSession = mavenSession.clone(); + executeSession.setCurrentProject(project); + for (Plugin plugin : project.getBuildPlugins()) { + if (plugin.isExtensions()) { + // due to maven classloading model limitations, build extensions plugins cannot + // share classes + // since tycho core, i.e. this code, is loaded as a build extension, no other + // extensions plugin + // can load classes from tycho core + // https://cwiki.apache.org/MAVEN/maven-3x-class-loading.html + continue; + } + lifecyclePluginResolver.resolveMissingPluginVersions(project, executeSession); + PluginDescriptor pluginDescriptor; + try { + pluginDescriptor = mavenPluginManager.getPluginDescriptor(plugin, project.getRemotePluginRepositories(), + executeSession.getRepositorySession()); + // session); + } catch (PluginResolutionException e) { + // if the plugin really does not exist, the Maven build will fail later on + // anyway -> ignore for now (cf. bug #432957) + logger.debug("PluginResolutionException while looking for components from " + plugin, e); + continue; + } + if (pluginDescriptor != null) { + if (filter == null || filter.accept(pluginDescriptor)) { + ClassRealm pluginRealm = buildPluginManager.getPluginRealm(executeSession, pluginDescriptor); + if (pluginRealm != null) { + ClassLoader origTCCL = Thread.currentThread().getContextClassLoader(); + try { + Thread.currentThread().setContextClassLoader(pluginRealm); + runnable.run(); + } finally { + Thread.currentThread().setContextClassLoader(origTCCL); + } + } + } + } + } + + } + + private static boolean isTychoEmbedderPlugin(PluginDescriptor pluginDescriptor) { + if (pluginDescriptor.getArtifactMap().containsKey("org.eclipse.tycho:tycho-spi")) { + return true; + } + for (ComponentDependency dependency : pluginDescriptor.getDependencies()) { + if ("org.eclipse.tycho".equals(dependency.getGroupId()) && "tycho-spi".equals(dependency.getArtifactId())) { + return true; + } + } + return false; + } +} diff --git a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelperTest.java b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelperTest.java index 61d069d943..12bb6e426e 100644 --- a/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelperTest.java +++ b/tycho-surefire/tycho-surefire-plugin/src/test/java/org/eclipse/tycho/surefire/provider/impl/ProviderHelperTest.java @@ -16,6 +16,7 @@ import static java.util.Arrays.asList; import static java.util.Collections.emptyList; import static org.eclipse.tycho.surefire.provider.impl.AbstractJUnitProviderTest.classPath; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertThrows; import java.io.File; @@ -29,12 +30,14 @@ import org.apache.maven.model.Dependency; import org.apache.maven.plugin.MojoExecutionException; import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.PlexusTestCase; import org.eclipse.tycho.ClasspathEntry; import org.eclipse.tycho.surefire.provider.spi.TestFrameworkProvider; +import org.eclipse.tycho.testing.TychoPlexusTestCase; +import org.junit.Before; +import org.junit.Test; import org.osgi.framework.Version; -public class ProviderHelperTest extends PlexusTestCase { +public class ProviderHelperTest extends TychoPlexusTestCase { private static final String TYCHO_GROUPID = "org.eclipse.tycho"; private static final String JUNIT3_FRAGMENT = "org.eclipse.tycho.surefire.junit"; @@ -43,23 +46,26 @@ public class ProviderHelperTest extends PlexusTestCase { private ProviderHelper providerHelper; - @Override - protected void setUp() throws Exception { - this.providerHelper = getContainer().lookup(ProviderHelper.class); + @Before + public void setUpTest() throws Exception { + this.providerHelper = lookup(ProviderHelper.class); } + @Test public void testSelectJunit3() throws Exception { TestFrameworkProvider provider = providerHelper.selectProvider(classPath("org.junit:3.8"), new Properties(), null); assertEquals(JUnit3Provider.class, provider.getClass()); } + @Test public void testSelectJunit4() throws Exception { TestFrameworkProvider provider = providerHelper.selectProvider(classPath("org.junit:4.8.1"), new Properties(), null); assertEquals(JUnit4Provider.class, provider.getClass()); } + @Test public void testSelectJunit47() throws Exception { Properties providerProperties = new Properties(); providerProperties.setProperty("parallel", "classes"); @@ -68,52 +74,61 @@ public void testSelectJunit47() throws Exception { assertEquals(JUnit47Provider.class, provider.getClass()); } + @Test public void testSelectJunit5WithJUnitFromOrbit() throws Exception { TestFrameworkProvider provider = providerHelper.selectProvider(classPath("org.junit.jupiter.api:5.0.0"), new Properties(), null); assertEquals(JUnit5Provider.class, provider.getClass()); } + @Test public void testSelectJunit5() throws Exception { TestFrameworkProvider provider = providerHelper.selectProvider(classPath("junit-jupiter-api:5.0.0"), new Properties(), null); assertEquals(JUnit5Provider.class, provider.getClass()); } + @Test public void testSelectJunit5WithJUnit4Present() throws Exception { TestFrameworkProvider provider = providerHelper .selectProvider(classPath("org.junit:4.12", "org.junit.jupiter.api:5.0.0"), new Properties(), null); assertEquals(JUnit5Provider.class, provider.getClass()); } + @Test public void testSelectJunit4WithJunit3Present() throws Exception { TestFrameworkProvider provider = providerHelper.selectProvider(classPath("org.junit:3.8.1", "org.junit:4.8.1"), new Properties(), null); assertEquals(JUnit4Provider.class, provider.getClass()); } + @Test public void testForceJunit3WithHint() throws Exception { TestFrameworkProvider provider = providerHelper.selectProvider(classPath("org.junit:3.8.1", "org.junit:4.8.1"), new Properties(), "junit3"); assertEquals(JUnit3Provider.class, provider.getClass()); } + @Test public void testSelectTestNG() throws Exception { TestFrameworkProvider provider = providerHelper.selectProvider(classPath("org.testng:6.9.12"), new Properties(), null); assertEquals(TestNGProvider.class, provider.getClass()); } + @Test public void testSelectWithNonExistingHint() { assertThrows(MojoExecutionException.class, () -> providerHelper.selectProvider(classPath(), new Properties(), "NON_EXISTING")); } + @Test public void testNoProviderFound() { assertThrows(MojoExecutionException.class, () -> providerHelper.selectProvider(classPath("foo:1.0", "test:2.0"), new Properties(), null)); } + @Test public void testParallelModeNotSupported() { Properties providerProperties = new Properties(); providerProperties.setProperty("parallel", "methods"); @@ -121,6 +136,7 @@ public void testParallelModeNotSupported() { () -> providerHelper.selectProvider(classPath("org.junit:4.6"), providerProperties, null)); } + @Test public void testMultipleProviderTypesFound() throws Exception { TestFrameworkProvider anotherProvider = new TestFrameworkProvider() { @@ -165,11 +181,13 @@ public Properties getProviderSpecificProperties() { } } + @Test public void testFilterTestFrameworkBundlesNotFound() { assertThrows(MojoExecutionException.class, () -> providerHelper.filterTestFrameworkBundles(new JUnit3Provider(), asList(createMockArtifact("test", "test")))); } + @Test public void testFilterTestFrameworkBundlesJUnit3() throws MojoExecutionException { Set junitSurefireBundles = providerHelper.filterTestFrameworkBundles( new JUnit3Provider(), @@ -184,6 +202,7 @@ public void testFilterTestFrameworkBundlesJUnit3() throws MojoExecutionException assertEquals(expectedFileNames, fileNames); } + @Test public void testFilterTestFrameworkBundlesJUnit4() throws MojoExecutionException { Set junitSurefireBundles = providerHelper.filterTestFrameworkBundles( new JUnit4Provider(), @@ -198,6 +217,7 @@ public void testFilterTestFrameworkBundlesJUnit4() throws MojoExecutionException assertEquals(expectedFileNames, fileNames); } + @Test public void testGetSymbolicNames() throws MojoExecutionException { List symbolicNames = providerHelper.getSymbolicNames(Collections.singleton( createMockArtifact("foo", "bar", new File("src/test/resources/org.junit_3.8.2.v20090203-1005")))); diff --git a/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/AbstractTychoMojoTestCase.java b/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/AbstractTychoMojoTestCase.java index d8f4da43db..6762faf0e3 100644 --- a/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/AbstractTychoMojoTestCase.java +++ b/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/AbstractTychoMojoTestCase.java @@ -39,6 +39,7 @@ import org.apache.maven.project.MavenProject; import org.apache.maven.project.ProjectBuildingRequest; import org.apache.maven.repository.RepositorySystem; +import org.apache.maven.session.scope.internal.SessionScope; import org.apache.maven.settings.MavenSettingsBuilder; import org.apache.maven.settings.Settings; import org.codehaus.plexus.PlexusContainer; @@ -59,6 +60,10 @@ public class AbstractTychoMojoTestCase extends AbstractMojoTestCase { @Override protected void setUp() throws Exception { super.setUp(); + SessionScope sessionScope = lookup(SessionScope.class); + MavenSession session = newMavenSession(new MavenProject()); + sessionScope.enter(); + sessionScope.seed(MavenSession.class, session); maven = lookup(Maven.class); settingsBuilder = lookup(MavenSettingsBuilder.class); requestPopulator = lookup(MavenExecutionRequestPopulator.class); @@ -67,6 +72,8 @@ protected void setUp() throws Exception { @Override protected void tearDown() throws Exception { + SessionScope sessionScope = lookup(SessionScope.class); + sessionScope.exit(); maven = null; super.tearDown(); } @@ -76,6 +83,11 @@ protected String getCustomConfigurationName() { return AbstractTychoMojoTestCase.class.getName().replace('.', '/') + ".xml"; } + @Override + protected Mojo lookupMojo(String goal, File pom) throws Exception { + return super.lookupMojo(goal, pom); + } + protected ArtifactRepository getLocalRepository() throws Exception { RepositorySystem repoSystem = lookup(RepositorySystem.class); diff --git a/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/TychoPlexusTestCase.java b/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/TychoPlexusTestCase.java index cfffae9b0f..15e51fcf61 100644 --- a/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/TychoPlexusTestCase.java +++ b/tycho-testing-harness/src/main/java/org/eclipse/tycho/testing/TychoPlexusTestCase.java @@ -25,6 +25,7 @@ import org.apache.maven.monitor.event.EventMonitor; import org.apache.maven.plugin.LegacySupport; import org.apache.maven.plugin.testing.stubs.StubArtifactRepository; +import org.apache.maven.session.scope.internal.SessionScope; import org.apache.maven.settings.Settings; import org.codehaus.plexus.ContainerConfiguration; import org.codehaus.plexus.PlexusConstants; @@ -51,10 +52,16 @@ public class TychoPlexusTestCase { PlexusTestCaseExension ext = new PlexusTestCaseExension(); @After - public void tearDown() { + public void tearDown() throws ComponentLookupException { + SessionScope sessionScope = ext.getContainer().lookup(SessionScope.class); + sessionScope.exit(); ext.teardownContainer(); } + protected PlexusContainer getContainer() { + return ext.getContainer(); + } + @SuppressWarnings("deprecation") @Before public void setUpServiceAndSession() throws ComponentLookupException, IOException { @@ -87,7 +94,10 @@ public void addEventMonitor(EventMonitor monitor) { MavenSession mavenSession = new MavenSession(container, settings, localRepository, eventDispatcher, null, List.of(), temporaryFolder.newFolder().getAbsolutePath(), System.getProperties(), System.getProperties(), new Date()); + SessionScope sessionScope = container.lookup(SessionScope.class); mavenSession.setProjects(Collections.emptyList()); + sessionScope.enter(); + sessionScope.seed(MavenSession.class, mavenSession); legacySupport.setSession(mavenSession); modifySession(mavenSession); //if possible, init the service factory and loading of services From f4324489f64e323ca3c1a7b0e24f1f929e70e903 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Thu, 5 Jan 2023 08:12:03 +0100 Subject: [PATCH 18/19] Remove surefire from the default lifecycle --- RELEASE_NOTES.md | 18 +++++++++++++++++- .../surefire.combinedtests/bundle.test/pom.xml | 11 +++++++++-- .../bundle5.test/pom.xml | 13 ++++++++++++- .../resources/META-INF/plexus/components.xml | 1 - 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index be94417be2..3f9428f330 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -128,11 +128,27 @@ Some improvements have been made for the test execution with `eclipse-plugin` pa 1. The property `skipITs` has been renamed to `tycho.plugin-test.skip` 2. the mojo `integration-test` has been renamed to `plugin-test` 3. the default pattern of the former `integration-test` has been changed from `**/PluginTest*.class", "**/*IT.class` to the maven default `**/Test*.class", "**/*Test.class", "**/*Tests.class", "**/*TestCase.class` -4. the former `integration-test` mojo is no longer part of the default life-cycle, that means to use it it has to be explicitly be enabled to be more flexible and this is how standard maven behaves +4. the former `integration-test` mojo is no longer part of the default life-cycle, that means it has to be explicitly be enabled to be more flexible and this is how standard maven behaves +5. the `test` mojo of the `maven-surefire-plugin` is no longer part of the default life-cycle, that means it has to be explicitly be enabled to be more flexible and to not pollute the test-phase. To restore old behaviour you can add the follwoing snippet to your (master) pom: ``` + + org.apache.maven.plugins + maven-surefire-plugin + ${surefire-plugin-version} + + + execute-tests + + test + + + + + + org.eclipse.tycho tycho-surefire-plugin diff --git a/tycho-its/projects/surefire.combinedtests/bundle.test/pom.xml b/tycho-its/projects/surefire.combinedtests/bundle.test/pom.xml index b27c22a2ad..fae164ce65 100644 --- a/tycho-its/projects/surefire.combinedtests/bundle.test/pom.xml +++ b/tycho-its/projects/surefire.combinedtests/bundle.test/pom.xml @@ -7,7 +7,7 @@ 1.0.0 https:////download.eclipse.org/releases/2022-12/ - 3.1.0-SNAPSHOT + 4.0.0-SNAPSHOT @@ -24,7 +24,6 @@ ${tycho-version} true - org.apache.maven.plugins maven-surefire-plugin @@ -36,6 +35,14 @@ 3.0.0-M5
+ + + execute-tests + + test + + +
org.eclipse.tycho diff --git a/tycho-its/projects/surefire.combinedtests/bundle5.test/pom.xml b/tycho-its/projects/surefire.combinedtests/bundle5.test/pom.xml index c6464fdb92..59fc27d97c 100644 --- a/tycho-its/projects/surefire.combinedtests/bundle5.test/pom.xml +++ b/tycho-its/projects/surefire.combinedtests/bundle5.test/pom.xml @@ -5,6 +5,10 @@ bundle.test5 eclipse-plugin 1.0.0 + + https:////download.eclipse.org/releases/2022-12/ + 4.0.0-SNAPSHOT + platform @@ -20,7 +24,6 @@ ${tycho-version} true - org.apache.maven.plugins maven-surefire-plugin @@ -32,6 +35,14 @@ 3.0.0-M5 + + + execute-tests + + test + + +
diff --git a/tycho-maven-plugin/src/main/resources/META-INF/plexus/components.xml b/tycho-maven-plugin/src/main/resources/META-INF/plexus/components.xml index 45bb7f65e6..234b27ad3f 100644 --- a/tycho-maven-plugin/src/main/resources/META-INF/plexus/components.xml +++ b/tycho-maven-plugin/src/main/resources/META-INF/plexus/components.xml @@ -37,7 +37,6 @@ org.eclipse.tycho:tycho-compiler-plugin:${project.version}:testCompile - org.apache.maven.plugins:maven-surefire-plugin:${surefire-plugin.version}:test org.eclipse.tycho:tycho-packaging-plugin:${project.version}:update-consumer-pom From c663386249ee21041a363366f1748a7cd16b5a1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Thu, 5 Jan 2023 21:18:12 +0100 Subject: [PATCH 19/19] Support PDE BUNDLE_ROOT_PATH settings One can change the root of the bundle (for example) BUNDLE_ROOT_PATH=src/main/resources in org.eclipse.pde.core.prefs but then Tycho fails as it search for the manifest always at the root. This enhances the BundleReader and PackagePluginMojo to support this configuration preference. Fix https://github.com/eclipse-tycho/tycho/issues/1516 --- .../tycho/core/osgitools/BundleReader.java | 7 ++++-- .../core/osgitools/DefaultBundleReader.java | 23 ++++++++++++++++--- .../tycho/core/osgitools/OsgiManifest.java | 4 ++++ .../tycho/packaging/PackagePluginMojo.java | 7 ++++-- 4 files changed, 34 insertions(+), 7 deletions(-) diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleReader.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleReader.java index 794a9c9580..181240f73b 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleReader.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/BundleReader.java @@ -13,6 +13,7 @@ package org.eclipse.tycho.core.osgitools; import java.io.File; +import java.io.IOException; /** * Cache for OSGi manifest files and bundle classpath entries. @@ -33,8 +34,8 @@ public interface BundleReader { * @throws InvalidOSGiManifestException * if valid MANIFEST is found but it does not have valid mandatory OSGi headers */ - public OsgiManifest loadManifest(File bundleLocation) throws OsgiManifestParserException, - InvalidOSGiManifestException; + public OsgiManifest loadManifest(File bundleLocation) + throws OsgiManifestParserException, InvalidOSGiManifestException; /** * Returns bundle entry with given path or null if no such entry exists. If bundle @@ -47,4 +48,6 @@ public OsgiManifest loadManifest(File bundleLocation) throws OsgiManifestParserE * */ public File getEntry(File bundleLocation, String path); + + File getManifestLocation(File directory) throws IOException; } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultBundleReader.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultBundleReader.java index 70bccbb1c9..df0ea71597 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultBundleReader.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/DefaultBundleReader.java @@ -23,6 +23,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Optional; +import java.util.Properties; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; import java.util.jar.JarFile; @@ -67,8 +68,7 @@ private OsgiManifest doLoadManifest(File bundleLocation) { return loadManifestFromFile(bundleLocation); } else { // file does not exist - throw new OsgiManifestParserException(new File(bundleLocation, JarFile.MANIFEST_NAME).getAbsolutePath(), - "Manifest file not found"); + throw new OsgiManifestParserException(bundleLocation.getAbsolutePath(), "Manifest file not found"); } } catch (IOException e) { throw new OsgiManifestParserException(bundleLocation.getAbsolutePath(), e); @@ -93,13 +93,30 @@ private OsgiManifest loadManifestFromFile(File bundleLocation) throws IOExceptio } private OsgiManifest loadManifestFromDirectory(File directory) throws IOException { - File manifestFile = new File(directory, JarFile.MANIFEST_NAME); + File manifestFile = getManifestLocation(directory); if (!manifestFile.isFile()) { throw new OsgiManifestParserException(manifestFile.getAbsolutePath(), "Manifest file not found"); } return loadManifestFile(manifestFile); } + @Override + public File getManifestLocation(File directory) throws IOException { + File defaultLocation = new File(directory, JarFile.MANIFEST_NAME); + if (!defaultLocation.isFile()) { + File pdePreferences = new File(directory, ".settings/org.eclipse.pde.core.prefs"); + if (pdePreferences.isFile()) { + Properties properties = new Properties(); + properties.load(new FileInputStream(pdePreferences)); + String property = properties.getProperty("BUNDLE_ROOT_PATH"); + if (property != null) { + return new File(new File(directory, property), JarFile.MANIFEST_NAME); + } + } + } + return defaultLocation; + } + private OsgiManifest loadManifestFile(File manifestFile) throws IOException, OsgiManifestParserException { return OsgiManifest.parse(new FileInputStream(manifestFile), manifestFile.getAbsolutePath()); } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiManifest.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiManifest.java index 3ea0ab2bfd..7a6e1ca742 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiManifest.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/OsgiManifest.java @@ -130,6 +130,10 @@ public String[] getExecutionEnvironments() { return executionEnvironments; } + public String getLocation() { + return location; + } + /** * Returns true if Eclipse-BundleShape header is set to dir. * diff --git a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/PackagePluginMojo.java b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/PackagePluginMojo.java index 5ac3b6473d..7ede96b568 100644 --- a/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/PackagePluginMojo.java +++ b/tycho-packaging-plugin/src/main/java/org/eclipse/tycho/packaging/PackagePluginMojo.java @@ -49,6 +49,7 @@ import org.eclipse.tycho.core.BundleProject; import org.eclipse.tycho.core.TychoProject; import org.eclipse.tycho.core.TychoProjectManager; +import org.eclipse.tycho.core.osgitools.BundleReader; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; import org.eclipse.tycho.core.osgitools.OsgiBundleProject; import org.eclipse.tycho.core.osgitools.project.BuildOutputJar; @@ -148,6 +149,9 @@ public class PackagePluginMojo extends AbstractTychoPackagingMojo { @Component TychoProjectManager projectManager; + @Component + private BundleReader bundleReader; + @Override public void execute() throws MojoExecutionException { @@ -304,10 +308,9 @@ protected Manifest getManifest() throws IOException, MojoExecutionException { final File archiveManifestFile = archive.getManifestFile(); final File manifestFile = archiveManifestFile != null ? archiveManifestFile - : new File(project.getBasedir(), "META-INF/MANIFEST.MF"); + : bundleReader.getManifestLocation(project.getBasedir()); Manifest mf; - try (final InputStream is = new FileInputStream(manifestFile)) { mf = new Manifest(is); }