From 0699e2ff175f575935fdaf82afe4ac99c428e23b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christoph=20L=C3=A4ubrich?= Date: Mon, 31 Jul 2023 09:09:43 +0200 Subject: [PATCH] [backport] Support repository references Currently Tycho ignores repository references when resolving IU locations and P2 repositories. This now adds support for referenced repositories so Tycho can resolve from there as well. --- RELEASE_NOTES.md | 3 +- .../ListCompositeArtifactRepository.java | 12 +-- .../repository/P2RepositoryManager.java | 2 +- .../TargetPlatformConfigurationMojo.java | 57 ++++++----- .../core/TargetPlatformConfiguration.java | 11 +++ ...aultTargetPlatformConfigurationReader.java | 17 ++++ .../shared/ReferencedRepositoryMode.java | 26 +++++ .../ListCompositeMetadataRepository.java | 11 +-- .../resolver/URITargetDefinitionContent.java | 99 ++++++++++++++++--- .../TargetPlatformConfigurationStub.java | 10 ++ .../p2resolver/P2DependencyResolver.java | 1 + .../p2resolver/TargetDefinitionResolver.java | 17 ++-- .../TargetDefinitionResolverService.java | 24 +++-- .../p2resolver/TargetPlatformFactoryImpl.java | 69 ++++++++----- ...itionResolverExecutionEnvironmentTest.java | 3 +- ...rgetDefinitionResolverIncludeModeTest.java | 6 +- ...etDefinitionResolverIncludeSourceTest.java | 6 +- .../TargetDefinitionResolverTest.java | 6 +- ...ResolverWithPlatformSpecificUnitsTest.java | 5 +- 19 files changed, 281 insertions(+), 104 deletions(-) create mode 100644 tycho-core/src/main/java/org/eclipse/tycho/core/resolver/shared/ReferencedRepositoryMode.java diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 4239a9b583..1635125b51 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -3,7 +3,8 @@ This page describes the noteworthy improvements provided by each release of Eclipse Tycho. ## 4.0.2 -- +- new option to include referenced repositories when resolving the target platform +- Add dummy parameter to prevent warnings with jgit as timestamp provider ## 4.0.1 diff --git a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/ListCompositeArtifactRepository.java b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/ListCompositeArtifactRepository.java index 87a7490a1b..fc77efbc8a 100644 --- a/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/ListCompositeArtifactRepository.java +++ b/p2-maven-plugin/src/main/java/org/eclipse/tycho/p2maven/ListCompositeArtifactRepository.java @@ -37,6 +37,7 @@ import org.eclipse.equinox.p2.query.IQuery; import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.query.IQueryable; +import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.equinox.p2.repository.ICompositeRepository; import org.eclipse.equinox.p2.repository.artifact.IArtifactDescriptor; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; @@ -57,8 +58,8 @@ public class ListCompositeArtifactRepository extends AbstractArtifactRepository public final List artifactRepositories; - public ListCompositeArtifactRepository(IProvisioningAgent agent, - List artifactRepositories) { + public ListCompositeArtifactRepository(List artifactRepositories, + IProvisioningAgent agent) { super(agent, null, IArtifactRepositoryManager.TYPE_COMPOSITE_REPOSITORY, null, null, null, null, null); try { setLocation(new URI("list:" + UUID.randomUUID())); @@ -74,12 +75,7 @@ public IQueryResult query(IQuery query, IProgressMon if (size == 1) { return artifactRepositories.get(0).query(query, monitor); } - Collector collector = new Collector<>(); - SubMonitor subMonitor = SubMonitor.convert(monitor, size); - for (IArtifactRepository repository : artifactRepositories) { - collector.addAll(repository.query(query, subMonitor.split(1))); - } - return collector; + return QueryUtil.compoundQueryable(artifactRepositories).query(query, IProgressMonitor.nullSafe(monitor)); } @Override 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 e34ebd32b0..95b7295d5a 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 @@ -93,7 +93,7 @@ public IArtifactRepository getCompositeArtifactRepository(Collection for (Repository repository : repositories) { childs.add(getArtifactRepository(repository)); } - return new ListCompositeArtifactRepository(agent, childs); + return new ListCompositeArtifactRepository(childs, agent); } /** diff --git a/target-platform-configuration/src/main/java/org/eclipse/tycho/target/TargetPlatformConfigurationMojo.java b/target-platform-configuration/src/main/java/org/eclipse/tycho/target/TargetPlatformConfigurationMojo.java index fa649db7ad..a6de15a24c 100644 --- a/target-platform-configuration/src/main/java/org/eclipse/tycho/target/TargetPlatformConfigurationMojo.java +++ b/target-platform-configuration/src/main/java/org/eclipse/tycho/target/TargetPlatformConfigurationMojo.java @@ -26,6 +26,7 @@ import org.eclipse.tycho.core.resolver.DefaultTargetPlatformConfigurationReader; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; import org.eclipse.tycho.core.resolver.shared.PomDependencies; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.targetplatform.TargetPlatformFilter.CapabilityPattern; /** @@ -45,11 +46,11 @@ public class TargetPlatformConfigurationMojo extends AbstractMojo { * List of .target artifacts to use for dependency resolution.
* Could either be *
    - *
  • <artifact> to define a target GAV (either local to the reactor or a remote - * one)
  • + *
  • <artifact> to define a target GAV (either local to the reactor or a + * remote one)
  • *
  • <file> to define a file local to the build
  • - *
  • <uri> to define a (remote) URI that specifies a target, currently only URIs - * that can be converted to URLs are supported (e.g. file:/.... http://..., )
  • + *
  • <uri> to define a (remote) URI that specifies a target, currently only + * URIs that can be converted to URLs are supported (e.g. file:/.... http://..., )
  • *
*/ @Parameter(name = DefaultTargetPlatformConfigurationReader.TARGET) @@ -60,21 +61,21 @@ public class TargetPlatformConfigurationMojo extends AbstractMojo { *

* If consider or wrapAsBundle, the effect is: *

    - *
  • First, Maven resolves the GAV dependencies according to the normal Maven rules. This results - * in a list of artifacts consisting of the specified artifacts and their transitive Maven - * dependencies.
  • - *
  • Tycho then checks each of these artifacts, and if the artifact is an OSGi bundle, it is added - * to the target platform. Other artifacts are ignored in case of consider, or get some - * OSGi metadata generated and an OSGi bundle created from them.
  • + *
  • First, Maven resolves the GAV dependencies according to the normal Maven rules. This + * results in a list of artifacts consisting of the specified artifacts and their transitive + * Maven dependencies.
  • + *
  • Tycho then checks each of these artifacts, and if the artifact is an OSGi bundle, it is + * added to the target platform. Other artifacts are ignored in case of consider, + * or get some OSGi metadata generated and an OSGi bundle created from them.
  • *
  • OSGi bundles which become part of the target platform in this way are then available to * resolve the project's OSGi dependencies.
  • *
*

*

- * 📝 Tycho always attempts to resolve transitive dependencies, so if you need a POM dependency in - * the target platform of one module, you will also need it in all downstream modules. Therefore the - * POM dependencies (and the pomDependencies=consider configuration) typically need to be added in - * the parent POM. + * 📝 Tycho always attempts to resolve transitive dependencies, so if you need a POM dependency + * in the target platform of one module, you will also need it in all downstream modules. + * Therefore the POM dependencies (and the pomDependencies=consider configuration) typically + * need to be added in the parent POM. *

*

* If no explicit value is configured Tycho uses {@link PomDependencies#ignore} if eager @@ -85,8 +86,8 @@ public class TargetPlatformConfigurationMojo extends AbstractMojo { private PomDependencies pomDependencies; /** - * Force an execution environment for dependency resolution. If unset, use the default JRE of your - * computer. + * Force an execution environment for dependency resolution. If unset, use the default JRE of + * your computer. *

* Set to none to force the resolution to happen without any execution * environment, typically when the module is supposed to use system packages coming from some @@ -122,15 +123,15 @@ public class TargetPlatformConfigurationMojo extends AbstractMojo { /** * Selectively remove content from the target platform. *

- * This for example allows to restrict the version of a bundle, or to select one particular provider - * for a package. Filtering is done as last step in the target platform computation, so the filters - * apply to all sources listed above. + * This for example allows to restrict the version of a bundle, or to select one particular + * provider for a package. Filtering is done as last step in the target platform computation, so + * the filters apply to all sources listed above. *

*

* The filters will only remove content from the target platform; they will not add new content. * {@code dependency-resolution} should be used for addition of extra content. If you specify a - * restriction that is not fulfilled by any of the units from the target platform sources, all units - * that the filter applies to (i.e. units that match the filter.type, filter.id, and + * restriction that is not fulfilled by any of the units from the target platform sources, all + * units that the filter applies to (i.e. units that match the filter.type, filter.id, and * filter.version/versionRange criteria) will be removed from the target platform. *

*

@@ -169,10 +170,10 @@ public class TargetPlatformConfigurationMojo extends AbstractMojo { private List filters; /** - * Exclusions could be used together with {@link #pomDependencies} setting to exclude certain maven - * dependencies from being considered. This is useful for example if there is an offending - * (transitive) dependency needed for compilation but not for the runtime that would cause problems - * otherwise. + * Exclusions could be used together with {@link #pomDependencies} setting to exclude certain + * maven dependencies from being considered. This is useful for example if there is an offending + * (transitive) dependency needed for compilation but not for the runtime that would cause + * problems otherwise. */ @Parameter(name = DefaultTargetPlatformConfigurationReader.EXCLUSIONS) private List exclusions; @@ -206,6 +207,12 @@ public class TargetPlatformConfigurationMojo extends AbstractMojo { @Parameter(name = DefaultTargetPlatformConfigurationReader.TARGET_DEFINITION_INCLUDE_SOURCE) private IncludeSourceMode targetDefinionIncludeSource; + /** + * Configures if referenced repositories should be included in when fetching repositories. + */ + @Parameter(name = DefaultTargetPlatformConfigurationReader.REFERENCED_REPOSITORY_MODE) + private ReferencedRepositoryMode referencedRepositoryMode; + @Override public void execute() throws MojoExecutionException, MojoFailureException { throw new MojoFailureException( diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformConfiguration.java b/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformConfiguration.java index d103c80fc9..46cad2dcc0 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformConfiguration.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/TargetPlatformConfiguration.java @@ -34,6 +34,7 @@ import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; import org.eclipse.tycho.core.resolver.shared.PomDependencies; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.targetplatform.TargetDefinitionFile; import org.eclipse.tycho.targetplatform.TargetPlatformFilter; @@ -118,6 +119,8 @@ public enum InjectP2MavenMetadataHandling { private InjectP2MavenMetadataHandling p2MavenMetadataHandling; + private ReferencedRepositoryMode referencedRepositoryMode = ReferencedRepositoryMode.ignore; + /** * Returns the list of configured target environments, or the running environment if no * environments have been specified explicitly. @@ -311,4 +314,12 @@ public void setLocalArtifactHandling(LocalArtifactHandling localArtifactHandling this.localArtifactHandling = localArtifactHandling; } + public ReferencedRepositoryMode getReferencedRepositoryMode() { + return referencedRepositoryMode; + } + + public void setReferencedRepositoryMode(ReferencedRepositoryMode referencedRepositoryMode) { + this.referencedRepositoryMode = referencedRepositoryMode; + } + } 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 d51f5adf60..8dbc94c21b 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 @@ -50,6 +50,7 @@ import org.eclipse.tycho.core.TychoProjectManager; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; import org.eclipse.tycho.core.resolver.shared.PomDependencies; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.p2resolver.TargetDefinitionResolver; import org.eclipse.tycho.targetplatform.TargetDefinitionFile; import org.eclipse.tycho.targetplatform.TargetPlatformArtifactResolver; @@ -59,6 +60,7 @@ @Component(role = DefaultTargetPlatformConfigurationReader.class) public class DefaultTargetPlatformConfigurationReader { public static final String TARGET_DEFINITION_INCLUDE_SOURCE = "targetDefinitionIncludeSource"; + public static final String REFERENCED_REPOSITORY_MODE = "referencedRepositoryMode"; public static final String DEPENDENCY_RESOLUTION = "dependency-resolution"; public static final String OPTIONAL_DEPENDENCIES = "optionalDependencies"; public static final String LOCAL_ARTIFACTS = "localArtifacts"; @@ -137,6 +139,7 @@ public TargetPlatformConfiguration getTargetPlatformConfiguration(MavenSession s readDependencyResolutionConfiguration(result, configuration, session); setTargetDefinitionIncludeSources(result, configuration); + setReferencedRepositoryMode(result, configuration); } } //consider items set in the pom repositories @@ -191,6 +194,20 @@ private void setTargetDefinitionIncludeSources(TargetPlatformConfiguration resul } } + private void setReferencedRepositoryMode(TargetPlatformConfiguration result, Xpp3Dom configuration) + throws BuildFailureException { + String value = getStringValue(configuration.getChild(REFERENCED_REPOSITORY_MODE)); + if (value == null) { + return; + } + try { + result.setReferencedRepositoryMode(ReferencedRepositoryMode.valueOf(value)); + } catch (IllegalArgumentException e) { + throw new BuildFailureException("Illegal value of <" + REFERENCED_REPOSITORY_MODE + + "> target platform configuration parameter: " + value, e); + } + } + protected void readDependencyResolutionConfiguration(TargetPlatformConfiguration result, Xpp3Dom configuration, MavenSession mavenSession) { Xpp3Dom resolverDom = configuration.getChild(DEPENDENCY_RESOLUTION); diff --git a/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/shared/ReferencedRepositoryMode.java b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/shared/ReferencedRepositoryMode.java new file mode 100644 index 0000000000..2a02f3bd8a --- /dev/null +++ b/tycho-core/src/main/java/org/eclipse/tycho/core/resolver/shared/ReferencedRepositoryMode.java @@ -0,0 +1,26 @@ +/******************************************************************************* + * 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.resolver.shared; + +public enum ReferencedRepositoryMode { + + /** + * Repository references are ignored + */ + ignore, + /** + * Repository references are included + */ + include; + +} diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2/repository/ListCompositeMetadataRepository.java b/tycho-core/src/main/java/org/eclipse/tycho/p2/repository/ListCompositeMetadataRepository.java index 30fa3e2043..90f55907a5 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2/repository/ListCompositeMetadataRepository.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2/repository/ListCompositeMetadataRepository.java @@ -20,12 +20,12 @@ import java.util.UUID; import org.eclipse.core.runtime.IProgressMonitor; -import org.eclipse.core.runtime.SubMonitor; import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.metadata.IInstallableUnit; -import org.eclipse.equinox.p2.query.Collector; import org.eclipse.equinox.p2.query.IQuery; import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.query.IQueryable; +import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.equinox.p2.repository.ICompositeRepository; import org.eclipse.equinox.p2.repository.IRepositoryReference; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; @@ -61,12 +61,7 @@ public IQueryResult query(IQuery query, IPro if (size == 1) { return metadataRepositories.get(0).query(query, monitor); } - Collector collector = new Collector<>(); - SubMonitor subMonitor = SubMonitor.convert(monitor, size); - for (IMetadataRepository repository : metadataRepositories) { - collector.addAll(repository.query(query, subMonitor.split(1))); - } - return collector; + return QueryUtil.compoundQueryable(metadataRepositories).query(query, IProgressMonitor.nullSafe(monitor)); } @Override diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2/resolver/URITargetDefinitionContent.java b/tycho-core/src/main/java/org/eclipse/tycho/p2/resolver/URITargetDefinitionContent.java index 9e37d989e5..726f33425c 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2/resolver/URITargetDefinitionContent.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2/resolver/URITargetDefinitionContent.java @@ -13,6 +13,10 @@ package org.eclipse.tycho.p2.resolver; import java.net.URI; +import java.util.Collection; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.SubMonitor; @@ -21,30 +25,35 @@ import org.eclipse.equinox.p2.metadata.IInstallableUnit; import org.eclipse.equinox.p2.query.IQuery; import org.eclipse.equinox.p2.query.IQueryResult; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.IRepositoryReference; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; import org.eclipse.equinox.p2.repository.metadata.IMetadataRepositoryManager; import org.eclipse.tycho.IRepositoryIdManager; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.p2.repository.LazyArtifactRepository; +import org.eclipse.tycho.p2.repository.ListCompositeMetadataRepository; import org.eclipse.tycho.p2.repository.RepositoryArtifactProvider; +import org.eclipse.tycho.p2maven.ListCompositeArtifactRepository; import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinitionResolutionException; public class URITargetDefinitionContent implements TargetDefinitionContent { - private final IArtifactRepository artifactRepository; + private IArtifactRepository artifactRepository; private IProvisioningAgent agent; private URI location; private String id; private IMetadataRepository metadataRepository; + private ReferencedRepositoryMode referencedRepositoryMode; - public URITargetDefinitionContent(IProvisioningAgent agent, URI location, String id) { + public URITargetDefinitionContent(IProvisioningAgent agent, URI location, String id, + ReferencedRepositoryMode referencedRepositoryMode) { this.agent = agent; this.location = location; this.id = id; - //artifact repositories are resolved lazy here as loading them might not be always necessary (e.g only dependency resolution required) and could be expensive (net I/O) - artifactRepository = new LazyArtifactRepository(agent, location, RepositoryArtifactProvider::loadRepository); - + this.referencedRepositoryMode = referencedRepositoryMode; } @Override @@ -61,28 +70,86 @@ public IMetadataRepository getMetadataRepository() { return metadataRepository; } - public synchronized void preload(IProgressMonitor monitor) { + private synchronized void preload(IProgressMonitor monitor) { if (metadataRepository == null) { - IMetadataRepositoryManager metadataManager = agent.getService(IMetadataRepositoryManager.class); - if (metadataManager == null) { - throw new TargetDefinitionResolutionException( - "IMetadataRepositoryManager is null in IProvisioningAgent"); + Map metadataRepositoriesMap = new LinkedHashMap<>(); + Map artifactRepositoriesMap = new LinkedHashMap<>(); + loadMetadataRepositories(location, id, metadataRepositoriesMap, artifactRepositoriesMap, + referencedRepositoryMode == ReferencedRepositoryMode.include, agent, monitor); + loadArtifactRepositories(location, artifactRepositoriesMap, agent); + Collection metadataRepositories = metadataRepositoriesMap.values(); + if (metadataRepositories.size() == 1) { + metadataRepository = metadataRepositories.iterator().next(); + } else { + metadataRepository = new ListCompositeMetadataRepository(List.copyOf(metadataRepositories), agent); } + Collection artifactRepositories = artifactRepositoriesMap.values(); + if (artifactRepositories.size() == 1) { + artifactRepository = artifactRepositories.iterator().next(); + } else { + artifactRepository = new ListCompositeArtifactRepository(List.copyOf(artifactRepositories), agent); + } + } + } + + private static void loadMetadataRepositories(URI uri, String id, Map metadataRepositories, + Map artifactRepositories, boolean includeReferenced, IProvisioningAgent agent, + IProgressMonitor monitor) { + URI key = uri.normalize(); + if (metadataRepositories.containsKey(key)) { + //already loaded... + return; + } + SubMonitor subMonitor = SubMonitor.convert(monitor, 100); + IMetadataRepositoryManager metadataManager = agent.getService(IMetadataRepositoryManager.class); + if (metadataManager == null) { + throw new TargetDefinitionResolutionException("IMetadataRepositoryManager is null in IProvisioningAgent"); + } + try { IRepositoryIdManager repositoryIdManager = agent.getService(IRepositoryIdManager.class); if (repositoryIdManager != null) { - repositoryIdManager.addMapping(id, location); + repositoryIdManager.addMapping(id, uri); } - try { - metadataRepository = metadataManager.loadRepository(location, monitor); - } catch (ProvisionException e) { - throw new TargetDefinitionResolutionException( - "Failed to load p2 metadata repository from location " + location, e); + IMetadataRepository repository = metadataManager.loadRepository(uri, subMonitor.split(50)); + metadataRepositories.put(key, repository); + if (includeReferenced) { + Collection references = repository.getReferences(); + subMonitor.setWorkRemaining(references.size()); + for (IRepositoryReference reference : references) { + if ((reference.getOptions() | IRepository.ENABLED) != 0) { + if (reference.getType() == IRepository.TYPE_METADATA) { + loadMetadataRepositories(reference.getLocation(), reference.getNickname(), + metadataRepositories, artifactRepositories, includeReferenced, agent, + subMonitor.split(1)); + } else if (reference.getType() == IRepository.TYPE_ARTIFACT) { + loadArtifactRepositories(reference.getLocation(), artifactRepositories, agent); + subMonitor.worked(1); + } + } + } } + } catch (ProvisionException e) { + throw new TargetDefinitionResolutionException("Failed to load p2 metadata repository from location " + uri, + e); } + + } + + private static void loadArtifactRepositories(URI uri, Map artifactRepositories, + IProvisioningAgent agent) { + URI key = uri.normalize(); + if (artifactRepositories.containsKey(key)) { + //already loaded... + return; + } + //artifact repositories are resolved lazy here as loading them might not be always necessary (e.g only dependency resolution required) and could be expensive (net I/O) + artifactRepositories.put(key, + new LazyArtifactRepository(agent, uri, RepositoryArtifactProvider::loadRepository)); } @Override public IArtifactRepository getArtifactRepository() { + preload(null); return artifactRepository; } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java b/tycho-core/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java index 69ab0a5658..d6a44f2cd3 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2/target/facade/TargetPlatformConfigurationStub.java @@ -22,6 +22,7 @@ import org.eclipse.tycho.MavenRepositoryLocation; import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.targetplatform.TargetDefinition; import org.eclipse.tycho.targetplatform.TargetPlatformFilter; @@ -35,6 +36,7 @@ public class TargetPlatformConfigurationStub { private final List targetDefinitions = new ArrayList<>(); private boolean forceIgnoreLocalArtifacts = false; private IncludeSourceMode includeSourceMode = IncludeSourceMode.honor; + private ReferencedRepositoryMode referencedRepositoryMode = ReferencedRepositoryMode.ignore; public TargetPlatformConfigurationStub() { // TODO Auto-generated constructor stub @@ -93,4 +95,12 @@ public void setIncludeSourceMode(IncludeSourceMode includeSourceMode) { this.includeSourceMode = includeSourceMode; } + public ReferencedRepositoryMode getIncludeRefererenced() { + return referencedRepositoryMode; + } + + public void setReferencedRepositoryMode(ReferencedRepositoryMode referencedRepositoryMode) { + this.referencedRepositoryMode = referencedRepositoryMode; + } + } 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 5ab95f32a3..8358bf89ef 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 @@ -210,6 +210,7 @@ public TargetPlatform computePreliminaryTargetPlatform(MavenSession session, Mav tpConfiguration.setIncludeSourceMode(configuration.getTargetDefinitionIncludeSourceMode()); tpConfiguration .setIgnoreLocalArtifacts(configuration.getIgnoreLocalArtifacts() == LocalArtifactHandling.ignore); + tpConfiguration.setReferencedRepositoryMode(configuration.getReferencedRepositoryMode()); return reactorRepositoryManager.computePreliminaryTargetPlatform(reactorProject, tpConfiguration, ee, reactorProjects); 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 0b3d111fc0..ddc03e720f 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 @@ -43,6 +43,7 @@ import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.core.resolver.MavenTargetLocationFactory; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.core.shared.LoggingProgressMonitor; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.core.shared.MavenLogger; @@ -53,7 +54,6 @@ import org.eclipse.tycho.p2.resolver.URITargetDefinitionContent; import org.eclipse.tycho.p2maven.ListCompositeArtifactRepository; import org.eclipse.tycho.targetplatform.TargetDefinition; -import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinition.DirectoryLocation; import org.eclipse.tycho.targetplatform.TargetDefinition.FeaturesLocation; import org.eclipse.tycho.targetplatform.TargetDefinition.InstallableUnitLocation; @@ -63,6 +63,7 @@ import org.eclipse.tycho.targetplatform.TargetDefinition.ProfileLocation; import org.eclipse.tycho.targetplatform.TargetDefinition.Repository; import org.eclipse.tycho.targetplatform.TargetDefinition.TargetReferenceLocation; +import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinitionFile; import org.eclipse.tycho.targetplatform.TargetDefinitionResolutionException; import org.eclipse.tycho.targetplatform.TargetDefinitionSyntaxException; @@ -85,13 +86,16 @@ public final class TargetDefinitionResolver { private MavenTargetLocationFactory mavenDependenciesResolver; private TargetDefinitionVariableResolver varResolver; + private ReferencedRepositoryMode referencedRepositoryMode; + public TargetDefinitionResolver(List environments, ExecutionEnvironmentResolutionHints executionEnvironment, IncludeSourceMode includeSourceMode, - MavenContext mavenContext, MavenTargetLocationFactory mavenDependenciesResolver, - TargetDefinitionVariableResolver varResolver) { + ReferencedRepositoryMode referencedRepositoryMode, MavenContext mavenContext, + MavenTargetLocationFactory mavenDependenciesResolver, TargetDefinitionVariableResolver varResolver) { this.environments = environments; this.executionEnvironment = executionEnvironment; this.includeSourceMode = includeSourceMode; + this.referencedRepositoryMode = referencedRepositoryMode; this.mavenDependenciesResolver = mavenDependenciesResolver; this.logger = mavenContext.getLogger(); this.varResolver = varResolver; @@ -137,8 +141,9 @@ public TargetDefinitionContent resolveContentWithExceptions(TargetDefinition def 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()))); + locations.add( + uriRepositories.computeIfAbsent(key, s -> new URITargetDefinitionContent(provisioningAgent, + location, repository.getId(), referencedRepositoryMode))); } IQueryable locationUnits = QueryUtil.compoundQueryable(locations); installableUnitResolver.addLocation((InstallableUnitLocation) locationDefinition, locationUnits); @@ -258,7 +263,7 @@ public IMetadataRepository getMetadataRepository() { @Override public IArtifactRepository getArtifactRepository() { if (artifactRepository == null) { - artifactRepository = new ListCompositeArtifactRepository(provisioningAgent, artifactRepositories); + artifactRepository = new ListCompositeArtifactRepository(artifactRepositories, provisioningAgent); } return artifactRepository; } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverService.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverService.java index f99d3d7b1f..f87fe0e507 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverService.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverService.java @@ -31,6 +31,7 @@ import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.core.resolver.MavenTargetLocationFactory; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.targetplatform.TargetDefinition; import org.eclipse.tycho.targetplatform.TargetDefinitionContent; @@ -62,9 +63,10 @@ public TargetDefinitionResolverService() { public TargetDefinitionContent getTargetDefinitionContent(TargetDefinition definition, List environments, ExecutionEnvironmentResolutionHints jreIUs, - IncludeSourceMode includeSourceMode, IProvisioningAgent agent) { + IncludeSourceMode includeSourceMode, ReferencedRepositoryMode referencedRepositoryMode, + IProvisioningAgent agent) { ResolutionArguments arguments = new ResolutionArguments(definition, environments, jreIUs, includeSourceMode, - agent); + referencedRepositoryMode, agent); CompletableFuture future = resolutionCache.computeIfAbsent(arguments, this::resolveFromArguments); @@ -88,7 +90,8 @@ private CompletableFuture resolveFromArguments(Resoluti } TargetDefinitionResolver resolver = new TargetDefinitionResolver(arguments.environments, arguments.jreIUs, - arguments.includeSourceMode, mavenContext, dependenciesResolver, varResolver); + arguments.includeSourceMode, arguments.referencedRepositoryMode, mavenContext, dependenciesResolver, + varResolver); try { return CompletableFuture.completedFuture(resolver.resolveContent(arguments.definition, arguments.agent)); } catch (Exception e) { @@ -142,20 +145,22 @@ private static final class ResolutionArguments { final ExecutionEnvironmentResolutionHints jreIUs; final IProvisioningAgent agent; private IncludeSourceMode includeSourceMode; + private ReferencedRepositoryMode referencedRepositoryMode; public ResolutionArguments(TargetDefinition definition, List environments, ExecutionEnvironmentResolutionHints jreIUs, IncludeSourceMode includeSourceMode, - IProvisioningAgent agent) { + ReferencedRepositoryMode repositoryMode, IProvisioningAgent agent) { this.definition = definition; this.environments = environments; this.jreIUs = jreIUs; this.includeSourceMode = includeSourceMode; + this.referencedRepositoryMode = repositoryMode; this.agent = agent; } @Override public int hashCode() { - return Objects.hash(agent, definition, environments, jreIUs, includeSourceMode); + return Objects.hash(agent, definition, environments, jreIUs, includeSourceMode, referencedRepositoryMode); } @Override @@ -165,7 +170,8 @@ public boolean equals(Object obj) { && Objects.equals(definition, other.definition) // && Objects.equals(agent, other.agent) // expected to be object identity && Objects.equals(environments, other.environments) // - && Objects.equals(includeSourceMode, other.includeSourceMode)); + && Objects.equals(includeSourceMode, other.includeSourceMode) + && Objects.equals(referencedRepositoryMode, other.referencedRepositoryMode)); } public List getNonEqualFields(ResolutionArguments other) { @@ -175,14 +181,16 @@ public List getNonEqualFields(ResolutionArguments other) { addIfNonEqual(result, "target environments", environments, other.environments); addIfNonEqual(result, "remote p2 repository options", agent, other.agent); addIfNonEqual(result, "include source mode", includeSourceMode, other.includeSourceMode); + addIfNonEqual(result, "include reference mode", referencedRepositoryMode, other.referencedRepositoryMode); return result; } @Override public String toString() { return "target definition " + definition.getOrigin() + " for environments=" + environments - + ", include source mode=" + includeSourceMode + ", execution environment=" + jreIUs - + ", remote p2 repository options=" + agent; + + ", include source mode=" + includeSourceMode + ", referenced repository mode =" + + referencedRepositoryMode + ", execution environment=" + jreIUs + ", remote p2 repository options=" + + agent; } } diff --git a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java index a8d91f2792..fa4f2416ff 100644 --- a/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java +++ b/tycho-core/src/main/java/org/eclipse/tycho/p2resolver/TargetPlatformFactoryImpl.java @@ -19,6 +19,7 @@ import java.io.File; import java.io.IOException; +import java.net.URI; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -52,6 +53,8 @@ import org.eclipse.equinox.p2.query.IQuery; import org.eclipse.equinox.p2.query.IQueryResult; import org.eclipse.equinox.p2.query.QueryUtil; +import org.eclipse.equinox.p2.repository.IRepository; +import org.eclipse.equinox.p2.repository.IRepositoryReference; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepository; import org.eclipse.equinox.p2.repository.artifact.IArtifactRepositoryManager; import org.eclipse.equinox.p2.repository.metadata.IMetadataRepository; @@ -74,6 +77,7 @@ import org.eclipse.tycho.core.osgitools.ClasspathReader; import org.eclipse.tycho.core.osgitools.MavenBundleResolver; import org.eclipse.tycho.core.osgitools.OsgiBundleProject; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.core.resolver.target.ArtifactTypeHelper; import org.eclipse.tycho.core.resolver.target.DuplicateReactorIUsException; import org.eclipse.tycho.core.resolver.target.FileArtifactRepository; @@ -212,9 +216,11 @@ public P2TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpC registerRepositoryIDs(completeRepositories); // collect & process metadata + Set artifactRepositories = new LinkedHashSet<>(); boolean includeLocalMavenRepo = !tpConfiguration.getIgnoreLocalArtifacts(); Set externalUIs = gatherExternalInstallableUnits(completeRepositories, targetFileContent, - includeLocalMavenRepo); + includeLocalMavenRepo, artifactRepositories, + tpConfiguration.getIncludeRefererenced() == ReferencedRepositoryMode.include); //add maven junit bundles... List junitBundles = getMissingJunitBundles(project, externalUIs); @@ -259,7 +265,7 @@ public P2TargetPlatform createTargetPlatform(TargetPlatformConfigurationStub tpC applyFilters(filter, externalUIs, reactorProjectUIs.keySet(), eeResolutionHandler.getResolutionHints(), shadowed); - IRawArtifactFileProvider externalArtifactFileProvider = createExternalArtifactProvider(completeRepositories, + IRawArtifactFileProvider externalArtifactFileProvider = createExternalArtifactProvider(artifactRepositories, targetFileContent); PreliminaryTargetPlatformImpl targetPlatform = new PreliminaryTargetPlatformImpl(reactorProjectUIs, // externalUIs, // @@ -316,7 +322,7 @@ private List resolveTargetDefinitions(TargetPlatformCon TargetDefinitionContent targetFileContent = targetDefinitionResolverService.getTargetDefinitionContent( definition, tpConfiguration.getEnvironments(), eeResolutionHints, - tpConfiguration.getIncludeSourceMode(), remoteAgent); + tpConfiguration.getIncludeSourceMode(), tpConfiguration.getIncludeRefererenced(), remoteAgent); result.add(targetFileContent); if (logger.isDebugEnabled()) { @@ -340,10 +346,12 @@ private void registerRepositoryIDs(Set repositoriesWith /** * External installable units collected from p2 repositories, .target files and local Maven * repository. + * + * @param artifactRepositories */ private LinkedHashSet gatherExternalInstallableUnits( Set completeRepositories, List targetDefinitionsContent, - boolean includeLocalMavenRepo) { + boolean includeLocalMavenRepo, Set artifactRepositories, boolean includeReferences) { LinkedHashSet result = new LinkedHashSet<>(); for (TargetDefinitionContent targetDefinitionContent : targetDefinitionsContent) { @@ -352,8 +360,10 @@ private LinkedHashSet gatherExternalInstallableUnits( } List metadataRepositories = new ArrayList<>(); + Set loaded = new HashSet<>(); for (MavenRepositoryLocation location : completeRepositories) { - metadataRepositories.add(loadMetadataRepository(location)); + artifactRepositories.add(location.getURL()); + loadMetadataRepository(location, metadataRepositories, loaded, artifactRepositories, includeReferences); } if (includeLocalMavenRepo) { metadataRepositories.add(localMetadataRepository); @@ -374,17 +384,32 @@ private LinkedHashSet gatherExternalInstallableUnits( return result; } - private IMetadataRepository loadMetadataRepository(MavenRepositoryLocation location) { - try { - // TODO always log that a p2 repository is added to the target platform somewhere; used to be either from p2 or the following line - // logger.info("Adding repository (cached) " + location.toASCIIString()); - - return remoteMetadataRepositoryManager.loadRepository(location.getURL(), monitor); - - } catch (ProvisionException e) { - String idMessage = location.getId() == null ? "" : " with ID '" + location.getId() + "'"; - throw new RuntimeException( - "Failed to load p2 repository" + idMessage + " from location " + location.getURL(), e); + private void loadMetadataRepository(MavenRepositoryLocation location, + List metadataRepositories, Set loaded, Set artifactRepositories, + boolean includeReferences) { + if (loaded.add(location.getURL().normalize())) { + try { + IMetadataRepository repository = remoteMetadataRepositoryManager.loadRepository(location.getURL(), + monitor); + metadataRepositories.add(repository); + if (includeReferences) { + for (IRepositoryReference reference : repository.getReferences()) { + if ((reference.getOptions() | IRepository.ENABLED) != 0) { + if (reference.getType() == IRepository.TYPE_METADATA) { + loadMetadataRepository( + new MavenRepositoryLocation(reference.getNickname(), reference.getLocation()), + metadataRepositories, loaded, artifactRepositories, includeReferences); + } else if (reference.getType() == IRepository.TYPE_ARTIFACT) { + artifactRepositories.add(reference.getLocation()); + } + } + } + } + } catch (ProvisionException e) { + String idMessage = location.getId() == null ? "" : " with ID '" + location.getId() + "'"; + throw new RuntimeException( + "Failed to load p2 repository" + idMessage + " from location " + location.getURL(), e); + } } } @@ -430,7 +455,7 @@ public static SortedRepositories sort(List repositories) { /** * Provider for all target platform artifacts from outside the reactor. */ - private IRawArtifactFileProvider createExternalArtifactProvider(Set completeRepositories, + private IRawArtifactFileProvider createExternalArtifactProvider(Set completeRepositories, List targetDefinitionsContent) { SortedRepositories repos = SortedRepositories .sort(targetDefinitionsContent.stream().map(TargetDefinitionContent::getArtifactRepository).toList()); @@ -448,14 +473,14 @@ private IRawArtifactFileProvider createExternalArtifactProvider(Set mavenRepositories, + private RepositoryArtifactProvider createRemoteArtifactProvider(Set mavenRepositories, List repos) { List artifactRepositories = new ArrayList<>(); - for (MavenRepositoryLocation location : mavenRepositories) { - if (!offline || URIUtil.isFileURI(location.getURL())) { - artifactRepositories.add(new LazyArtifactRepository(remoteAgent, location.getURL(), - RepositoryArtifactProvider::loadRepository)); + for (URI location : mavenRepositories) { + if (!offline || URIUtil.isFileURI(location)) { + artifactRepositories.add( + new LazyArtifactRepository(remoteAgent, location, RepositoryArtifactProvider::loadRepository)); } } diff --git a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverExecutionEnvironmentTest.java b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverExecutionEnvironmentTest.java index 583660b1a8..7f5826da80 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverExecutionEnvironmentTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverExecutionEnvironmentTest.java @@ -34,6 +34,7 @@ import org.eclipse.tycho.core.ee.impl.StandardEEResolutionHints; import org.eclipse.tycho.core.ee.shared.ExecutionEnvironmentStub; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.p2resolver.TargetDefinitionResolverIncludeModeTest.PlannerLocationStub; import org.eclipse.tycho.p2resolver.TargetDefinitionResolverTest.RepositoryStub; @@ -60,7 +61,7 @@ private TargetDefinitionResolver targetResolverForEE(String executionEnvironment MavenContext mavenCtx = new MockMavenContext(tempManager.newFolder("localRepo"), logVerifier.getLogger()); return new TargetDefinitionResolver(defaultEnvironments(), new StandardEEResolutionHints(new ExecutionEnvironmentStub(executionEnvironmentName, systemPackages)), - IncludeSourceMode.honor, mavenCtx, null, + IncludeSourceMode.honor, ReferencedRepositoryMode.ignore, mavenCtx, null, new DefaultTargetDefinitionVariableResolver(mavenCtx, logVerifier.getLogger())); } diff --git a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverIncludeModeTest.java b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverIncludeModeTest.java index bc29521b99..f3edce29f4 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverIncludeModeTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverIncludeModeTest.java @@ -30,13 +30,14 @@ import org.eclipse.equinox.p2.core.IProvisioningAgent; import org.eclipse.equinox.p2.metadata.IVersionedId; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.p2.resolver.ResolverException; import org.eclipse.tycho.p2resolver.TargetDefinitionResolverTest.LocationStub; import org.eclipse.tycho.p2resolver.TargetDefinitionResolverTest.TestRepositories; import org.eclipse.tycho.targetplatform.TargetDefinition; -import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinition.IncludeMode; +import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinitionResolutionException; import org.eclipse.tycho.test.util.LogVerifier; import org.eclipse.tycho.test.util.MockMavenContext; @@ -59,7 +60,8 @@ public class TargetDefinitionResolverIncludeModeTest extends TychoPlexusTestCase public void initSubject() throws Exception { MavenContext mavenCtx = new MockMavenContext(tempManager.newFolder("localRepo"), logVerifier.getLogger()); subject = new TargetDefinitionResolver(defaultEnvironments(), - ExecutionEnvironmentTestUtils.NOOP_EE_RESOLUTION_HINTS, IncludeSourceMode.honor, mavenCtx, null, + ExecutionEnvironmentTestUtils.NOOP_EE_RESOLUTION_HINTS, IncludeSourceMode.honor, + ReferencedRepositoryMode.ignore, mavenCtx, null, new DefaultTargetDefinitionVariableResolver(mavenCtx, logVerifier.getLogger())); } diff --git a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverIncludeSourceTest.java b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverIncludeSourceTest.java index 3f5bb91513..efa0a88ec7 100644 --- a/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverIncludeSourceTest.java +++ b/tycho-core/src/test/java/org/eclipse/tycho/p2resolver/TargetDefinitionResolverIncludeSourceTest.java @@ -26,12 +26,13 @@ import org.eclipse.equinox.p2.metadata.VersionedId; import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.p2resolver.TargetDefinitionResolverTest.LocationStub; import org.eclipse.tycho.p2resolver.TargetDefinitionResolverTest.TestRepositories; import org.eclipse.tycho.targetplatform.TargetDefinition; -import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinition.IncludeMode; +import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinitionResolutionException; import org.eclipse.tycho.test.util.LogVerifier; import org.eclipse.tycho.test.util.MockMavenContext; @@ -59,7 +60,8 @@ public class TargetDefinitionResolverIncludeSourceTest extends TychoPlexusTestCa public void initSubject() throws Exception { MavenContext mavenCtx = new MockMavenContext(tempManager.newFolder("localRepo"), logVerifier.getLogger()); subject = new TargetDefinitionResolver(defaultEnvironments(), - ExecutionEnvironmentTestUtils.NOOP_EE_RESOLUTION_HINTS, IncludeSourceMode.honor, mavenCtx, null, + ExecutionEnvironmentTestUtils.NOOP_EE_RESOLUTION_HINTS, IncludeSourceMode.honor, + ReferencedRepositoryMode.ignore, mavenCtx, null, new DefaultTargetDefinitionVariableResolver(mavenCtx, logVerifier.getLogger())); } 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 16a5ff20c0..78f765f169 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 @@ -37,15 +37,16 @@ import org.eclipse.equinox.p2.query.QueryUtil; import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.core.test.utils.ResourceUtil; import org.eclipse.tycho.targetplatform.TargetDefinition; -import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinition.IncludeMode; 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.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinitionResolutionException; import org.eclipse.tycho.targetplatform.TargetDefinitionSyntaxException; import org.eclipse.tycho.test.util.LogVerifier; @@ -91,7 +92,8 @@ public class TargetDefinitionResolverTest extends TychoPlexusTestCase { public void initContext() throws Exception { MavenContext mavenCtx = new MockMavenContext(tempManager.newFolder("localRepo"), logVerifier.getLogger()); subject = new TargetDefinitionResolver(defaultEnvironments(), - ExecutionEnvironmentTestUtils.NOOP_EE_RESOLUTION_HINTS, IncludeSourceMode.honor, mavenCtx, null, + ExecutionEnvironmentTestUtils.NOOP_EE_RESOLUTION_HINTS, IncludeSourceMode.honor, + ReferencedRepositoryMode.ignore, mavenCtx, null, new DefaultTargetDefinitionVariableResolver(mavenCtx, logVerifier.getLogger())); } 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 4bad3ba156..fbb9a72dd0 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 @@ -30,14 +30,15 @@ import org.eclipse.equinox.p2.metadata.VersionedId; import org.eclipse.tycho.TargetEnvironment; import org.eclipse.tycho.core.resolver.shared.IncludeSourceMode; +import org.eclipse.tycho.core.resolver.shared.ReferencedRepositoryMode; import org.eclipse.tycho.core.shared.MavenContext; import org.eclipse.tycho.p2resolver.TargetDefinitionResolverTest.RepositoryStub; import org.eclipse.tycho.p2resolver.TargetDefinitionResolverTest.UnitStub; import org.eclipse.tycho.targetplatform.TargetDefinition; -import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinition.IncludeMode; import org.eclipse.tycho.targetplatform.TargetDefinition.Repository; import org.eclipse.tycho.targetplatform.TargetDefinition.Unit; +import org.eclipse.tycho.targetplatform.TargetDefinitionContent; import org.eclipse.tycho.targetplatform.TargetDefinitionResolutionException; import org.eclipse.tycho.test.util.LogVerifier; import org.eclipse.tycho.test.util.MockMavenContext; @@ -155,7 +156,7 @@ private TargetDefinitionResolver createResolver(List environm throws ProvisionException, IOException { MavenContext mavenCtx = new MockMavenContext(tempManager.newFolder("localRepo"), logVerifier.getLogger()); return new TargetDefinitionResolver(environments, ExecutionEnvironmentTestUtils.NOOP_EE_RESOLUTION_HINTS, - IncludeSourceMode.honor, mavenCtx, null, + IncludeSourceMode.honor, ReferencedRepositoryMode.ignore, mavenCtx, null, new DefaultTargetDefinitionVariableResolver(mavenCtx, logVerifier.getLogger())); }