Search in sources :

Example 11 with TargetEnvironment

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

the class DefaultTargetPlatformConfigurationReader method addTargetEnvironments.

private void addTargetEnvironments(TargetPlatformConfiguration result, MavenProject project, Xpp3Dom configuration) {
    try {
        TargetEnvironment deprecatedTargetEnvironmentSpec = getDeprecatedTargetEnvironment(configuration);
        if (deprecatedTargetEnvironmentSpec != null) {
            result.addEnvironment(deprecatedTargetEnvironmentSpec);
        }
        Xpp3Dom environmentsDom = configuration.getChild("environments");
        if (environmentsDom != null) {
            if (deprecatedTargetEnvironmentSpec != null) {
                String message = "Deprecated target-platform-configuration <environment> element must not be combined with new <environments> element; check the (inherited) configuration of " + project.getId();
                throw new RuntimeException(message);
            }
            for (Xpp3Dom environmentDom : environmentsDom.getChildren("environment")) {
                result.addEnvironment(newTargetEnvironment(environmentDom));
            }
        }
    } catch (TargetPlatformConfigurationException e) {
        throw new RuntimeException("target-platform-configuration error in project " + project.getId(), e);
    }
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment)

Example 12 with TargetEnvironment

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

the class P2DependencyResolver method setupProjects.

@Override
public void setupProjects(final MavenSession session, final MavenProject project, final ReactorProject reactorProject) {
    TargetPlatformConfiguration configuration = (TargetPlatformConfiguration) project.getContextValue(TychoConstants.CTX_TARGET_PLATFORM_CONFIGURATION);
    List<TargetEnvironment> environments = configuration.getEnvironments();
    Map<String, IDependencyMetadata> metadata = getDependencyMetadata(session, project, environments, OptionalResolutionAction.OPTIONAL);
    Set<Object> primaryMetadata = new LinkedHashSet<>();
    Set<Object> secondaryMetadata = new LinkedHashSet<>();
    for (Map.Entry<String, IDependencyMetadata> entry : metadata.entrySet()) {
        primaryMetadata.addAll(entry.getValue().getMetadata(true));
        secondaryMetadata.addAll(entry.getValue().getMetadata(false));
    }
    reactorProject.setDependencyMetadata(true, primaryMetadata);
    reactorProject.setDependencyMetadata(false, secondaryMetadata);
}
Also used : LinkedHashSet(java.util.LinkedHashSet) IDependencyMetadata(org.eclipse.tycho.p2.metadata.IDependencyMetadata) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration) Map(java.util.Map) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with TargetEnvironment

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

the class P2DependencyResolver method doResolveDependencies.

private DependencyArtifacts doResolveDependencies(MavenSession session, MavenProject project, List<ReactorProject> reactorProjects, DependencyResolverConfiguration resolverConfiguration, TargetPlatform targetPlatform, P2Resolver resolver, TargetPlatformConfiguration configuration) {
    Map<File, ReactorProject> projects = new HashMap<>();
    resolver.setEnvironments(configuration.getEnvironments());
    resolver.setAdditionalFilterProperties(configuration.getProfileProperties());
    for (ReactorProject otherProject : reactorProjects) {
        projects.put(otherProject.getBasedir(), otherProject);
    }
    if (resolverConfiguration != null) {
        for (Dependency dependency : resolverConfiguration.getExtraRequirements()) {
            try {
                resolver.addDependency(dependency.getType(), dependency.getArtifactId(), dependency.getVersion());
            } catch (IllegalArtifactReferenceException e) {
                throw new BuildFailureException("Invalid extraRequirement " + dependency.getType() + ":" + dependency.getArtifactId() + ":" + dependency.getVersion() + ": " + e.getMessage(), e);
            }
        }
    }
    // get reactor project with prepared optional dependencies // TODO use original IU and have the resolver create the modified IUs
    ReactorProject optionalDependencyPreparedProject = getThisReactorProject(session, project, configuration);
    if (!isAllowConflictingDependencies(project, configuration)) {
        List<P2ResolutionResult> results = resolver.resolveDependencies(targetPlatform, optionalDependencyPreparedProject);
        MultiEnvironmentDependencyArtifacts multiPlatform = new MultiEnvironmentDependencyArtifacts(DefaultReactorProject.adapt(project));
        // FIXME this is just wrong
        for (int i = 0; i < configuration.getEnvironments().size(); i++) {
            TargetEnvironment environment = configuration.getEnvironments().get(i);
            P2ResolutionResult result = results.get(i);
            DefaultDependencyArtifacts platform = newDefaultTargetPlatform(DefaultReactorProject.adapt(project), projects, result);
            multiPlatform.addPlatform(environment, platform);
        }
        return multiPlatform;
    } else {
        P2ResolutionResult result = resolver.collectProjectDependencies(targetPlatform, optionalDependencyPreparedProject);
        return newDefaultTargetPlatform(DefaultReactorProject.adapt(project), projects, result);
    }
}
Also used : HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) IllegalArtifactReferenceException(org.eclipse.tycho.artifacts.IllegalArtifactReferenceException) BuildFailureException(org.eclipse.tycho.core.shared.BuildFailureException) ReactorProject(org.eclipse.tycho.ReactorProject) DefaultReactorProject(org.eclipse.tycho.core.osgitools.DefaultReactorProject) ComponentDependency(org.codehaus.plexus.component.repository.ComponentDependency) Dependency(org.apache.maven.model.Dependency) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) MultiEnvironmentDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.MultiEnvironmentDependencyArtifacts) DefaultDependencyArtifacts(org.eclipse.tycho.core.osgitools.targetplatform.DefaultDependencyArtifacts) P2ResolutionResult(org.eclipse.tycho.p2.resolver.facade.P2ResolutionResult) File(java.io.File)

