Search in sources :

Example 6 with FacadeException

use of org.eclipse.tycho.p2.tools.FacadeException 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 7 with FacadeException

use of org.eclipse.tycho.p2.tools.FacadeException in project tycho by eclipse.

the class MirrorApplicationServiceImpl method recreateArtifactRepository.

private void recreateArtifactRepository(DestinationRepositoryDescriptor destination) throws FacadeException {
    // create the missing md5 checksums
    if (destination.isMetaDataOnly()) {
        return;
    }
    RepositoryDescriptor descriptor = new RepositoryDescriptor();
    descriptor.setAppend(true);
    descriptor.setFormat(null);
    // $NON-NLS-1$
    descriptor.setKind("artifact");
    descriptor.setLocation(destination.getLocation().toURI());
    RecreateRepositoryApplication application = new RecreateRepositoryApplication();
    application.setArtifactRepository(descriptor);
    try {
        application.run(new NullProgressMonitor());
    } catch (ProvisionException e) {
        throw new FacadeException("Recreate artifact repository failed", e);
    }
}
Also used : FacadeException(org.eclipse.tycho.p2.tools.FacadeException) DestinationRepositoryDescriptor(org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor) RepositoryDescriptor(org.eclipse.equinox.p2.internal.repository.tools.RepositoryDescriptor) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) RecreateRepositoryApplication(org.eclipse.equinox.p2.internal.repository.tools.RecreateRepositoryApplication)

Example 8 with FacadeException

use of org.eclipse.tycho.p2.tools.FacadeException 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 9 with FacadeException

use of org.eclipse.tycho.p2.tools.FacadeException in project tycho by eclipse.

the class MirrorApplicationServiceImpl method xzCompress.

private void xzCompress(DestinationRepositoryDescriptor destination) throws FacadeException {
    if (!destination.isXZCompress()) {
        return;
    }
    try {
        XZCompressor xzCompressor = new XZCompressor();
        xzCompressor.setPreserveOriginalFile(destination.shouldKeepNonXzIndexFiles());
        xzCompressor.setRepoFolder(destination.getLocation().getAbsolutePath());
        xzCompressor.compressRepo();
    } catch (IOException e) {
        throw new FacadeException("XZ compression failed", e);
    }
}
Also used : FacadeException(org.eclipse.tycho.p2.tools.FacadeException) XZCompressor(org.eclipse.equinox.p2.internal.repository.tools.XZCompressor) IOException(java.io.IOException)

Example 10 with FacadeException

use of org.eclipse.tycho.p2.tools.FacadeException 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)

Aggregations

FacadeException (org.eclipse.tycho.p2.tools.FacadeException)12 ProvisionException (org.eclipse.equinox.p2.core.ProvisionException)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)4 File (java.io.File)3 ArrayList (java.util.ArrayList)3 IProvisioningAgent (org.eclipse.equinox.p2.core.IProvisioningAgent)3 IUDescription (org.eclipse.tycho.p2.tools.mirroring.facade.IUDescription)3 IOException (java.io.IOException)2 MojoFailureException (org.apache.maven.plugin.MojoFailureException)2 IStatus (org.eclipse.core.runtime.IStatus)2 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)2 DestinationRepositoryDescriptor (org.eclipse.tycho.p2.tools.DestinationRepositoryDescriptor)2 PublisherService (org.eclipse.tycho.p2.tools.publisher.facade.PublisherService)2 FileInputStream (java.io.FileInputStream)1 URI (java.net.URI)1 Properties (java.util.Properties)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 IProvisioningAgentProvider (org.eclipse.equinox.p2.core.IProvisioningAgentProvider)1 RecreateRepositoryApplication (org.eclipse.equinox.p2.internal.repository.tools.RecreateRepositoryApplication)1