Search in sources :

Example 1 with ProductFile

use of org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile in project tycho by eclipse.

the class ProductDependenciesAction method getRequiredCapabilities.

@Override
protected Set<IRequirement> getRequiredCapabilities() {
    Set<IRequirement> required = new LinkedHashSet<>();
    if (product.useFeatures()) {
        for (IVersionedId feature : product.getFeatures()) {
            // $NON-NLS-1$
            String id = feature.getId() + FEATURE_GROUP_IU_SUFFIX;
            Version version = feature.getVersion();
            addRequiredCapability(required, id, version, null, false);
        }
    } else {
        for (FeatureEntry plugin : ((ProductFile) product).getProductEntries()) {
            addRequiredCapability(required, plugin.getId(), Version.parseVersion(plugin.getVersion()), null, true);
        }
    }
    if (product.includeLaunchers()) {
        addRequiredCapability(required, "org.eclipse.equinox.executable.feature.group", null, null, false);
    }
    return required;
}
Also used : IRequirement(org.eclipse.equinox.p2.metadata.IRequirement) LinkedHashSet(java.util.LinkedHashSet) FeatureEntry(org.eclipse.equinox.p2.publisher.eclipse.FeatureEntry) ProductFile(org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile) IVersionedId(org.eclipse.equinox.p2.metadata.IVersionedId) Version(org.eclipse.equinox.p2.metadata.Version)

Example 2 with ProductFile

use of org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile in project tycho by eclipse.

the class P2GeneratorImpl method getPublisherActions.

@Override
protected List<IPublisherAction> getPublisherActions(IArtifactFacade artifact, List<TargetEnvironment> environments, OptionalResolutionAction optionalAction) {
    if (!dependenciesOnly && optionalAction != null) {
        throw new IllegalArgumentException();
    }
    List<IPublisherAction> actions = new ArrayList<>();
    String packaging = artifact.getPackagingType();
    File location = artifact.getLocation();
    if (PackagingType.TYPE_ECLIPSE_PLUGIN.equals(packaging) || PackagingType.TYPE_ECLIPSE_TEST_PLUGIN.equals(packaging)) {
        if (dependenciesOnly && optionalAction != null) {
            actions.add(new BundleDependenciesAction(location, optionalAction));
        } else {
            actions.add(new BundlesAction(new File[] { location }));
        }
    } else if (PackagingType.TYPE_ECLIPSE_FEATURE.equals(packaging)) {
        Feature feature = new FeatureParser().parse(location);
        feature.setLocation(location.getAbsolutePath());
        if (dependenciesOnly) {
            actions.add(new FeatureDependenciesAction(feature));
        } else {
            actions.add(new FeaturesAction(new Feature[] { feature }));
        }
    } else if (PackagingType.TYPE_ECLIPSE_APPLICATION.equals(packaging)) {
        String product = new File(location, artifact.getArtifactId() + ".product").getAbsolutePath();
        try {
            IProductDescriptor productDescriptor = new ProductFile2(product);
            if (dependenciesOnly) {
                actions.add(new ProductDependenciesAction(productDescriptor));
            } else {
                actions.add(new ProductAction(product, productDescriptor, null, null));
            }
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    } else if (PackagingType.TYPE_ECLIPSE_UPDATE_SITE.equals(packaging)) {
        if (dependenciesOnly) {
            actions.add(new SiteDependenciesAction(location, artifact.getArtifactId(), artifact.getVersion()));
        } else {
            actions.add(new SiteXMLAction(location.toURI(), null));
        }
    } else if (PackagingType.TYPE_ECLIPSE_REPOSITORY.equals(packaging)) {
        for (File productFile : getProductFiles(location)) {
            String product = productFile.getAbsolutePath();
            IProductDescriptor productDescriptor;
            try {
                productDescriptor = new ProductFile2(product);
            } catch (Exception e) {
                throw new RuntimeException("Unable to parse the product file " + product, e);
            }
            if (dependenciesOnly) {
                actions.add(new ProductDependenciesAction(productDescriptor));
            }
        }
        for (File categoryFile : getCategoryFiles(location)) {
            CategoryParser cp = new CategoryParser(null);
            FileInputStream ins = null;
            try {
                try {
                    ins = new FileInputStream(categoryFile);
                    SiteModel siteModel = cp.parse(ins);
                    actions.add(new CategoryDependenciesAction(siteModel, artifact.getArtifactId(), artifact.getVersion()));
                } finally {
                    if (ins != null) {
                        ins.close();
                    }
                }
            } catch (Exception e) {
                throw new RuntimeException("Unable to read category File", e);
            }
        }
    } else if (PackagingType.TYPE_P2_IU.equals(packaging)) {
        actions.add(new AuthoredIUAction(location));
    } else if (location.isFile() && location.getName().endsWith(".jar")) {
        actions.add(new BundlesAction(new File[] { location }));
    } else {
        throw new IllegalArgumentException("Unknown type of packaging " + packaging);
    }
    return actions;
}
Also used : BundlesAction(org.eclipse.equinox.p2.publisher.eclipse.BundlesAction) ArrayList(java.util.ArrayList) ProductAction(org.eclipse.equinox.p2.publisher.eclipse.ProductAction) Feature(org.eclipse.equinox.p2.publisher.eclipse.Feature) CategoryParser(org.eclipse.equinox.internal.p2.updatesite.CategoryParser) FeaturesAction(org.eclipse.equinox.p2.publisher.eclipse.FeaturesAction) FeatureParser(org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser) IPublisherAction(org.eclipse.equinox.p2.publisher.IPublisherAction) IProductDescriptor(org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor) SiteXMLAction(org.eclipse.equinox.internal.p2.updatesite.SiteXMLAction) SiteModel(org.eclipse.equinox.internal.p2.updatesite.SiteModel) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) ProductFile2(org.eclipse.tycho.p2.impl.publisher.model.ProductFile2) File(java.io.File)

Example 3 with ProductFile

use of org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile 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

ArrayList (java.util.ArrayList)2 IProductDescriptor (org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor)2 ProductAction (org.eclipse.equinox.p2.publisher.eclipse.ProductAction)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 LinkedHashSet (java.util.LinkedHashSet)1 FeatureParser (org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser)1 ProductFile (org.eclipse.equinox.internal.p2.publisher.eclipse.ProductFile)1 CategoryParser (org.eclipse.equinox.internal.p2.updatesite.CategoryParser)1 SiteModel (org.eclipse.equinox.internal.p2.updatesite.SiteModel)1 SiteXMLAction (org.eclipse.equinox.internal.p2.updatesite.SiteXMLAction)1 IInstallableUnit (org.eclipse.equinox.p2.metadata.IInstallableUnit)1 IRequirement (org.eclipse.equinox.p2.metadata.IRequirement)1 IVersionedId (org.eclipse.equinox.p2.metadata.IVersionedId)1 Version (org.eclipse.equinox.p2.metadata.Version)1 IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)1 IPublisherAdvice (org.eclipse.equinox.p2.publisher.IPublisherAdvice)1 BundlesAction (org.eclipse.equinox.p2.publisher.eclipse.BundlesAction)1 Feature (org.eclipse.equinox.p2.publisher.eclipse.Feature)1