Search in sources :

Example 31 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.

the class P2DependencyResolver method getThisReactorProject.

private ReactorProject getThisReactorProject(MavenSession session, MavenProject project, TargetPlatformConfiguration configuration) {
    // 'this' project should obey optionalDependencies configuration
    final List<TargetEnvironment> environments = configuration.getEnvironments();
    final OptionalResolutionAction optionalAction = configuration.getDependencyResolverConfiguration().getOptionalResolutionAction();
    Map<String, IDependencyMetadata> dependencyMetadata = getDependencyMetadata(session, project, environments, optionalAction);
    final Set<Object> metadata = new LinkedHashSet<>();
    final Set<Object> secondaryMetadata = new LinkedHashSet<>();
    for (Map.Entry<String, IDependencyMetadata> entry : dependencyMetadata.entrySet()) {
        metadata.addAll(entry.getValue().getMetadata(true));
        secondaryMetadata.addAll(entry.getValue().getMetadata(false));
    }
    ReactorProject reactorProjet = new DefaultReactorProject(project) {

        @Override
        public Set<?> getDependencyMetadata(boolean primary) {
            return primary ? metadata : secondaryMetadata;
        }
    };
    return reactorProjet;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) OptionalResolutionAction(org.eclipse.tycho.core.resolver.shared.OptionalResolutionAction) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 32 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.

the class ProductArchiverMojoTest method testGetArtifactClassifier.

@Test
public void testGetArtifactClassifier() {
    TargetEnvironment env = new TargetEnvironment("os", "ws", "arch");
    Product product = new Product("product.id");
    String classifier = ProductArchiverMojo.getArtifactClassifier(product, env);
    assertEquals("os.ws.arch", classifier);
}
Also used : TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Test(org.junit.Test)

Example 33 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.

the class ProductArchiverMojoTest method testGetArtifactClassifierWithAttachId.

@Test
public void testGetArtifactClassifierWithAttachId() {
    TargetEnvironment env = new TargetEnvironment("os", "ws", "arch");
    Product product = new Product("product.id", "attachId");
    String classifier = ProductArchiverMojo.getArtifactClassifier(product, env);
    assertEquals("attachId-os.ws.arch", classifier);
}
Also used : TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Test(org.junit.Test)

Example 34 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.

the class ProductArchiverMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    ProductConfig config = getProductConfig();
    if (!config.uniqueAttachIds()) {
        throw new MojoFailureException("Artifact file names for the archived products are not unique. " + "Configure the attachId or select a subset of products. Current configuration: " + config.getProducts());
    }
    for (Product product : config.getProducts()) {
        for (TargetEnvironment env : getEnvironments()) {
            String format = getArchiveFormat(env);
            ProductArchiver productArchiver = productArchivers.get(format);
            if (productArchiver == null) {
                throw new MojoExecutionException("Unknown or unsupported archive format os=" + env.getOs() + " format=" + format);
            }
            File productArchive = new File(getProductsBuildDirectory(), getArchiveFileName(product) + "-" + getOsWsArch(env, '.') + "." + format);
            try {
                final File sourceDir = getProductMaterializeDirectory(product, env);
                if (TAR_GZ_ARCHIVE_FORMAT.equals(format) && !"plexus".equals(getSession().getUserProperties().getProperty("tycho.tar"))) {
                    getLog().debug("Using commons-compress tar");
                    createCommonsCompressTarGz(productArchive, sourceDir);
                } else {
                    Archiver archiver = productArchiver.getArchiver();
                    archiver.setDestFile(productArchive);
                    DefaultFileSet fileSet = new DefaultFileSet(sourceDir);
                    fileSet.setUsingDefaultExcludes(false);
                    archiver.addFileSet(fileSet);
                    archiver.createArchive();
                }
            } catch (ArchiverException e) {
                throw new MojoExecutionException("Error packing product", e);
            } catch (IOException e) {
                throw new MojoExecutionException("Error packing product", e);
            }
            final String artifactClassifier = getArtifactClassifier(product, env);
            helper.attachArtifact(getProject(), format, artifactClassifier, productArchive);
        }
    }
}
Also used : DefaultFileSet(org.codehaus.plexus.archiver.util.DefaultFileSet) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) ArchiverException(org.codehaus.plexus.archiver.ArchiverException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) IOException(java.io.IOException) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) File(java.io.File) TarArchiver(org.codehaus.plexus.archiver.tar.TarArchiver) TarGzArchiver(org.eclipse.tycho.plugins.tar.TarGzArchiver) Archiver(org.codehaus.plexus.archiver.Archiver)

