From e5364713e03bc41676cc969ed829c0e8afdcc18f Mon Sep 17 00:00:00 2001 From: Titouan Vervack Date: Mon, 29 Apr 2024 18:09:13 +0200 Subject: [PATCH] Add support for followRepositoryReference in .target files This is the per-location setting that overrides TargetPlatformConfiguration#referencedRepositoryMode --- .../.settings/org.eclipse.jdt.core.prefs | 8 +++++ .../p2resolver/InstallableUnitResolver.java | 2 +- .../p2resolver/TargetDefinitionResolver.java | 12 ++++++- .../TargetDefinitionResolverTest.java | 5 +++ ...ResolverWithPlatformSpecificUnitsTest.java | 5 +++ .../tycho/versionbump/UpdateTargetMojo.java | 11 +++++++ tycho-p2/.settings/org.eclipse.jdt.core.prefs | 8 +++++ .../.settings/org.eclipse.jdt.core.prefs | 8 +++++ .../targetplatform/TargetDefinition.java | 22 ++++++++++++- .../targetplatform/TargetDefinitionFile.java | 33 +++++++++++++++++-- 10 files changed, 109 insertions(+), 5 deletions(-) create mode 100644 tycho-baseline-plugin/.settings/org.eclipse.jdt.core.prefs create mode 100644 tycho-p2/.settings/org.eclipse.jdt.core.prefs create mode 100644 tycho-surefire/org.eclipse.tycho.bnd.executionlistener/.settings/org.eclipse.jdt.core.prefs diff --git a/tycho-baseline-plugin/.settings/org.eclipse.jdt.core.prefs b/tycho-baseline-plugin/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..cf2cd4590a --- /dev/null +++ b/tycho-baseline-plugin/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/InstallableUnitResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/InstallableUnitResolver.java index c6524a233d..6edba2fa89 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/InstallableUnitResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/InstallableUnitResolver.java @@ -183,7 +183,7 @@ private ProjectorResolutionStrategy getPlannerResolutionStrategy(ResolutionData throws TargetDefinitionResolutionException { if (includeAllEnvironments) { logger.warn( - "includeAllPlatforms='true' and includeMode='planner' are incompatible. ignore includeAllPlatforms flag"); + "includeAllPlatforms='true' and includeMode='planner' are incompatible. Ignoring 'includeAllPlatforms' flag"); } ProjectorResolutionStrategy strategy = new ProjectorResolutionStrategy(logger); strategy.setData(data); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolver.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolver.java index c193452254..a2cd62978f 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolver.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolver.java @@ -63,6 +63,7 @@ import org.eclipse.tycho.targetplatform.TargetDefinition; import org.eclipse.tycho.targetplatform.TargetDefinition.DirectoryLocation; import org.eclipse.tycho.targetplatform.TargetDefinition.FeaturesLocation; +import org.eclipse.tycho.targetplatform.TargetDefinition.FollowRepositoryReferences; import org.eclipse.tycho.targetplatform.TargetDefinition.InstallableUnitLocation; import org.eclipse.tycho.targetplatform.TargetDefinition.Location; import org.eclipse.tycho.targetplatform.TargetDefinition.MavenGAVLocation; @@ -149,12 +150,21 @@ public TargetDefinitionContent resolveContentWithExceptions(TargetDefinition def includeSourceMode, logger); } List locations = new ArrayList<>(); + var followRepositoryReferences = installableUnitLocation.followRepositoryReferences(); + final ReferencedRepositoryMode followReferences; + if (followRepositoryReferences == FollowRepositoryReferences.DEFAULT) { + followReferences = referencedRepositoryMode; + } else if (followRepositoryReferences == FollowRepositoryReferences.ENABLED) { + followReferences = ReferencedRepositoryMode.include; + } else { + followReferences = ReferencedRepositoryMode.ignore; + } for (Repository repository : installableUnitLocation.getRepositories()) { URI location = resolveRepositoryLocation(repository.getLocation()); String key = location.normalize().toASCIIString(); locations.add( uriRepositories.computeIfAbsent(key, s -> new URITargetDefinitionContent(provisioningAgent, - location, repository.getId(), referencedRepositoryMode, logger))); + location, repository.getId(), followReferences, logger))); } IQueryable locationUnits = QueryUtil.compoundQueryable(locations); Collection rootUnits = installableUnitResolver diff --git a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverTest.java b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverTest.java index f05aeb264c..81717fa5c9 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverTest.java @@ -366,6 +366,11 @@ public boolean includeAllEnvironments() { public boolean includeSource() { return false; } + + @Override + public boolean includeConfigurePhase() { + return false; + } } private static class OtherLocationStub implements Location { diff --git a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverWithPlatformSpecificUnitsTest.java b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverWithPlatformSpecificUnitsTest.java index fbb9a72dd0..582a7c7f4a 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverWithPlatformSpecificUnitsTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverWithPlatformSpecificUnitsTest.java @@ -203,6 +203,11 @@ public boolean includeAllEnvironments() { public boolean includeSource() { return false; } + + @Override + public boolean includeConfigurePhase() { + return false; + } } } 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 3d1a1f1557..9c6e9dce55 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 @@ -35,6 +35,7 @@ import org.eclipse.tycho.core.resolver.P2ResolutionResult; import org.eclipse.tycho.p2resolver.TargetDefinitionVariableResolver; import org.eclipse.tycho.targetplatform.TargetDefinition; +import org.eclipse.tycho.targetplatform.TargetDefinition.FollowRepositoryReferences; import org.eclipse.tycho.targetplatform.TargetDefinition.IncludeMode; import org.eclipse.tycho.targetplatform.TargetDefinition.InstallableUnitLocation; import org.eclipse.tycho.targetplatform.TargetDefinition.Unit; @@ -170,6 +171,16 @@ public boolean includeSource() { return delegate.includeSource(); } + @Override + public boolean includeConfigurePhase() { + return delegate.includeConfigurePhase(); + } + + @Override + public FollowRepositoryReferences followRepositoryReferences() { + return delegate.followRepositoryReferences(); + } + } private static final class LatestVersionUnit implements TargetDefinition.Unit { diff --git a/tycho-p2/.settings/org.eclipse.jdt.core.prefs b/tycho-p2/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..cf2cd4590a --- /dev/null +++ b/tycho-p2/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=17 +org.eclipse.jdt.core.compiler.compliance=17 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=17 diff --git a/tycho-surefire/org.eclipse.tycho.bnd.executionlistener/.settings/org.eclipse.jdt.core.prefs b/tycho-surefire/org.eclipse.tycho.bnd.executionlistener/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..2f5cc74c3a --- /dev/null +++ b/tycho-surefire/org.eclipse.tycho.bnd.executionlistener/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 +org.eclipse.jdt.core.compiler.compliance=1.8 +org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore +org.eclipse.jdt.core.compiler.release=disabled +org.eclipse.jdt.core.compiler.source=1.8 diff --git a/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetDefinition.java b/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetDefinition.java index 1a0683df41..27bc5c2103 100644 --- a/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetDefinition.java +++ b/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetDefinition.java @@ -22,6 +22,7 @@ import java.util.List; import java.util.Properties; +import org.bouncycastle.jcajce.provider.drbg.DRBG.Default; import org.eclipse.tycho.IArtifactFacade; import org.eclipse.tycho.MavenArtifactRepositoryReference; import org.osgi.resource.Requirement; @@ -66,10 +67,16 @@ public interface Location { } + public enum FollowRepositoryReferences { + DEFAULT, + ENABLED, + DISABLED, + } + public interface InstallableUnitLocation extends Location { public static String TYPE = "InstallableUnit"; - + public List getRepositories(); public List getUnits(); @@ -79,6 +86,19 @@ public interface InstallableUnitLocation extends Location { public boolean includeAllEnvironments(); public boolean includeSource(); + + /** + * Read for completeness but not used + */ + public boolean includeConfigurePhase(); + + /** + * When {@link FollowRepositoryReferences.Default} the global {@link IncludeSourceMode} should be used instead. + * @return whether repository references should be used, never null + */ + public default FollowRepositoryReferences followRepositoryReferences() { + return FollowRepositoryReferences.DEFAULT; + } @Override public default String getTypeDescription() { diff --git a/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetDefinitionFile.java b/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetDefinitionFile.java index 53549f0cd5..01ecc755d2 100644 --- a/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetDefinitionFile.java +++ b/tycho-targetplatform/src/main/java/org/eclipse/tycho/targetplatform/TargetDefinitionFile.java @@ -413,14 +413,19 @@ private static class IULocation implements TargetDefinition.InstallableUnitLocat private final IncludeMode includeMode; private final boolean includeAllEnvironments; private final boolean includeSource; + private final boolean includeConfigurePhase; + private final FollowRepositoryReferences followRepositoryReferences; IULocation(List units, List repositories, IncludeMode includeMode, - boolean includeAllEnvironments, boolean includeSource) { + boolean includeAllEnvironments, boolean includeSource, boolean includeConfigurePhase, + FollowRepositoryReferences followRepositoryReferences) { this.units = units; this.repositories = repositories; this.includeMode = includeMode; this.includeAllEnvironments = includeAllEnvironments; this.includeSource = includeSource; + this.includeConfigurePhase = includeConfigurePhase; + this.followRepositoryReferences = followRepositoryReferences; } @Override @@ -447,6 +452,16 @@ public boolean includeAllEnvironments() { public boolean includeSource() { return includeSource; } + + @Override + public boolean includeConfigurePhase() { + return includeConfigurePhase; + } + + @Override + public FollowRepositoryReferences followRepositoryReferences() { + return followRepositoryReferences; + } } private static class OtherLocation implements Location { @@ -743,9 +758,23 @@ private static IULocation parseIULocation(Element dom) { String uri = node.getAttribute("location"); repositories.add(new Repository(id, uri)); } + + String rawFollowRepositoryReferences = dom.getAttribute("followRepositoryReferences"); + final FollowRepositoryReferences followRepositoryReferences; + if (rawFollowRepositoryReferences == null || rawFollowRepositoryReferences.isEmpty()) { + followRepositoryReferences = FollowRepositoryReferences.DEFAULT; + } else if (Boolean.parseBoolean(rawFollowRepositoryReferences)) { + followRepositoryReferences = FollowRepositoryReferences.ENABLED; + } else { + followRepositoryReferences = FollowRepositoryReferences.DISABLED; + } + return new IULocation(Collections.unmodifiableList(units), Collections.unmodifiableList(repositories), parseIncludeMode(dom), Boolean.parseBoolean(dom.getAttribute("includeAllPlatforms")), - Boolean.parseBoolean(dom.getAttribute("includeSource"))); + Boolean.parseBoolean(dom.getAttribute("includeSource")), + Boolean.parseBoolean(dom.getAttribute("includeConfigurePhase")), + followRepositoryReferences + ); } private static String parseTargetEE(Element dom) {