Search in sources :

Example 1 with PublisherServiceFactory

use of org.eclipse.tycho.p2.tools.publisher.facade.PublisherServiceFactory in project tycho by eclipse.

the class PublisherServiceFactoryTest method testThatRequiredServicesAreAvailable.

@Test
public void testThatRequiredServicesAreAvailable() throws Exception {
    ServiceTracker<PublisherServiceFactory, PublisherServiceFactory> tracker = new ServiceTracker<>(Activator.getContext(), PublisherServiceFactory.class, null);
    tracker.open();
    try {
        PublisherServiceFactory publisherServiceFactory = tracker.waitForService(2000);
        // factory service is only available if all required services are available
        assertThat(publisherServiceFactory, is(notNullValue()));
    } finally {
        tracker.close();
    }
}
Also used : PublisherServiceFactory(org.eclipse.tycho.p2.tools.publisher.facade.PublisherServiceFactory) ServiceTracker(org.osgi.util.tracker.ServiceTracker) Test(org.junit.Test)

Example 2 with PublisherServiceFactory

use of org.eclipse.tycho.p2.tools.publisher.facade.PublisherServiceFactory 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 3 with PublisherServiceFactory

use of org.eclipse.tycho.p2.tools.publisher.facade.PublisherServiceFactory in project tycho by eclipse.

the class PublishCategoriesMojo method publishContent.

@Override
protected Collection<DependencySeed> publishContent(PublisherServiceFactory publisherServiceFactory) throws MojoExecutionException, MojoFailureException {
    PublisherService publisherService = publisherServiceFactory.createPublisher(getReactorProject(), getEnvironments());
    try {
        List<DependencySeed> categoryIUs = new ArrayList<>();
        for (Category category : getCategories()) {
            final File buildCategoryFile = prepareBuildCategory(category, getBuildDirectory());
            Collection<DependencySeed> ius = publisherService.publishCategories(buildCategoryFile);
            categoryIUs.addAll(ius);
        }
        return categoryIUs;
    } catch (FacadeException e) {
        throw new MojoExecutionException("Exception while publishing categories: " + e.getMessage(), e);
    }
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) FacadeException(org.eclipse.tycho.p2.tools.FacadeException) Category(org.eclipse.tycho.model.Category) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) PublisherService(org.eclipse.tycho.p2.tools.publisher.facade.PublisherService) ArrayList(java.util.ArrayList) File(java.io.File)

Example 4 with PublisherServiceFactory

use of org.eclipse.tycho.p2.tools.publisher.facade.PublisherServiceFactory in project tycho by eclipse.

the class PublishEEProfileMojo method publishContent.

@Override
protected Collection<DependencySeed> publishContent(PublisherServiceFactory publisherServiceFactory) throws MojoExecutionException, MojoFailureException {
    PublisherService publisherService = publisherServiceFactory.createPublisher(getReactorProject(), getEnvironments());
    try {
        Collection<DependencySeed> ius = publisherService.publishEEProfile(profileFile);
        getLog().info("Published profile IUs: " + ius);
        return ius;
    } catch (FacadeException e) {
        throw new MojoExecutionException("Exception while publishing execution environment profile " + profileFile + ": " + e.getMessage(), e);
    }
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) FacadeException(org.eclipse.tycho.p2.tools.FacadeException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) PublisherService(org.eclipse.tycho.p2.tools.publisher.facade.PublisherService)

Example 5 with PublisherServiceFactory

use of org.eclipse.tycho.p2.tools.publisher.facade.PublisherServiceFactory in project tycho by eclipse.

the class PublishProductMojo method publishContent.

@Override
protected Collection<DependencySeed> publishContent(PublisherServiceFactory publisherServiceFactory) throws MojoExecutionException, MojoFailureException {
    Interpolator interpolator = new TychoInterpolator(getSession(), getProject());
    PublishProductTool publisher = publisherServiceFactory.createProductPublisher(getReactorProject(), getEnvironments(), getQualifier(), interpolator);
    List<DependencySeed> seeds = new ArrayList<>();
    for (File productFile : getEclipseRepositoryProject().getProductFiles(getProject())) {
        try {
            ProductConfiguration productConfiguration = ProductConfiguration.read(productFile);
            if (isEmpty(productConfiguration.getId())) {
                throw new MojoExecutionException("The product file " + productFile.getName() + " does not contain the mandatory attribute 'uid'. Please ensure you entered an id in the product file.");
            } else if (isEmpty(productConfiguration.getVersion())) {
                throw new MojoExecutionException("The product file " + productFile.getName() + " does not contain the mandatory attribute 'version'. Please ensure you entered a version in the product file.");
            }
            seeds.addAll(publisher.publishProduct(productFile, productConfiguration.includeLaunchers() ? getExpandedLauncherBinaries() : null, flavor));
        } catch (IOException e) {
            throw new MojoExecutionException("I/O exception while writing product definition or copying launcher icons", e);
        }
    }
    return seeds;
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) ProductConfiguration(org.eclipse.tycho.model.ProductConfiguration) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) PublishProductTool(org.eclipse.tycho.p2.tools.publisher.facade.PublishProductTool) ArrayList(java.util.ArrayList) Interpolator(org.eclipse.tycho.core.shared.Interpolator) TychoInterpolator(org.eclipse.tycho.core.maven.TychoInterpolator) IOException(java.io.IOException) TychoInterpolator(org.eclipse.tycho.core.maven.TychoInterpolator) File(java.io.File)

Aggregations

DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)4 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 File (java.io.File)2 ArrayList (java.util.ArrayList)2 FacadeException (org.eclipse.tycho.p2.tools.FacadeException)2 PublisherService (org.eclipse.tycho.p2.tools.publisher.facade.PublisherService)2 PublisherServiceFactory (org.eclipse.tycho.p2.tools.publisher.facade.PublisherServiceFactory)2 IOException (java.io.IOException)1 TychoInterpolator (org.eclipse.tycho.core.maven.TychoInterpolator)1 Interpolator (org.eclipse.tycho.core.shared.Interpolator)1 Category (org.eclipse.tycho.model.Category)1 ProductConfiguration (org.eclipse.tycho.model.ProductConfiguration)1 PublishProductTool (org.eclipse.tycho.p2.tools.publisher.facade.PublishProductTool)1 Test (org.junit.Test)1 ServiceTracker (org.osgi.util.tracker.ServiceTracker)1