Search in sources :

Example 6 with DependencySeed

use of org.eclipse.tycho.core.resolver.shared.DependencySeed in project tycho by eclipse.

the class PublishProductToolImpl method addRootFeatures.

private static void addRootFeatures(ExpandedProduct product, List<DependencySeed> seeds) {
    final String productId = product.getId();
    // add root features as special dependency seed which are marked as "add-on" for the product
    DependencySeed.Filter filter = new DependencySeed.Filter() {

        @Override
        public boolean isAddOnFor(String type, String id) {
            return ArtifactType.TYPE_ECLIPSE_PRODUCT.equals(type) && productId.equals(id);
        }
    };
    for (IInstallableUnit featureIU : product.getRootFeatures()) {
        ArtifactKey featureArtifact = ArtifactTypeHelper.toTychoArtifact(featureIU);
        seeds.add(new DependencySeed(featureArtifact.getType(), featureArtifact.getId(), featureIU, filter));
    }
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) ArtifactKey(org.eclipse.tycho.ArtifactKey) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 7 with DependencySeed

use of org.eclipse.tycho.core.resolver.shared.DependencySeed in project tycho by eclipse.

the class DirectorMojo method execute.

// TODO extract methods
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    List<Product> products = getProductConfig().getProducts();
    if (products.isEmpty()) {
        getLog().info("No product definitions found. Nothing to do.");
    }
    DirectorRuntime director = getDirectorRuntime();
    RepositoryReferences sources = getSourceRepositories();
    for (Product product : products) {
        for (TargetEnvironment env : getEnvironments()) {
            DirectorRuntime.Command command = director.newInstallCommand();
            File destination = getProductMaterializeDirectory(product, env);
            String rootFolder = product.getRootFolder(env.getOs());
            if (rootFolder != null && rootFolder.length() > 0) {
                destination = new File(destination, rootFolder);
            }
            command.addMetadataSources(sources.getMetadataRepositories());
            command.addArtifactSources(sources.getArtifactRepositories());
            command.addUnitToInstall(product.getId());
            for (DependencySeed seed : product.getAdditionalInstallationSeeds()) {
                command.addUnitToInstall(seed);
            }
            command.setDestination(destination);
            command.setProfileName(ProfileName.getNameForEnvironment(env, profileNames, profile));
            command.setEnvironment(env);
            command.setInstallFeatures(installFeatures);
            getLog().info("Installing product " + product.getId() + " for environment " + env + " to " + destination.getAbsolutePath());
            try {
                command.execute();
            } catch (DirectorCommandException e) {
                throw new MojoFailureException("Installation of product " + product.getId() + " for environment " + env + " failed", e);
            }
        }
    }
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) DirectorCommandException(org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) File(java.io.File) DirectorRuntime(org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime)

Example 8 with DependencySeed

use of org.eclipse.tycho.core.resolver.shared.DependencySeed in project tycho by eclipse.

the class AbstractPublishMojo method execute.

@Override
public final void execute() throws MojoExecutionException, MojoFailureException {
    PublisherServiceFactory publisherServiceFactory = osgiServices.getService(PublisherServiceFactory.class);
    Collection<DependencySeed> units = publishContent(publisherServiceFactory);
    postPublishedIUs(units);
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) PublisherServiceFactory(org.eclipse.tycho.p2.tools.publisher.facade.PublisherServiceFactory)

Example 9 with DependencySeed

use of org.eclipse.tycho.core.resolver.shared.DependencySeed 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 10 with DependencySeed

use of org.eclipse.tycho.core.resolver.shared.DependencySeed in project tycho by eclipse.

the class PublishProductToolImpl method publishProduct.

@Override
public List<DependencySeed> publishProduct(File productFile, File launcherBinaries, String flavor) throws IllegalArgumentException {
    IProductDescriptor originalProduct = loadProductFile(productFile);
    ExpandedProduct expandedProduct = new ExpandedProduct(originalProduct, buildQualifier, targetPlatform, interpolator, logger);
    IPublisherAdvice[] advice = getProductSpecificAdviceFileAdvice(productFile, expandedProduct);
    ProductAction action = new ProductAction(null, expandedProduct, flavor, launcherBinaries);
    IMetadataRepository metadataRepository = publishingRepository.getMetadataRepository();
    IArtifactRepository artifactRepository = publishingRepository.getArtifactRepositoryForWriting(new ProductBinariesWriteSession(expandedProduct.getId()));
    Collection<IInstallableUnit> allIUs = publisherRunner.executeAction(action, metadataRepository, artifactRepository, advice);
    List<DependencySeed> seeds = new ArrayList<>();
    seeds.add(createSeed(ArtifactType.TYPE_ECLIPSE_PRODUCT, selectUnit(allIUs, expandedProduct.getId())));
    addRootFeatures(expandedProduct, seeds);
    return seeds;
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) IProductDescriptor(org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor) ArrayList(java.util.ArrayList) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) ProductAction(org.eclipse.equinox.p2.publisher.eclipse.ProductAction) IPublisherAdvice(org.eclipse.equinox.p2.publisher.IPublisherAdvice) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) IMetadataRepository(org.eclipse.equinox.p2.repository.metadata.IMetadataRepository)

Aggregations

DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)16 File (java.io.File)8 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)6 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)4 ResourceUtil.resourceFile (org.eclipse.tycho.p2.tools.test.util.ResourceUtil.resourceFile)4 FacadeException (org.eclipse.tycho.p2.tools.FacadeException)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)2 RepositoryReferences (org.eclipse.tycho.p2.tools.RepositoryReferences)2 PublisherService (org.eclipse.tycho.p2.tools.publisher.facade.PublisherService)2 TychoMatchers.isFile (org.eclipse.tycho.test.util.TychoMatchers.isFile)2 IOException (java.io.IOException)1 HashMap (java.util.HashMap)1 IProductDescriptor (org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor)1 IProvidedCapability (org.eclipse.equinox.p2.metadata.IProvidedCapability)1 InstallableUnitDescription (org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription)1 Version (org.eclipse.equinox.p2.metadata.Version)1 VersionedId (org.eclipse.equinox.p2.metadata.VersionedId)1 IPublisherAdvice (org.eclipse.equinox.p2.publisher.IPublisherAdvice)1