From 4b46fa82a7a1e79b883cc605bf5fd97a847d07c9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 17 Dec 2023 06:11:16 +0100 Subject: [PATCH 1/9] Enable Platform Verification to analyze Build failures --- .github/workflows/verify-platform.yml | 4 ++-- .github/workflows/verify-platform2.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/verify-platform.yml b/.github/workflows/verify-platform.yml index 12d55f76ab..25e18e8a63 100644 --- a/.github/workflows/verify-platform.yml +++ b/.github/workflows/verify-platform.yml @@ -8,7 +8,7 @@ concurrency: on: pull_request: branches: - - 'master' + - 'tycho-4.0.x' jobs: build: @@ -69,5 +69,5 @@ jobs: -Dmaven.wagon.httpconnectionManager.ttlSeconds=120 -DskipTests -Pbree-libs - -Dtycho.version=4.0.0-SNAPSHOT + -Dtycho.version=4.0.5-SNAPSHOT clean verify diff --git a/.github/workflows/verify-platform2.yml b/.github/workflows/verify-platform2.yml index d572a36c59..2759f02c25 100644 --- a/.github/workflows/verify-platform2.yml +++ b/.github/workflows/verify-platform2.yml @@ -8,7 +8,7 @@ concurrency: on: pull_request: branches: - - 'master' + - 'tycho-4.0.x' jobs: build: @@ -69,6 +69,6 @@ jobs: -Pbuild-individual-bundles -Pbree-libs -Dmaven.test.failure.ignore=true - -Dtycho.version=4.0.0-SNAPSHOT + -Dtycho.version=4.0.5-SNAPSHOT -T1C clean verify From 483db4c2e4a52405ce1eba4559b5a9f2e42bbecc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Sun, 17 Dec 2023 12:26:00 +0100 Subject: [PATCH 2/9] Add support for resolving target platform projects Currently target-platform projects do not have any resolved dependencies, this has a few disadvantages: - if one want to see the dependency tree it is empty - if one wants to mirror a target platform this can't be performed This adds support for target platform projects to resolve and have their dependencies injected to support such advanced use-cases. --- .../core/osgitools/TargetPlatformProject.java | 97 +++++++++++++++++++ .../p2resolver/P2DependencyResolver.java | 70 ++++++++----- 2 files changed, 142 insertions(+), 25 deletions(-) create mode 100644 tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java new file mode 100644 index 0000000000..f9c2bba376 --- /dev/null +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java @@ -0,0 +1,97 @@ +/******************************************************************************* + * 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.io.File; +import java.util.List; +import java.util.Set; + +import org.apache.maven.execution.MavenSession; +import org.apache.maven.project.MavenProject; +import org.codehaus.plexus.component.annotations.Component; +import org.eclipse.equinox.p2.metadata.IArtifactKey; +import org.eclipse.equinox.p2.metadata.IInstallableUnit; +import org.eclipse.tycho.ArtifactKey; +import org.eclipse.tycho.DefaultArtifactKey; +import org.eclipse.tycho.DependencyArtifacts; +import org.eclipse.tycho.PackagingType; +import org.eclipse.tycho.ReactorProject; +import org.eclipse.tycho.TargetPlatform; +import org.eclipse.tycho.TychoConstants; +import org.eclipse.tycho.core.ArtifactDependencyVisitor; +import org.eclipse.tycho.core.ArtifactDependencyWalker; +import org.eclipse.tycho.core.TychoProject; +import org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts; +import org.eclipse.tycho.core.resolver.target.ArtifactTypeHelper; +import org.eclipse.tycho.model.Feature; +import org.eclipse.tycho.model.ProductConfiguration; +import org.eclipse.tycho.model.UpdateSite; +import org.eclipse.tycho.targetplatform.P2TargetPlatform; + +@Component(role = TychoProject.class, hint = PackagingType.TYPE_ECLIPSE_TARGET_DEFINITION) +public class TargetPlatformProject extends AbstractTychoProject { + + @Override + public ArtifactDependencyWalker getDependencyWalker(ReactorProject project) { + return new ArtifactDependencyWalker() { + + @Override + public void walk(ArtifactDependencyVisitor visitor) { + + } + + @Override + public void traverseUpdateSite(UpdateSite site, ArtifactDependencyVisitor visitor) { + + } + + @Override + public void traverseProduct(ProductConfiguration productConfiguration, ArtifactDependencyVisitor visitor) { + + } + + @Override + public void traverseFeature(File location, Feature feature, ArtifactDependencyVisitor visitor) { + + } + }; + } + + @Override + public ArtifactKey getArtifactKey(ReactorProject project) { + return new DefaultArtifactKey("target", project.getArtifactId(), project.getVersion()); + } + + @Override + public DependencyArtifacts getDependencyArtifacts(ReactorProject reactorProject) { + return reactorProject.computeContextValue(TychoConstants.CTX_DEPENDENCY_ARTIFACTS, () -> { + DefaultDependencyArtifacts artifacts = new DefaultDependencyArtifacts(reactorProject); + MavenSession mavenSession = getMavenSession(reactorProject); + MavenProject mavenProject = getMavenProject(reactorProject); + TargetPlatform targetPlatform = dependencyResolver.computePreliminaryTargetPlatform(mavenSession, + mavenProject); + if (targetPlatform instanceof P2TargetPlatform p2) { + Set installableUnits = p2.getInstallableUnits(); + for (IInstallableUnit iu : installableUnits) { + for (IArtifactKey key : iu.getArtifacts()) { + ArtifactKey artifactKey = ArtifactTypeHelper.toTychoArtifactKey(iu, key); + artifacts.addArtifactFile(artifactKey, () -> targetPlatform.getArtifactLocation(artifactKey), + List.of(iu)); + } + } + } + return artifacts; + }); + } + +} 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 460d4ab32b..38b56fb308 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 @@ -62,6 +62,7 @@ import org.eclipse.tycho.MavenDependencyDescriptor; import org.eclipse.tycho.MavenRepositoryLocation; import org.eclipse.tycho.OptionalResolutionAction; +import org.eclipse.tycho.PackagingType; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.TargetPlatform; @@ -83,6 +84,7 @@ import org.eclipse.tycho.core.resolver.P2ResolutionResult; import org.eclipse.tycho.core.resolver.P2Resolver; import org.eclipse.tycho.core.resolver.P2ResolverFactory; +import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; import org.eclipse.tycho.core.resolver.shared.PomDependencies; import org.eclipse.tycho.helper.PluginRealmHelper; import org.eclipse.tycho.p2.metadata.DependencyMetadataGenerator; @@ -95,6 +97,8 @@ import org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManager; import org.eclipse.tycho.resolver.P2MetadataProvider; import org.eclipse.tycho.targetplatform.TargetDefinitionFile; +import org.eclipse.tycho.targetplatform.TargetPlatformArtifactResolver; +import org.eclipse.tycho.targetplatform.TargetResolveException; @Component(role = DependencyResolver.class, hint = P2DependencyResolver.ROLE_HINT, instantiationStrategy = "per-lookup") public class P2DependencyResolver implements DependencyResolver, Initializable { @@ -149,22 +153,26 @@ public class P2DependencyResolver implements DependencyResolver, Initializable { @Override public void setupProjects(final MavenSession session, final MavenProject project, final ReactorProject reactorProject) { - TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(project); - List environments = configuration.getEnvironments(); - Collection metadataMap = getDependencyMetadata(session, project, environments, - OptionalResolutionAction.OPTIONAL); - Map> typeMap = new TreeMap<>(); - for (DependencyMetadataType type : DependencyMetadataType.values()) { - typeMap.put(type, new LinkedHashSet<>()); - } - for (IDependencyMetadata metadata : metadataMap) { - typeMap.forEach((key, value) -> value.addAll(metadata.getDependencyMetadata(key))); - } Set initial = new HashSet<>(); - typeMap.forEach((key, value) -> { - reactorProject.setDependencyMetadata(key, value); - initial.addAll(value); - }); + if (PackagingType.TYPE_ECLIPSE_TARGET_DEFINITION.equals(project.getPackaging())) { + //Target projects do not have any (initial) dependency metadata + } else { + TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(project); + List environments = configuration.getEnvironments(); + Collection metadataMap = getDependencyMetadata(session, project, environments, + OptionalResolutionAction.OPTIONAL); + Map> typeMap = new TreeMap<>(); + for (DependencyMetadataType type : DependencyMetadataType.values()) { + typeMap.put(type, new LinkedHashSet<>()); + } + for (IDependencyMetadata metadata : metadataMap) { + typeMap.forEach((key, value) -> value.addAll(metadata.getDependencyMetadata(key))); + } + typeMap.forEach((key, value) -> { + reactorProject.setDependencyMetadata(key, value); + initial.addAll(value); + }); + } reactorProject.setDependencyMetadata(DependencyMetadataType.INITIAL, initial); } @@ -202,23 +210,35 @@ public TargetPlatform computePreliminaryTargetPlatform(MavenSession mavenSession logger.debug("Computing preliminary target platform for " + mavenProject); List reactorProjects = DefaultReactorProject.adapt(mavenSession); TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(mavenProject); - ExecutionEnvironmentConfiguration ee = projectManager.getExecutionEnvironmentConfiguration(mavenProject); - TargetPlatformConfigurationStub tpConfiguration = new TargetPlatformConfigurationStub(); + ExecutionEnvironmentConfiguration ee = projectManager.getExecutionEnvironmentConfiguration(mavenProject); for (ArtifactRepository repository : mavenProject.getRemoteArtifactRepositories()) { addEntireP2RepositoryToTargetPlatform(repository, tpConfiguration); } - tpConfiguration.setEnvironments(configuration.getEnvironments()); - for (TargetDefinitionFile target : configuration.getTargets()) { - tpConfiguration.addTargetDefinition(target); - } - tpConfiguration.addFilters(configuration.getFilters()); - tpConfiguration.setIncludeSourceMode(configuration.getTargetDefinitionIncludeSourceMode()); - tpConfiguration - .setIgnoreLocalArtifacts(configuration.getIgnoreLocalArtifacts() == LocalArtifactHandling.ignore); tpConfiguration.setReferencedRepositoryMode(configuration.getReferencedRepositoryMode()); + if (PackagingType.TYPE_ECLIPSE_TARGET_DEFINITION.equals(mavenProject.getPackaging())) { + //for target definition project itself we only want the main target to be considered + try { + File targetFile = TargetPlatformArtifactResolver.getMainTargetFile(mavenProject); + TargetDefinitionFile targetDefinitionFile = TargetDefinitionFile.read(targetFile); + tpConfiguration.addTargetDefinition(targetDefinitionFile); + } catch (TargetResolveException e) { + logger.warn("Can't read main target definition file from project " + mavenProject.getId(), e); + } + //also we always want to ignore sources + tpConfiguration.setIncludeSourceMode(IncludeSourceMode.ignore); + //and local artifacts + tpConfiguration.setIgnoreLocalArtifacts(true); + } else { + for (TargetDefinitionFile target : configuration.getTargets()) { + tpConfiguration.addTargetDefinition(target); + } + tpConfiguration.setIncludeSourceMode(configuration.getTargetDefinitionIncludeSourceMode()); + tpConfiguration.setIgnoreLocalArtifacts( + configuration.getIgnoreLocalArtifacts() == LocalArtifactHandling.ignore); + } TargetPlatform result = tpFactory.createTargetPlatform(tpConfiguration, ee, reactorProjects, reactorProject); return result; From f1bd2e2d6007b1ff2c2257cfb76c07e046c365cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 18 Dec 2023 07:27:27 +0100 Subject: [PATCH 3/9] Compute a final target platform for target projects --- .../org/eclipse/tycho/TargetPlatform.java | 4 + .../tycho/core/DependencyResolver.java | 2 +- .../core/osgitools/AbstractTychoProject.java | 2 +- .../core/osgitools/OsgiBundleProject.java | 2 +- .../core/osgitools/TargetPlatformProject.java | 2 +- .../DefaultTargetPlatformService.java | 124 ++++++++++-------- .../p2resolver/P2DependencyResolver.java | 2 +- 7 files changed, 76 insertions(+), 62 deletions(-) diff --git a/tycho-api/src/main/java/org/eclipse/tycho/TargetPlatform.java b/tycho-api/src/main/java/org/eclipse/tycho/TargetPlatform.java index 99b2572379..ffbb72eb09 100644 --- a/tycho-api/src/main/java/org/eclipse/tycho/TargetPlatform.java +++ b/tycho-api/src/main/java/org/eclipse/tycho/TargetPlatform.java @@ -33,6 +33,10 @@ public interface TargetPlatform { * Key under which the final target platform is stored in the reactor project instances. */ String FINAL_TARGET_PLATFORM_KEY = "org.eclipse.tycho.core.TychoConstants/targetPlatform"; + + /** + * Key under which the preliminary target platform is stored in the reactor project instances. + */ String PRELIMINARY_TARGET_PLATFORM_KEY = "org.eclipse.tycho.core.TychoConstants/dependencyOnlyTargetPlatform"; /** 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 736d659ce0..96acc2708e 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/DependencyResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/DependencyResolver.java @@ -33,7 +33,7 @@ public interface DependencyResolver { PomDependencyCollector resolvePomDependencies(MavenSession session, MavenProject project); - public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, MavenProject project); + public TargetPlatform getPreliminaryTargetPlatform(MavenSession session, MavenProject project); /** * @param targetPlatform 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 7fb65b8e67..8a4a0cf2ae 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/AbstractTychoProject.java @@ -80,7 +80,7 @@ public DependencyArtifacts getDependencyArtifacts(ReactorProject reactorProject) } MavenSession mavenSession = getMavenSession(reactorProject); MavenProject mavenProject = getMavenProject(reactorProject); - TargetPlatform preliminaryTargetPlatform = dependencyResolver.computePreliminaryTargetPlatform(mavenSession, + TargetPlatform preliminaryTargetPlatform = dependencyResolver.getPreliminaryTargetPlatform(mavenSession, mavenProject); TargetPlatformConfiguration configuration = projectManager.getTargetPlatformConfiguration(mavenProject); DependencyResolverConfiguration resolverConfiguration = configuration.getDependencyResolverConfiguration(); 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 162a8b8afe..5c51557638 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 @@ -711,7 +711,7 @@ public Collection getAdditionalRequirements() { return resolverConfiguration.getAdditionalRequirements(); } }; - TargetPlatform preliminaryTargetPlatform = dependencyResolver.computePreliminaryTargetPlatform(mavenSession, + TargetPlatform preliminaryTargetPlatform = dependencyResolver.getPreliminaryTargetPlatform(mavenSession, mavenProject); return dependencyResolver.resolveDependencies(mavenSession, mavenProject, preliminaryTargetPlatform, testResolverConfiguration, configuration.getEnvironments()); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java index f9c2bba376..fca2c72aab 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/osgitools/TargetPlatformProject.java @@ -78,7 +78,7 @@ public DependencyArtifacts getDependencyArtifacts(ReactorProject reactorProject) DefaultDependencyArtifacts artifacts = new DefaultDependencyArtifacts(reactorProject); MavenSession mavenSession = getMavenSession(reactorProject); MavenProject mavenProject = getMavenProject(reactorProject); - TargetPlatform targetPlatform = dependencyResolver.computePreliminaryTargetPlatform(mavenSession, + TargetPlatform targetPlatform = dependencyResolver.getPreliminaryTargetPlatform(mavenSession, mavenProject); if (targetPlatform instanceof P2TargetPlatform p2) { Set installableUnits = p2.getInstallableUnits(); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformService.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformService.java index 3c16ed915d..cadd674cb2 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformService.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/DefaultTargetPlatformService.java @@ -16,6 +16,7 @@ import java.io.File; import java.util.ArrayList; import java.util.Collection; +import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Optional; @@ -27,7 +28,13 @@ import org.codehaus.plexus.component.annotations.Component; import org.codehaus.plexus.component.annotations.Requirement; import org.codehaus.plexus.logging.Logger; +import org.eclipse.equinox.p2.core.IProvisioningAgent; +import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; +import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; +import org.eclipse.tycho.ArtifactKey; import org.eclipse.tycho.DependencyResolutionException; +import org.eclipse.tycho.IllegalArtifactReferenceException; +import org.eclipse.tycho.PackagingType; import org.eclipse.tycho.ReactorProject; import org.eclipse.tycho.ReactorProjectIdentities; import org.eclipse.tycho.TargetPlatform; @@ -35,12 +42,13 @@ import org.eclipse.tycho.TychoConstants; import org.eclipse.tycho.core.DependencyResolver; import org.eclipse.tycho.core.osgitools.DefaultReactorProject; +import org.eclipse.tycho.core.resolver.target.SupplierMetadataRepository; import org.eclipse.tycho.p2.repository.GAV; import org.eclipse.tycho.p2.repository.PublishingRepository; import org.eclipse.tycho.p2.target.facade.PomDependencyCollector; import org.eclipse.tycho.p2.target.facade.TargetPlatformFactory; -import org.eclipse.tycho.p2resolver.PreliminaryTargetPlatformImpl; import org.eclipse.tycho.repository.registry.facade.ReactorRepositoryManager; +import org.eclipse.tycho.targetplatform.P2TargetPlatform; @Component(role = TargetPlatformService.class) public class DefaultTargetPlatformService implements TargetPlatformService { @@ -63,6 +71,9 @@ public class DefaultTargetPlatformService implements TargetPlatformService { @Requirement private TargetPlatformFactory tpFactory; + @Requirement + private IProvisioningAgent agent; + @Override public Optional getTargetPlatform() throws DependencyResolutionException { MavenSession session = legacySupport.getSession(); @@ -78,61 +89,67 @@ public Optional getTargetPlatform() throws DependencyResolutionE @Override public Optional getTargetPlatform(ReactorProject project) throws DependencyResolutionException { - synchronized (project) { - Object contextValue = project.getContextValue(TargetPlatform.FINAL_TARGET_PLATFORM_KEY); - if (contextValue instanceof TargetPlatform) { - return Optional.of((TargetPlatform) contextValue); - } - MavenSession session = legacySupport.getSession(); - if (repositoryManager == null || session == null) { - return Optional.empty(); - } - List upstreamProjects = getReferencedTychoProjects(project); - PomDependencyCollector pomDependenciesCollector = dependencyResolver.resolvePomDependencies(session, - project.adapt(MavenProject.class)); - TargetPlatform finalTargetPlatform = computeFinalTargetPlatform(project, upstreamProjects, - pomDependenciesCollector); - return Optional.ofNullable(finalTargetPlatform); + Object contextValue = project.getContextValue(TargetPlatform.FINAL_TARGET_PLATFORM_KEY); + if (contextValue instanceof TargetPlatform) { + return Optional.of((TargetPlatform) contextValue); + } + if (repositoryManager == null || project.adapt(MavenSession.class) == null) { + return Optional.empty(); } + return Optional.ofNullable(computeFinalTargetPlatform(project)); } - /** - * Computes the (immutable) target platform with final p2 metadata and attaches it to the given - * project. - * - * @param project - * the reactor project to compute the target platform for. - * @param upstreamProjects - * Other projects in the reactor which have already been built and may be referenced - * by the given project. - */ - private TargetPlatform computeFinalTargetPlatform(ReactorProject project, - List upstreamProjects, PomDependencyCollector pomDependencyCollector) { - synchronized (project) { - PreliminaryTargetPlatformImpl preliminaryTargetPlatform = getRegisteredPreliminaryTargetPlatform(project); - if (preliminaryTargetPlatform == null) { - MavenSession session = project.adapt(MavenSession.class); - if (session == null) { - session = legacySupport.getSession(); - if (session == null) { - return null; - } + private TargetPlatform computeFinalTargetPlatform(ReactorProject project) { + return project.computeContextValue(TargetPlatform.FINAL_TARGET_PLATFORM_KEY, () -> { + MavenProject mavenProject = project.adapt(MavenProject.class); + MavenSession mavenSession = project.adapt(MavenSession.class); + TargetPlatform preliminaryTargetPlatform = dependencyResolver.getPreliminaryTargetPlatform(mavenSession, + mavenProject); + if (PackagingType.TYPE_ECLIPSE_TARGET_DEFINITION.equals(mavenProject.getPackaging())) { + IMetadataRepository metadataRepository; + if (preliminaryTargetPlatform instanceof P2TargetPlatform p2) { + metadataRepository = new SupplierMetadataRepository(agent, + () -> p2.getInstallableUnits().iterator()); + } else { + metadataRepository = new SupplierMetadataRepository(agent, () -> Collections.emptyIterator()); } - MavenProject mavenProject = project.adapt(MavenProject.class); - if (mavenProject == null) { - return null; - } - preliminaryTargetPlatform = (PreliminaryTargetPlatformImpl) dependencyResolver - .computePreliminaryTargetPlatform(session, mavenProject); + return new TargetPlatform() { - } - List upstreamProjectResults = getBuildResults(upstreamProjects); - TargetPlatform result = tpFactory.createTargetPlatformWithUpdatedReactorContent(preliminaryTargetPlatform, - upstreamProjectResults, pomDependencyCollector); + @Override + public ArtifactKey resolveArtifact(String type, String id, String versionRef) + throws IllegalArtifactReferenceException, DependencyResolutionException { + return preliminaryTargetPlatform.resolveArtifact(type, id, versionRef); + } - project.setContextValue(TargetPlatform.FINAL_TARGET_PLATFORM_KEY, result); - return result; - } + @Override + public boolean isFileAlreadyAvailable(ArtifactKey artifactKey) { + return preliminaryTargetPlatform.isFileAlreadyAvailable(artifactKey); + } + + @Override + public IMetadataRepository getMetadataRepository() { + return metadataRepository; + } + + @Override + public IArtifactRepository getArtifactRepository() { + return preliminaryTargetPlatform.getArtifactRepository(); + } + + @Override + public File getArtifactLocation(ArtifactKey artifact) { + return preliminaryTargetPlatform.getArtifactLocation(artifact); + } + }; + } else { + List upstreamProjects = getReferencedTychoProjects(project); + PomDependencyCollector pomDependenciesCollector = dependencyResolver + .resolvePomDependencies(mavenSession, project.adapt(MavenProject.class)); + List upstreamProjectResults = getBuildResults(upstreamProjects); + return tpFactory.createTargetPlatformWithUpdatedReactorContent(preliminaryTargetPlatform, + upstreamProjectResults, pomDependenciesCollector); + } + }); } private List getBuildResults(List projects) { @@ -143,13 +160,6 @@ private List getBuildResults(List getReferencedTychoProjects(ReactorProject reactorProject) throws DependencyResolutionException { List result = new ArrayList<>(); 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 38b56fb308..54f6d7473a 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 @@ -204,7 +204,7 @@ protected Collection getDependencyMetadata(final MavenSessi } @Override - public TargetPlatform computePreliminaryTargetPlatform(MavenSession mavenSession, MavenProject mavenProject) { + public TargetPlatform getPreliminaryTargetPlatform(MavenSession mavenSession, MavenProject mavenProject) { ReactorProject reactorProject = DefaultReactorProject.adapt(mavenProject); return reactorProject.computeContextValue(TargetPlatform.PRELIMINARY_TARGET_PLATFORM_KEY, () -> { logger.debug("Computing preliminary target platform for " + mavenProject); From f3a481dff23796ada327b42360cc37875da737ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 18 Dec 2023 06:37:41 +0100 Subject: [PATCH 4/9] Disable P2 mirror lists by default because they are unstable --- ...ArtifactRepositoryManagerAgentFactory.java | 40 +++++++++---------- src/site/markdown/SystemProperties.md | 9 +++++ .../P2RepositoryPropertiesTest.java | 6 +++ .../test/AbstractTychoIntegrationTest.java | 11 +++++ 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/RemoteArtifactRepositoryManagerAgentFactory.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/RemoteArtifactRepositoryManagerAgentFactory.java index c936a1669c..0f638c3ea4 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/RemoteArtifactRepositoryManagerAgentFactory.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/transport/RemoteArtifactRepositoryManagerAgentFactory.java @@ -20,11 +20,12 @@ import org.eclipse.equinox.p2.core.spi.IAgentServiceFactory; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.tycho.IRepositoryIdManager; +import org.eclipse.tycho.version.TychoVersion; @Component(role = IAgentServiceFactory.class, hint = "org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager") public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServiceFactory { - @Requirement + @Requirement Logger logger; @Requirement @@ -33,26 +34,25 @@ public class RemoteArtifactRepositoryManagerAgentFactory implements IAgentServic @Requirement MavenAuthenticator authenticator; - @Override - public Object createService(IProvisioningAgent agent) { - IArtifactRepositoryManager plainRepoManager = (IArtifactRepositoryManager) new ArtifactRepositoryComponent() - .createService(agent); - if (getDisableP2MirrorsConfiguration()) { - plainRepoManager = new P2MirrorDisablingArtifactRepositoryManager(plainRepoManager, - logger); - } + @Override + public Object createService(IProvisioningAgent agent) { + IArtifactRepositoryManager plainRepoManager = (IArtifactRepositoryManager) new ArtifactRepositoryComponent() + .createService(agent); + if (getDisableP2MirrorsConfiguration()) { + plainRepoManager = new P2MirrorDisablingArtifactRepositoryManager(plainRepoManager, logger); + } return new RemoteArtifactRepositoryManager(plainRepoManager, repositoryIdManager, authenticator); - } + } - private boolean getDisableP2MirrorsConfiguration() { - String key = "tycho.disableP2Mirrors"; + private boolean getDisableP2MirrorsConfiguration() { + String key = "tycho.disableP2Mirrors"; String value = System.getProperty(key); - - boolean disableP2Mirrors = Boolean.parseBoolean(value); - if (disableP2Mirrors && logger.isDebugEnabled()) { - String message = key + "=" + value + " -> ignoring mirrors specified in p2 artifact repositories"; - logger.debug(message); - } - return disableP2Mirrors; - } + if (value != null) { + logger.info("Using " + key + + " to disable P2 mirrors is deprecated, use the property eclipse.p2.mirrors instead, see https://tycho.eclipseprojects.io/doc/" + + TychoVersion.getTychoVersion() + "/SystemProperties.html for details."); + return Boolean.parseBoolean(value); + } + return false; + } } diff --git a/src/site/markdown/SystemProperties.md b/src/site/markdown/SystemProperties.md index 4890aed2da..7ba6c87471 100644 --- a/src/site/markdown/SystemProperties.md +++ b/src/site/markdown/SystemProperties.md @@ -26,3 +26,12 @@ Name | Value | Default | Documentation --- | --- | --- tycho.comparator.showDiff | true / false | false | If set to true if text-like files show a unified diff of possible differences in files tycho.comparator.threshold | bytes | 5242880 (~5MB) | gives the number of bytes for content to be compared semantically, larger files will only be compared byte-by-byte + +### P2 + +These properties control the behaviour of P2 used by Tycho + +Name | Value | Default | Documentation +--- | --- | --- +eclipse.p2.mirrors | true / false | true | Each p2 site can define a list of artifact repository mirrors, this controls if P2 mirrors should be used. This is independent from configuring mirrors in the maven configuration to be used by Tycho! + diff --git a/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryPropertiesTest.java b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryPropertiesTest.java index 0a4714c5d8..56c41f2147 100644 --- a/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryPropertiesTest.java +++ b/tycho-its/src/test/java/org/eclipse/tycho/test/p2Repository/P2RepositoryPropertiesTest.java @@ -78,4 +78,10 @@ public void testPropertyPropagation() throws Exception { assertTrue(properties.containsKey(TychoConstants.PROP_PGP_SIGNATURES) && !properties.get(TychoConstants.PROP_PGP_SIGNATURES).isBlank()); } + + @Override + protected boolean isDisableMirrors() { + // we want to test mirror properties... + return false; + } } diff --git a/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/AbstractTychoIntegrationTest.java b/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/AbstractTychoIntegrationTest.java index 10e53fb2e4..1862059973 100644 --- a/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/AbstractTychoIntegrationTest.java +++ b/tycho-testing-harness/src/main/java/org/eclipse/tycho/test/AbstractTychoIntegrationTest.java @@ -90,6 +90,9 @@ protected Verifier getVerifier(String test, boolean setTargetPlatform, File user Verifier verifier = new Verifier(testDir.getAbsolutePath()); verifier.setForkJvm(isForked()); + if (isDisableMirrors()) { + verifier.setSystemProperty("eclipse.p2.mirrors", "false"); + } String debug = System.getProperty("tycho.mvnDebug"); if (debug != null) { System.out.println("Preparing to execute Maven in debug mode"); @@ -145,6 +148,14 @@ protected Verifier getVerifier(String test, boolean setTargetPlatform, File user return verifier; } + + /** + * can be overridden by subclass to explicitly enable mirrors, by default they are disabled. + * + */ + protected boolean isDisableMirrors() { + return true; + } protected boolean isForked() { return true; From 62df62b5e545b4fcc39d3828129f9b7957979b7e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 18 Dec 2023 23:16:02 +0000 Subject: [PATCH 5/9] Bump org.apache.maven.plugins:maven-compiler-plugin Bumps [org.apache.maven.plugins:maven-compiler-plugin](https://github.com/apache/maven-compiler-plugin) from 3.11.0 to 3.12.0. - [Release notes](https://github.com/apache/maven-compiler-plugin/releases) - [Commits](https://github.com/apache/maven-compiler-plugin/compare/maven-compiler-plugin-3.11.0...maven-compiler-plugin-3.12.0) --- updated-dependencies: - dependency-name: org.apache.maven.plugins:maven-compiler-plugin 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 1de482ef01..fc175641b2 100644 --- a/pom.xml +++ b/pom.xml @@ -386,7 +386,7 @@ org.apache.maven.plugins maven-compiler-plugin - 3.11.0 + 3.12.0 ${min.jdk.version} ${min.jdk.version} From 614ea025b8e8f99ebd1b13807cc70ab4330c6d87 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Tue, 19 Dec 2023 17:35:49 +0100 Subject: [PATCH 6/9] Ignore dependencies if they are not meant to be added to the classpath --- .../compiler/AbstractOsgiCompilerMojo.java | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) 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 05598dd3c8..e052d7cc59 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 @@ -40,6 +40,7 @@ import java.util.stream.Stream; import org.apache.maven.artifact.Artifact; +import org.apache.maven.artifact.handler.ArtifactHandler; import org.apache.maven.artifact.repository.ArtifactRepository; import org.apache.maven.execution.MavenSession; import org.apache.maven.model.Dependency; @@ -610,14 +611,26 @@ public List getClasspathElements() throws MojoExecutionException { .filter(a -> includedPathes.add(a.getFile().getAbsolutePath())) // .toList(); for (Artifact artifact : additionalClasspathEntries) { - String path = artifact.getFile().getAbsolutePath(); - getLog().debug("Add a pom only classpath entry: " + artifact + " @ " + path); - classpath.add(path); + ArtifactHandler artifactHandler = artifact.getArtifactHandler(); + if (artifactHandler.isAddedToClasspath() && inScope(artifact.getScope())) { + String path = artifact.getFile().getAbsolutePath(); + getLog().debug("Add a pom only classpath entry: " + artifact + " @ " + path); + classpath.add(path); + } } } return classpath; } + private boolean inScope(String dependencyScope) { + if (Artifact.SCOPE_COMPILE.equals(getDependencyScope())) { + if (Artifact.SCOPE_TEST.equals(dependencyScope)) { + return false; + } + } + return true; + } + private static boolean isValidLocation(File location) { if (location == null || !location.exists() || (location.isFile() && location.length() == 0)) { return false; From 87be6c8636ca531e47968b4b248391eb560b8dde Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 19 Dec 2023 23:27:55 +0000 Subject: [PATCH 7/9] Bump jetty.version from 11.0.18 to 11.0.19 Bumps `jetty.version` from 11.0.18 to 11.0.19. Updates `org.eclipse.jetty:jetty-http` from 11.0.18 to 11.0.19 - [Release notes](https://github.com/jetty/jetty.project/releases) - [Commits](https://github.com/jetty/jetty.project/compare/jetty-11.0.18...jetty-11.0.19) Updates `org.eclipse.jetty:jetty-server` from 11.0.18 to 11.0.19 - [Release notes](https://github.com/jetty/jetty.project/releases) - [Commits](https://github.com/jetty/jetty.project/compare/jetty-11.0.18...jetty-11.0.19) Updates `org.eclipse.jetty:jetty-servlet` from 11.0.18 to 11.0.19 - [Release notes](https://github.com/jetty/jetty.project/releases) - [Commits](https://github.com/jetty/jetty.project/compare/jetty-11.0.18...jetty-11.0.19) --- updated-dependencies: - dependency-name: org.eclipse.jetty:jetty-http dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-server dependency-type: direct:development update-type: version-update:semver-patch - dependency-name: org.eclipse.jetty:jetty-servlet dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- tycho-core/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tycho-core/pom.xml b/tycho-core/pom.xml index e55ce9a699..cf0a4647da 100644 --- a/tycho-core/pom.xml +++ b/tycho-core/pom.xml @@ -23,7 +23,7 @@ Tycho Core Core Tycho components - 11.0.18 + 11.0.19 From 87049342f55cfc3cb98d4f2534f2f1faa6de3503 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Tue, 19 Dec 2023 06:13:39 +0100 Subject: [PATCH 8/9] Batch adding extra properties / remove pack file attribute (cherry picked from commit 7e8005b17da486efa959db12fb52ed94ef7d48f3) --- .../eclipse/tycho/p2tools/TychoMirrorApplication.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2tools/TychoMirrorApplication.java b/tycho-core/src/main/java/org/eclipse/tycho/p2tools/TychoMirrorApplication.java index b9fc834736..8406843f51 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2tools/TychoMirrorApplication.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2tools/TychoMirrorApplication.java @@ -85,9 +85,12 @@ public TychoMirrorApplication(IProvisioningAgent agent, DestinationRepositoryDes protected IArtifactRepository initializeDestination(RepositoryDescriptor toInit, IArtifactRepositoryManager mgr) throws ProvisionException { IArtifactRepository result = super.initializeDestination(toInit, mgr); - // simple.SimpleArtifactRepository.PUBLISH_PACK_FILES_AS_SIBLINGS is not public - result.setProperty("publishPackFilesAsSiblings", "true"); - destination.getExtraArtifactRepositoryProperties().forEach(result::setProperty); + Map extraArtifactRepositoryProperties = destination.getExtraArtifactRepositoryProperties(); + if (!extraArtifactRepositoryProperties.isEmpty()) { + result.executeBatch(nil -> { + extraArtifactRepositoryProperties.forEach(result::setProperty); + }, null); + } return result; } From 049acfb59e8e4d0e2084ebbd89201812dae485e0 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Wed, 20 Dec 2023 23:33:31 +0000 Subject: [PATCH 9/9] Bump plexusCompilerVersion from 2.14.1 to 2.14.2 Bumps `plexusCompilerVersion` from 2.14.1 to 2.14.2. Updates `org.codehaus.plexus:plexus-compiler-api` from 2.14.1 to 2.14.2 - [Release notes](https://github.com/codehaus-plexus/plexus-compiler/releases) - [Commits](https://github.com/codehaus-plexus/plexus-compiler/compare/plexus-compiler-2.14.1...plexus-compiler-2.14.2) Updates `org.codehaus.plexus:plexus-compiler-manager` from 2.14.1 to 2.14.2 - [Release notes](https://github.com/codehaus-plexus/plexus-compiler/releases) - [Commits](https://github.com/codehaus-plexus/plexus-compiler/compare/plexus-compiler-2.14.1...plexus-compiler-2.14.2) --- updated-dependencies: - dependency-name: org.codehaus.plexus:plexus-compiler-api dependency-type: direct:production update-type: version-update:semver-patch - dependency-name: org.codehaus.plexus:plexus-compiler-manager 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 fc175641b2..270ee8c1e7 100644 --- a/pom.xml +++ b/pom.xml @@ -60,7 +60,7 @@ 1.25.0 2.1.1 3.5.1 - 2.14.1 + 2.14.2 2.1.0 3.10.2 6.8.0.202311291450-r