Skip to content

Commit

Permalink
Add support for followRepositoryReference in .target files
Browse files Browse the repository at this point in the history
This is the per-location setting that overrides
TargetPlatformConfiguration#referencedRepositoryMode
  • Loading branch information
tivervac authored and laeubi committed May 3, 2024
1 parent cc3c261 commit e536471
Show file tree
Hide file tree
Showing 10 changed files with 109 additions and 5 deletions.
8 changes: 8 additions & 0 deletions tycho-baseline-plugin/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -149,12 +150,21 @@ public TargetDefinitionContent resolveContentWithExceptions(TargetDefinition def
includeSourceMode, logger);
}
List<URITargetDefinitionContent> 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<IInstallableUnit> locationUnits = QueryUtil.compoundQueryable(locations);
Collection<IInstallableUnit> rootUnits = installableUnitResolver
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,11 @@ public boolean includeAllEnvironments() {
public boolean includeSource() {
return false;
}

@Override
public boolean includeConfigurePhase() {
return false;
}
}

private static class OtherLocationStub implements Location {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,11 @@ public boolean includeAllEnvironments() {
public boolean includeSource() {
return false;
}

@Override
public boolean includeConfigurePhase() {
return false;
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
8 changes: 8 additions & 0 deletions tycho-p2/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<? extends Repository> getRepositories();

public List<? extends Unit> getUnits();
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Unit> units, List<Repository> 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
Expand All @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit e536471

Please sign in to comment.