Example 14 with TargetEnvironment

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

the class ProductExportMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    getLog().warn("The packaging type 'eclipse-application' is deprecated; use 'eclipse-repository' instead. " + "See http://wiki.eclipse.org/Tycho_Messages_Explained#Eclipse_Application");
    if (!productConfigurationFile.exists()) {
        throw new MojoExecutionException("Product configuration file not found " + productConfigurationFile.getAbsolutePath());
    }
    try {
        getLog().debug("Parsing productConfiguration");
        productConfiguration = ProductConfiguration.read(productConfigurationFile);
    } catch (IOException e) {
        throw new MojoExecutionException("Error reading product configuration file", e);
    }
    // build results will vary from system to system without explicit target environment configuration
    boolean implicitTargetEnvironment = TychoProjectUtils.getTargetPlatformConfiguration(project).isImplicitTargetEnvironment();
    if (productConfiguration.includeLaunchers() && implicitTargetEnvironment && environments == null) {
        throw new MojoFailureException("Product includes native launcher but no target environment was specified");
    }
    if (separateEnvironments) {
        for (TargetEnvironment environment : getEnvironments()) {
            File target = getTarget(environment);
            File targetEclipse = new File(target, "eclipse");
            targetEclipse.mkdirs();
            generateDotEclipseProduct(targetEclipse);
            generateConfigIni(environment, targetEclipse);
            includeRootFiles(environment, targetEclipse);
            ProductAssembler assembler = new ProductAssembler(session, manifestReader, targetEclipse, environment);
            assembler.setIncludeSources(includeSources);
            getDependencyWalker(environment).walk(assembler);
            if (productConfiguration.includeLaunchers()) {
                copyExecutable(environment, targetEclipse);
            }
            if (createProductArchive) {
                createProductArchive(target, toString(environment));
            }
        }
    } else {
        File target = getTarget(null);
        File targetEclipse = new File(target, "eclipse");
        targetEclipse.mkdirs();
        generateDotEclipseProduct(targetEclipse);
        generateConfigIni(null, targetEclipse);
        for (TargetEnvironment environment : getEnvironments()) {
            includeRootFiles(environment, targetEclipse);
        }
        ProductAssembler assembler = new ProductAssembler(session, manifestReader, targetEclipse, null);
        assembler.setIncludeSources(includeSources);
        if (forcePackedDependencies) {
            assembler.setUnpackFeatures(false);
            assembler.setUnpackPlugins(false);
        }
        getDependencyWalker().walk(assembler);
        if (productConfiguration.includeLaunchers()) {
            for (TargetEnvironment environment : getEnvironments()) {
                copyExecutable(environment, targetEclipse);
            }
        }
        if (createProductArchive) {
            createProductArchive(target, null);
        }
    }
    try {
        ProductConfiguration.write(productConfiguration, expandedProductFile);
        if (p2inf.canRead()) {
            FileUtils.copyFile(p2inf, new File(expandedProductFile.getParentFile(), p2inf.getName()));
        }
    } catch (IOException e) {
        throw new MojoExecutionException("Error writing expanded product configuration file", e);
    }
    if (!createProductArchive || environments != null) {
        project.getArtifact().setFile(expandedProductFile);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) IOException(java.io.IOException) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) ZipFile(java.util.zip.ZipFile) File(java.io.File)

Example 15 with TargetEnvironment

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

the class TargetDefinitionResolverWithPlatformSpecificUnitsTest method testSlicerResolutionWithMultiplePlatforms.

@Test
public void testSlicerResolutionWithMultiplePlatforms() throws Exception {
    List<TargetEnvironment> environments = Arrays.asList(new TargetEnvironment("win32", "win32", "x86"), new TargetEnvironment("macosx", "carbon", "x86"));
    targetDefinition = definitionWith(new FilterRepoLocationStubWithLauncherUnit(IncludeMode.SLICER));
    subject = createResolver(environments);
    TargetDefinitionContent units = subject.resolveContent(targetDefinition);
    assertThat(versionedIdsOf(units), bagEquals(versionedIdList(LAUNCHER_FEATURE, LAUNCHER_FEATURE_JAR, LAUNCHER_BUNDLE, LAUNCHER_BUNDLE_WINDOWS, LAUNCHER_BUNDLE_MAC)));
}
Also used : TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Test(org.junit.Test)

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