Search in sources :

Example 1 with DirectorCommandException

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

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

use of org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException in project tycho by eclipse.

the class StandaloneDirectorRuntime method newInstallCommand.

@Override
public Command newInstallCommand() {
    return new AbstractDirectorApplicationCommand() {

        @Override
        public void execute() throws DirectorCommandException {
            List<String> programArguments = new ArrayList<>();
            programArguments.add("-application");
            programArguments.add("org.eclipse.equinox.p2.director");
            programArguments.addAll(getDirectorApplicationArguments());
            LaunchConfiguration launch = new EquinoxInstallationLaunchConfiguration(runtimeLocation, programArguments);
            logger.info("Using the standalone p2 Director to install the product...");
            int exitCode = launchHelper.execute(launch, forkedProcessTimeoutInSeconds);
            if (exitCode != 0) {
                throw new DirectorCommandException("Call to p2 director application failed with exit code " + exitCode + ". Program arguments were: " + programArguments + ".");
            }
        }
    };
}
Also used : LaunchConfiguration(org.eclipse.tycho.launching.LaunchConfiguration) EquinoxInstallationLaunchConfiguration(org.eclipse.sisu.equinox.launching.internal.EquinoxInstallationLaunchConfiguration) EquinoxInstallationLaunchConfiguration(org.eclipse.sisu.equinox.launching.internal.EquinoxInstallationLaunchConfiguration) DirectorCommandException(org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException) ArrayList(java.util.ArrayList) AbstractDirectorApplicationCommand(org.eclipse.tycho.p2.tools.director.shared.AbstractDirectorApplicationCommand)

Example 4 with DirectorCommandException

use of org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException in project tycho by eclipse.

the class ProvisionedInstallationBuilder method executeDirector.

private void executeDirector() throws MojoFailureException {
    DirectorRuntime.Command command = directorRuntime.newInstallCommand();
    command.addMetadataSources(metadataRepos);
    command.addArtifactSources(artifactRepos);
    for (String iu : ius) {
        command.addUnitToInstall(iu);
    }
    command.setDestination(effectiveDestination);
    command.setProfileName(profileName);
    command.setInstallFeatures(installFeatures);
    command.setEnvironment(TargetEnvironment.getRunningEnvironment());
    log.info("Installing IUs " + ius + " to " + effectiveDestination);
    try {
        command.execute();
    } catch (DirectorCommandException e) {
        throw new MojoFailureException("Installation of IUs " + ius + " failed", e);
    }
}
Also used : DirectorCommandException(org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) DirectorRuntime(org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime)

Aggregations

DirectorCommandException (org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException)4 DirectorRuntime (org.eclipse.tycho.p2.tools.director.shared.DirectorRuntime)3 MojoFailureException (org.apache.maven.plugin.MojoFailureException)2 TargetEnvironment (org.eclipse.tycho.core.shared.TargetEnvironment)2 File (java.io.File)1 URI (java.net.URI)1 ArrayList (java.util.ArrayList)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 EquinoxInstallationLaunchConfiguration (org.eclipse.sisu.equinox.launching.internal.EquinoxInstallationLaunchConfiguration)1 DependencySeed (org.eclipse.tycho.core.resolver.shared.DependencySeed)1 LaunchConfiguration (org.eclipse.tycho.launching.LaunchConfiguration)1 RepositoryReferences (org.eclipse.tycho.p2.tools.RepositoryReferences)1 AbstractDirectorApplicationCommand (org.eclipse.tycho.p2.tools.director.shared.AbstractDirectorApplicationCommand)1