Search in sources :

Example 1 with IUDescription

use of org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription in project tycho by eclipse.

the class MirrorStandaloneTest method testIgnoreErrorShouldNotThrowException.

@Test
public void testIgnoreErrorShouldNotThrowException() throws FacadeException {
    MirrorOptions mirrorOptions = new MirrorOptions();
    mirrorOptions.setIgnoreErrors(true);
    subject.mirrorStandalone(sourceRepos("invalid/wrong_checksum"), destinationRepo, Collections.singletonList(new IUDescription("jarsigning", "0.0.1.201109191414")), mirrorOptions, targetFolder);
}
Also used : IUDescription(org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription) MirrorOptions(org.eclipse.tycho.p2.tools.mirroring.facade.MirrorOptions) Test(org.junit.Test)

Example 2 with IUDescription

use of org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription in project tycho by eclipse.

the class MirrorApplicationServiceImpl method mirrorStandalone.

@Override
public void mirrorStandalone(RepositoryReferences sources, DestinationRepositoryDescriptor destination, Collection<IUDescription> seedIUs, MirrorOptions mirrorOptions, BuildOutputDirectory tempDirectory) throws FacadeException {
    IProvisioningAgent agent = Activator.createProvisioningAgent(tempDirectory);
    try {
        final MirrorApplication mirrorApp = createMirrorApplication(sources, destination, agent, mirrorOptions.isIncludePacked());
        mirrorApp.setSlicingOptions(createSlicingOptions(mirrorOptions));
        mirrorApp.setIgnoreErrors(mirrorOptions.isIgnoreErrors());
        try {
            // we want to see mirror progress as this is a possibly long-running operation
            mirrorApp.setVerbose(true);
            mirrorApp.setLog(new LogListener(mavenContext.getLogger()));
            mirrorApp.setSourceIUs(querySourceIus(seedIUs, mirrorApp.getCompositeMetadataRepository(), sources));
            IStatus returnStatus = mirrorApp.run(null);
            checkStatus(returnStatus, mirrorOptions.isIgnoreErrors());
        } catch (ProvisionException e) {
            throw new FacadeException(MIRROR_FAILURE_MESSAGE + ": " + StatusTool.collectProblems(e.getStatus()), e);
        }
    } 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) IProvisioningAgent(org.eclipse.equinox.p2.core.IProvisioningAgent)

Example 3 with IUDescription

use of org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription 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 4 with IUDescription

use of org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription 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 5 with IUDescription

use of org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription in project tycho by eclipse.

the class MirrorStandaloneTest method testMirrorMatchExpression.

@Test
public void testMirrorMatchExpression() throws Exception {
    subject.mirrorStandalone(e342PlusFragmentsRepo(), destinationRepo, Collections.singletonList(new IUDescription(null, null, "id == $0 && version == $1", new String[] { "org.eclipse.core.runtime", "3.4.0.v20080512" })), new MirrorOptions(), targetFolder);
    assertEquals(1, getMirroredBundleFiles().length);
    assertTrue(repoFile(destinationRepo, "plugins/org.eclipse.core.runtime_3.4.0.v20080512.jar").exists());
}
Also used : IUDescription(org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription) MirrorOptions(org.eclipse.tycho.p2.tools.mirroring.facade.MirrorOptions) Test(org.junit.Test)

Aggregations

IUDescription (org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription)5 MirrorOptions (org.eclipse.tycho.p2.tools.mirroring.facade.MirrorOptions)3 Test (org.junit.Test)3 ArrayList (java.util.ArrayList)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 FacadeException (org.eclipse.tycho.p2.tools.FacadeException)2 IStatus (org.eclipse.core.runtime.IStatus)1 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)1 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)1 DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)1