use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.
the class RepositoryReferenceTool method getVisibleRepositories.
/**
* Returns the list of visible p2 repositories for the build of the current module. The list
* includes the p2 repositories of the referenced reactor modules, the target platform, and
* optionally the current module itself. The repositories are sorted in a reasonable order of
* precedence, so if there should be duplicate installable units or artifacts, the hope is that
* it is deterministic from which repository the unit or artifact is taken. The order is:
* <ol>
* <li>The publisher results of the current module (only if the flag
* {@link #REPOSITORIES_INCLUDE_CURRENT_MODULE} is set),
* <li>The results of the referenced reactor modules,
* <li>The non-reactor content of the module's target platform.
* </ol>
*
* @param module
* The current Maven project
* @param session
* The current Maven session
* @param flags
* Options flags; supported flags are {@link #REPOSITORIES_INCLUDE_CURRENT_MODULE}
* @return a {@link RepositoryReferences} instance with the repositories.
* @throws MojoExecutionException
* in case of internal errors
* @throws MojoFailureException
* in case required artifacts are missing
*/
public RepositoryReferences getVisibleRepositories(MavenProject module, MavenSession session, int flags) throws MojoExecutionException, MojoFailureException {
RepositoryReferences repositories = new RepositoryReferences();
if ((flags & REPOSITORIES_INCLUDE_CURRENT_MODULE) != 0) {
File publisherResults = new File(module.getBuild().getDirectory());
repositories.addMetadataRepository(publisherResults);
repositories.addArtifactRepository(publisherResults);
}
repositories.addArtifactRepository(RepositoryBlackboardKey.forResolutionContextArtifacts(module.getBasedir()));
// metadata and artifacts of target platform
addTargetPlatformRepository(repositories, session, module);
repositories.addArtifactRepository(new File(session.getLocalRepository().getBasedir()));
return repositories;
}
use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.
the class MirrorApplicationServiceImpl method toInstallableUnitList.
private static List<IInstallableUnit> toInstallableUnitList(Collection<DependencySeed> seeds, IMetadataRepository sourceRepository, RepositoryReferences sourceRepositoryNames) throws FacadeException {
List<IInstallableUnit> result = new ArrayList<>(seeds.size());
for (DependencySeed seed : seeds) {
if (seed.getInstallableUnit() == null) {
// TODO 372780 drop this when getInstallableUnit can no longer be null
String unitId = seed.getId() + (ArtifactType.TYPE_ECLIPSE_FEATURE.equals(seed.getType()) ? ".feature.group" : "");
result.addAll(querySourceIus(Collections.singletonList(new IUDescription(unitId, null)), sourceRepository, sourceRepositoryNames));
} else {
result.add((IInstallableUnit) seed.getInstallableUnit());
}
}
if (result.isEmpty()) {
throw new IllegalArgumentException("List of seed units for repository aggregation must not be empty");
}
return result;
}
use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.
the class MirrorApplicationServiceImpl method querySourceIus.
private static List<IInstallableUnit> querySourceIus(Collection<IUDescription> sourceIUs, IMetadataRepository repository, RepositoryReferences sources) throws FacadeException {
if (sourceIUs == null || sourceIUs.isEmpty()) {
return null;
}
List<IInstallableUnit> result = new ArrayList<>();
for (IUDescription iu : sourceIUs) {
IQuery<IInstallableUnit> iuQuery = createQuery(iu);
Iterator<IInstallableUnit> queryResult = repository.query(iuQuery, null).iterator();
if (!queryResult.hasNext()) {
throw new FacadeException("Could not find IU " + iu.toString() + " in any of the source repositories " + sources.getMetadataRepositories(), null);
}
while (queryResult.hasNext()) {
result.add(queryResult.next());
}
}
return result;
}
use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.
the class MirrorApplicationServiceImpl method mirrorReactor.
@Override
public void mirrorReactor(RepositoryReferences sources, DestinationRepositoryDescriptor destination, Collection<DependencySeed> projectSeeds, BuildContext context, boolean includeAllDependencies, boolean includePacked, Map<String, String> filterProperties) throws FacadeException {
IProvisioningAgent agent = Activator.createProvisioningAgent(context.getTargetDirectory());
try {
final MirrorApplication mirrorApp = createMirrorApplication(sources, destination, agent, includePacked);
// mirror scope: seed units...
mirrorApp.setSourceIUs(toInstallableUnitList(projectSeeds, mirrorApp.getCompositeMetadataRepository(), sources));
// TODO the p2 mirror tool should support mirroring multiple environments at once
for (TargetEnvironment environment : context.getEnvironments()) {
SlicingOptions options = new SlicingOptions();
options.considerStrictDependencyOnly(!includeAllDependencies);
Map<String, String> filter = options.getFilter();
addFilterForFeatureJARs(filter);
if (filterProperties != null) {
filter.putAll(filterProperties);
}
filter.putAll(environment.toFilterProperties());
mirrorApp.setSlicingOptions(options);
try {
LogListener logListener = new LogListener(mavenContext.getLogger());
mirrorApp.setLog(logListener);
IStatus returnStatus = mirrorApp.run(null);
checkStatus(returnStatus, false);
logListener.showHelpForLoggedMessages();
} catch (ProvisionException e) {
throw new FacadeException(MIRROR_FAILURE_MESSAGE + ": " + StatusTool.collectProblems(e.getStatus()), e);
}
}
recreateArtifactRepository(destination);
xzCompress(destination);
} finally {
agent.stop();
}
}
use of org.eclipse.tycho.p2.tools.RepositoryReferences in project tycho by eclipse.
the class VerifierServiceImplTest method testMissingArtifactsReferencedInMetadata.
@Test
public void testMissingArtifactsReferencedInMetadata() throws Exception {
final RepositoryReferences repositories = sourceRepos("invalid/missing_artifacts");
assertEquals(false, verify(repositories));
assertTrue(firstErrorLine().contains("osgi.bundle"));
assertTrue(firstErrorLine().contains("tycho551.bundle1"));
assertTrue(firstErrorLine().contains("missing"));
}
Aggregations