Search in sources :

Example 11 with RepositoryReferences

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;
}
Also used : RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) File(java.io.File)

Example 12 with RepositoryReferences

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;
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) IUDescription(org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 13 with RepositoryReferences

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;
}
Also used : FacadeException(org.eclipse.tycho.p2.tools.FacadeException) IUDescription(org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription) ArrayList(java.util.ArrayList) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 14 with RepositoryReferences

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();
    }
}
Also used : FacadeException(org.eclipse.tycho.p2.tools.FacadeException) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) SlicingOptions(org.eclipse.equinox.p2.internal.repository.tools.SlicingOptions) IProvisioningAgent(org.eclipse.equinox.p2.core.IProvisioningAgent) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment)

Example 15 with RepositoryReferences

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"));
}
Also used : RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) Test(org.junit.Test)

Aggregations

RepositoryReferences (org.eclipse.tycho.p2.tools.RepositoryReferences)10 File (java.io.File)6 FacadeException (org.eclipse.tycho.p2.tools.FacadeException)4 Test (org.junit.Test)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)3 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 IStatus (org.eclipse.core.runtime.IStatus)2 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)2 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)2 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)2 DestinationRepositoryDescriptor (org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor)2 IUDescription (org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription)2 FileOutputStream (java.io.FileOutputStream)1 MalformedURLException (java.net.MalformedURLException)1 HashSet (java.util.HashSet)1