Search in sources :

Example 6 with TargetEnvironment

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

the class DirectorMojo method execute.

// TODO extract methods
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    List<Product> products = getProductConfig().getProducts();
    if (products.isEmpty()) {
        getLog().info("No product definitions found. Nothing to do.");
    }
    DirectorRuntime director = getDirectorRuntime();
    RepositoryReferences sources = getSourceRepositories();
    for (Product product : products) {
        for (TargetEnvironment env : getEnvironments()) {
            DirectorRuntime.Command command = director.newInstallCommand();
            File destination = getProductMaterializeDirectory(product, env);
            String rootFolder = product.getRootFolder(env.getOs());
            if (rootFolder != null && rootFolder.length() > 0) {
                destination = new File(destination, rootFolder);
            }
            command.addMetadataSources(sources.getMetadataRepositories());
            command.addArtifactSources(sources.getArtifactRepositories());
            command.addUnitToInstall(product.getId());
            for (DependencySeed seed : product.getAdditionalInstallationSeeds()) {
                command.addUnitToInstall(seed);
            }
            command.setDestination(destination);
            command.setProfileName(ProfileName.getNameForEnvironment(env, profileNames, profile));
            command.setEnvironment(env);
            command.setInstallFeatures(installFeatures);
            getLog().info("Installing product " + product.getId() + " for environment " + env + " to " + destination.getAbsolutePath());
            try {
                command.execute();
            } catch (DirectorCommandException e) {
                throw new MojoFailureException("Installation of product " + product.getId() + " for environment " + env + " failed", e);
            }
        }
    }
}
Also used : DependencySeed(org.eclipse.tycho.core.resolver.shared.DependencySeed) RepositoryReferences(org.eclipse.tycho.p2.tools.RepositoryReferences) DirectorCommandException(org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) File(java.io.File) DirectorRuntime(org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime)

Example 7 with TargetEnvironment

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

the class StandaloneDirectorRuntimeFactory method installStandaloneDirector.

private void installStandaloneDirector(File installLocation, ArtifactRepository localMavenRepository) throws MojoExecutionException {
    // using the internal director...
    DirectorRuntime bootstrapDirector = osgiServices.getService(DirectorRuntime.class);
    try {
        // ... install from a zipped p2 repository obtained via Maven ...
        URI directorRuntimeRepo = URI.create("jar:" + getDirectorRepositoryZip(localMavenRepository).toURI() + "!/");
        DirectorRuntime.Command command = bootstrapDirector.newInstallCommand();
        command.addMetadataSources(Arrays.asList(directorRuntimeRepo));
        command.addArtifactSources(Arrays.asList(directorRuntimeRepo));
        // ... a product that includes the p2 director application ...
        command.addUnitToInstall("tycho-standalone-p2-director");
        command.setProfileName("director");
        // ... to a location in the target folder
        command.setDestination(installLocation);
        // there is only this environment in the p2 repository zip
        // TODO use a "no environment-specific units" setting
        command.setEnvironment(new TargetEnvironment("linux", "gtk", "x86_64"));
        logger.info("Installing a standalone p2 Director...");
        command.execute();
    } catch (DirectorCommandException e) {
        throw new MojoExecutionException("Could not install the standalone director", e);
    }
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) DirectorCommandException(org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) URI(java.net.URI) DirectorRuntime(org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime)

Example 8 with TargetEnvironment

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

the class AbstractArtifactDependencyWalker method traverseProduct.

protected void traverseProduct(ProductConfiguration product, ArtifactDependencyVisitor visitor, WalkbackPath visited) {
    if (product.useFeatures()) {
        for (FeatureRef ref : product.getFeatures()) {
            traverseFeature(ref, visitor, visited);
        }
    } else {
        for (PluginRef ref : product.getPlugins()) {
            traversePlugin(ref, visitor, visited);
        }
    }
    Set<String> bundles = new HashSet<>();
    for (ArtifactDescriptor artifact : visited.getVisited()) {
        ArtifactKey key = artifact.getKey();
        if (ArtifactType.TYPE_ECLIPSE_PLUGIN.equals(key.getType())) {
            bundles.add(key.getId());
        }
    }
    if (environments != null && product.includeLaunchers()) {
        for (TargetEnvironment environment : environments) {
            String os = environment.getOs();
            String ws = environment.getWs();
            String arch = environment.getArch();
            String id;
            // see http://jira.codehaus.org/browse/MNGECLIPSE-1075
            if (PlatformPropertiesUtils.OS_MACOSX.equals(os) && (PlatformPropertiesUtils.ARCH_X86.equals(arch) || PlatformPropertiesUtils.ARCH_PPC.equals(arch))) {
                id = "org.eclipse.equinox.launcher." + ws + "." + os;
            } else {
                id = "org.eclipse.equinox.launcher." + ws + "." + os + "." + arch;
            }
            if (!bundles.contains(id)) {
                PluginRef ref = new PluginRef("plugin");
                ref.setId(id);
                ref.setOs(os);
                ref.setWs(ws);
                ref.setArch(arch);
                ref.setUnpack(true);
                traversePlugin(ref, visitor, visited);
            }
        }
    }
}
Also used : ArtifactKey(org.eclipse.tycho.ArtifactKey) ArtifactDescriptor(org.eclipse.tycho.ArtifactDescriptor) PluginRef(org.eclipse.tycho.model.PluginRef) FeatureRef(org.eclipse.tycho.model.FeatureRef) TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) HashSet(java.util.HashSet)

Example 9 with TargetEnvironment

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

the class EquinoxResolver method getPlatformProperties.

protected Properties getPlatformProperties(MavenProject project, ExecutionEnvironment ee) {
    TargetPlatformConfiguration configuration = TychoProjectUtils.getTargetPlatformConfiguration(project);
    TargetEnvironment environment = configuration.getEnvironments().get(0);
    Properties properties = new Properties();
    properties.putAll((Properties) project.getContextValue(TychoConstants.CTX_MERGED_PROPERTIES));
    return getPlatformProperties(properties, environment, ee);
}
Also used : TargetEnvironment(org.eclipse.tycho.core.shared.TargetEnvironment) Properties(java.util.Properties) TargetPlatformConfiguration(org.eclipse.tycho.core.TargetPlatformConfiguration)

Example 10 with TargetEnvironment

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

the class DefaultTargetPlatformConfigurationReader method newTargetEnvironment.

private static TargetEnvironment newTargetEnvironment(Xpp3Dom environmentDom) throws TargetPlatformConfigurationException {
    Xpp3Dom osDom = environmentDom.getChild("os");
    if (osDom == null) {
        String message = "<os> element is missing within target-platform-configuration (element <environment>)";
        throw new TargetPlatformConfigurationException(message);
    }
    Xpp3Dom wsDom = environmentDom.getChild("ws");
    if (wsDom == null) {
        String message = "<ws> element is missing within target-platform-configuration (element <environment>)";
        throw new TargetPlatformConfigurationException(message);
    }
    Xpp3Dom archDom = environmentDom.getChild("arch");
    if (archDom == null) {
        String message = "<arch> element is missing within target-platform-configuration (element <environment>)";
        throw new TargetPlatformConfigurationException(message);
    }
    return new TargetEnvironment(osDom.getValue(), wsDom.getValue(), archDom.getValue());
}
Also used : Xpp3Dom(org.codehaus.plexus.util.xml.Xpp3Dom) 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