Example 35 with TargetEnvironment

use of org.eclipse.tycho.core.shared.TargetEnvironment in project tycho by eclipse.

the class MirrorApplicationServiceImpl method mirrorReactor.

@Override
public void mirrorReactor(RepositoryReferences sources, DestinationRepositoryDescriptor destination, Collection<DependencySeed> projectSeeds, BuildContext context, boolean includeAllDependencies, boolean includePacked, Map<String, String> filterProperties) throws FacadeException {
    IProvisioningAgent agent = Activator.createProvisioningAgent(context.getTargetDirectory());
    try {
        final MirrorApplication mirrorApp = createMirrorApplication(sources, destination, agent, includePacked);
        // mirror scope: seed units...
        mirrorApp.setSourceIUs(toInstallableUnitList(projectSeeds, mirrorApp.getCompositeMetadataRepository(), sources));
        // TODO the p2 mirror tool should support mirroring multiple environments at once
        for (TargetEnvironment environment : context.getEnvironments()) {
            SlicingOptions options = new SlicingOptions();
            options.considerStrictDependencyOnly(!includeAllDependencies);
            Map<String, String> filter = options.getFilter();
            addFilterForFeatureJARs(filter);
            if (filterProperties != null) {
                filter.putAll(filterProperties);
            }
            filter.putAll(environment.toFilterProperties());
            mirrorApp.setSlicingOptions(options);
            try {
                LogListener logListener = new LogListener(mavenContext.getLogger());
                mirrorApp.setLog(logListener);
                IStatus returnStatus = mirrorApp.run(null);
                checkStatus(returnStatus, false);
                logListener.showHelpForLoggedMessages();
            } catch (ProvisionException e) {
                throw new FacadeException(MIRROR_FAILURE_MESSAGE + ": " + StatusTool.collectProblems(e.getStatus()), e);
            }
        }
        recreateArtifactRepository(destination);
        xzCompress(destination);
    } finally {
        agent.stop();
    }
}
Also used : FacadeException(org.eclipse.tycho.p2.tools.FacadeException) IStatus(org.eclipse.core.runtime.IStatus) ProvisionException(org.eclipse.equinox.p2.core.ProvisionException) SlicingOptions(org.eclipse.equinox.p2.internal.repository.tools.SlicingOptions) IProvisioningAgent(org.eclipse.equinox.p2.core.IProvisioningAgent) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment)

Aggregations

TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)38 Test (org.junit.Test)14 File (java.io.File)10 ArrayList (java.util.ArrayList)6 TargetPlatformConfiguration (org.eclipse.tycho.core.TargetPlatformConfiguration)6 HashMap (java.util.HashMap)4 LinkedHashMap (java.util.LinkedHashMap)3 LinkedHashSet (java.util.LinkedHashSet)3 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)3 Xpp3Dom (org.codehaus.plexus.util.xml.Xpp3Dom)3 P2ResolutionResult (org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult)3 IOException (java.io.IOException)2 Map (java.util.Map)2 Properties (java.util.Properties)2 MavenSession (org.apache.maven.execution.MavenSession)2 MavenProject (org.apache.maven.project.MavenProject)2 ArtifactDescriptor (org.eclipse.tycho.ArtifactDescriptor)2 ArtifactKey (org.eclipse.tycho.ArtifactKey)2 ReactorProject (org.eclipse.tycho.ReactorProject)2