Search in sources :

Example 1 with DirectorRuntime

use of org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime 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 2 with DirectorRuntime

use of org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime 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)

Aggregations

TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)2 DirectorCommandException (org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException)2 DirectorRuntime (org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime)2 File (java.io.File)1 URI (java.net.URI)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)1 RepositoryReferences (org.eclipse.tycho.p2.tools.RepositoryReferences)1