Search in sources :

Example 11 with DependencySeed

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

the class PublisherServiceTest method unitsById.

/**
 * Returns the installable units from the given dependency seeds, indexed by the installable
 * units's IDs.
 */
private static Map<String, IInstallableUnit> unitsById(Collection<DependencySeed> seeds) {
    Map<String, IInstallableUnit> result = new HashMap<>();
    for (DependencySeed seed : seeds) {
        IInstallableUnit iu = (IInstallableUnit) seed.getInstallableUnit();
        result.put(iu.getId(), iu);
    }
    return result;
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) HashMap(java.util.HashMap) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit)

Example 12 with DependencySeed

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

the class PublisherServiceTest method testProfilePublishing.

@Test
public void testProfilePublishing() throws Exception {
    File customProfile = resourceFile("publishers/virgo-1.6.profile");
    Collection<DependencySeed> seeds = subject.publishEEProfile(customProfile);
    assertThat(seeds.size(), is(2));
    IInstallableUnit virgoProfileIU = unitsById(seeds).get("a.jre.virgo");
    assertThat(virgoProfileIU, not(nullValue()));
    Collection<IProvidedCapability> provided = virgoProfileIU.getProvidedCapabilities();
    boolean customJavaxActivationVersionFound = false;
    Version version_1_1_1 = Version.create("1.1.1");
    for (IProvidedCapability capability : provided) {
        if (PublisherHelper.CAPABILITY_NS_JAVA_PACKAGE.equals(capability.getNamespace())) {
            if ("javax.activation".equals(capability.getName())) {
                if (version_1_1_1.equals(capability.getVersion())) {
                    customJavaxActivationVersionFound = true;
                    break;
                }
            }
        }
    }
    assertTrue("did not find capability for package javax.activation with custom version " + version_1_1_1, customJavaxActivationVersionFound);
    assertThat(unitsById(seeds).keySet(), hasItem("config.a.jre.virgo"));
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) IProvidedCapability(org.eclipse.equinox.p2.metadata.IProvidedCapability) Version(org.eclipse.equinox.p2.metadata.Version) IInstallableUnit(org.eclipse.equinox.p2.metadata.IInstallableUnit) ResourceUtil.resourceFile(org.eclipse.tycho.p2.tools.test.util.ResourceUtil.resourceFile) File(java.io.File) Test(org.junit.Test)

Example 13 with DependencySeed

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

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

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