Search in sources :

Example 1 with IPublisherAction

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

the class PublisherServiceImpl method publishEEProfile.

@Override
public Collection<DependencySeed> publishEEProfile(File profileFile) throws FacadeException {
    validateProfile(profileFile);
    IPublisherAction jreAction = new JREAction(profileFile);
    Collection<IInstallableUnit> allIUs = publisherRunner.executeAction(jreAction, publishingRepository.getMetadataRepository(), publishingRepository.getArtifactRepository());
    return toSeeds(null, allIUs);
}
Also used : IPublisherAction(org.eclipse.equinox.p2.publisher.IPublisherAction) JREAction(org.eclipse.equinox.p2.publisher.actions.JREAction) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 2 with IPublisherAction

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

the class AbstractMetadataGenerator method publish.

private DependencyMetadata publish(PublisherInfo publisherInfo, List<IPublisherAction> actions) {
    PublisherResult result = new PublisherResult();
    Publisher publisher = new Publisher(publisherInfo, result);
    IStatus status = publisher.publish(actions.toArray(new IPublisherAction[actions.size()]), monitor);
    if (!status.isOK()) {
        throw new RuntimeException(StatusTool.collectProblems(status), status.getException());
    }
    DependencyMetadata metadata = new DependencyMetadata();
    metadata.setMetadata(true, result.getIUs(null, PublisherResult.ROOT));
    metadata.setMetadata(false, result.getIUs(null, PublisherResult.NON_ROOT));
    IArtifactRepository artifactRepository = publisherInfo.getArtifactRepository();
    if (artifactRepository instanceof TransientArtifactRepository) {
        metadata.setArtifacts(((TransientArtifactRepository) artifactRepository).getArtifactDescriptors());
    }
    return metadata;
}
Also used : IStatus(org.eclipse.core.runtime.IStatus) IPublisherAction(org.eclipse.equinox.p2.publisher.IPublisherAction) PublisherResult(org.eclipse.equinox.p2.publisher.PublisherResult) IArtifactRepository(org.eclipse.equinox.p2.repository.artifact.IArtifactRepository) Publisher(org.eclipse.equinox.p2.publisher.Publisher) TransientArtifactRepository(org.eclipse.tycho.p2.impl.publisher.repo.TransientArtifactRepository)

Example 3 with IPublisherAction

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

the class SourcesBundleDependencyMetadataGenerator method getPublisherActions.

@Override
protected List<IPublisherAction> getPublisherActions(IArtifactFacade artifact, List<TargetEnvironment> environments, OptionalResolutionAction optionalAction) {
    ArrayList<IPublisherAction> actions = new ArrayList<>();
    String id = artifact.getArtifactId();
    String version = toCanonicalVersion(artifact.getVersion());
    try {
        // generated source bundle is not available at this point in filesystem yet, need to create
        // in-memory BundleDescription instead
        Dictionary<String, String> manifest = new Hashtable<>();
        manifest.put("Manifest-Version", "1.0");
        manifest.put("Bundle-ManifestVersion", "2");
        String sourceBundleSymbolicName = id + ".source";
        manifest.put("Bundle-SymbolicName", sourceBundleSymbolicName);
        manifest.put("Bundle-Version", version);
        manifest.put("Eclipse-SourceBundle", id + ";version=" + version + ";roots:=\".\"");
        StateObjectFactory factory = StateObjectFactory.defaultFactory;
        BundleDescription bundleDescription = factory.createBundleDescription(factory.createState(false), manifest, artifact.getLocation().getAbsolutePath(), createId(sourceBundleSymbolicName, version));
        bundleDescription.setUserObject(manifest);
        actions.add(new BundlesAction(new BundleDescription[] { bundleDescription }) {

            @Override
            protected void createAdviceFileAdvice(BundleDescription bundleDescription, IPublisherInfo publisherInfo) {
            // 367255 p2.inf is not applicable to sources bundles
            }
        });
    } catch (BundleException e) {
        throw new RuntimeException(e);
    }
    return actions;
}
Also used : IPublisherAction(org.eclipse.equinox.p2.publisher.IPublisherAction) BundlesAction(org.eclipse.equinox.p2.publisher.eclipse.BundlesAction) Hashtable(java.util.Hashtable) BundleDescription(org.eclipse.osgi.service.resolver.BundleDescription) ArrayList(java.util.ArrayList) IPublisherInfo(org.eclipse.equinox.p2.publisher.IPublisherInfo) StateObjectFactory(org.eclipse.osgi.service.resolver.StateObjectFactory) BundleException(org.osgi.framework.BundleException)

Example 4 with IPublisherAction

use of org.eclipse.equinox.p2.publisher.IPublisherAction 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 5 with IPublisherAction

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

the class PublisherActionRunner method executeAction.

public Collection<IInstallableUnit> executeAction(IPublisherAction action, IMetadataRepository metadataOutput, IArtifactRepository artifactOutput, IPublisherAdvice... advice) {
    ResultSpyAction resultSpy = new ResultSpyAction();
    IPublisherAction[] actions = new IPublisherAction[] { action, resultSpy };
    /**
     * The PublisherInfo must not be cached, or results may leak between publishing actions (see
     * bug 346532).
     */
    IPublisherInfo publisherInfo = newPublisherInfo(metadataOutput, artifactOutput);
    for (IPublisherAdvice adviceItem : advice) {
        publisherInfo.addAdvice(adviceItem);
    }
    Publisher publisher = new Publisher(publisherInfo);
    IStatus result = publisher.publish(actions, null);
    handlePublisherStatus(result);
    return resultSpy.getAllIUs();
}
Also used : IPublisherAdvice(org.eclipse.equinox.p2.publisher.IPublisherAdvice) IStatus(org.eclipse.core.runtime.IStatus) IPublisherAction(org.eclipse.equinox.p2.publisher.IPublisherAction) Publisher(org.eclipse.equinox.p2.publisher.Publisher) IPublisherInfo(org.eclipse.equinox.p2.publisher.IPublisherInfo)

Aggregations

IPublisherAction (org.eclipse.equinox.p2.publisher.IPublisherAction)5 ArrayList (java.util.ArrayList)2 IStatus (org.eclipse.core.runtime.IStatus)2 IPublisherInfo (org.eclipse.equinox.p2.publisher.IPublisherInfo)2 Publisher (org.eclipse.equinox.p2.publisher.Publisher)2 BundlesAction (org.eclipse.equinox.p2.publisher.eclipse.BundlesAction)2 File (java.io.File)1 FileInputStream (java.io.FileInputStream)1 IOException (java.io.IOException)1 Hashtable (java.util.Hashtable)1 FeatureParser (org.eclipse.equinox.internal.p2.publisher.eclipse.FeatureParser)1 IProductDescriptor (org.eclipse.equinox.internal.p2.publisher.eclipse.IProductDescriptor)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 IPublisherAdvice (org.eclipse.equinox.p2.publisher.IPublisherAdvice)1 PublisherResult (org.eclipse.equinox.p2.publisher.PublisherResult)1 JREAction (org.eclipse.equinox.p2.publisher.actions.JREAction)1 Feature (org.eclipse.equinox.p2.publisher.eclipse.Feature)1