Search in sources :

Example 1 with LaunchConfiguration

use of org.eclipse.tycho.launching.LaunchConfiguration 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 2 with LaunchConfiguration

use of org.eclipse.tycho.launching.LaunchConfiguration in project tycho by eclipse.

the class TestMojo method runTest.

private void runTest(EquinoxInstallation testRuntime) throws MojoExecutionException, MojoFailureException {
    int result;
    try {
        if (deleteOsgiDataDirectory) {
            FileUtils.deleteDirectory(osgiDataDirectory);
        }
        LaunchConfiguration cli = createCommandLine(testRuntime);
        getLog().info("Expected eclipse log file: " + new File(osgiDataDirectory, ".metadata/.log").getAbsolutePath());
        result = launcher.execute(cli, forkedProcessTimeoutInSeconds);
    } catch (Exception e) {
        throw new MojoExecutionException("Error while executing platform", e);
    }
    switch(result) {
        case 0:
            getLog().info("All tests passed!");
            break;
        case 200:
            /* see AbstractUITestApplication */
            if (application == null) {
                // the extra test dependencies should prevent this case
                throw new MojoExecutionException("Could not find the default application \"org.eclipse.ui.ide.workbench\" in the test runtime.");
            } else {
                throw new MojoFailureException("Could not find application \"" + application + "\" in the test runtime. Make sure that the test runtime includes the bundle " + "which defines this application.");
            }
        case 254:
            /* RunResult.NO_TESTS */
            String message = "No tests found.";
            if (failIfNoTests) {
                throw new MojoFailureException(message);
            } else {
                getLog().warn(message);
            }
            break;
        case 255:
            /* RunResult.FAILURE */
            String errorMessage = "There are test failures.\n\nPlease refer to " + reportsDirectory + " for the individual test results.";
            if (testFailureIgnore) {
                getLog().error(errorMessage);
            } else {
                throw new MojoFailureException(errorMessage);
            }
            break;
        default:
            throw new MojoFailureException("An unexpected error occured while launching the test runtime (return code " + result + "). See log for details.");
    }
}
Also used : LaunchConfiguration(org.eclipse.tycho.launching.LaunchConfiguration) EquinoxLaunchConfiguration(org.eclipse.sisu.equinox.launching.internal.EquinoxLaunchConfiguration) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException) File(java.io.File) MalformedURLException(java.net.MalformedURLException) ArtifactResolutionException(org.apache.maven.artifact.resolver.ArtifactResolutionException) IOException(java.io.IOException) MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) MojoFailureException(org.apache.maven.plugin.MojoFailureException)

Aggregations

LaunchConfiguration (org.eclipse.tycho.launching.LaunchConfiguration)2 File (java.io.File)1 IOException (java.io.IOException)1 MalformedURLException (java.net.MalformedURLException)1 ArrayList (java.util.ArrayList)1 ArtifactResolutionException (org.apache.maven.artifact.resolver.ArtifactResolutionException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 MojoFailureException (org.apache.maven.plugin.MojoFailureException)1 EquinoxInstallationLaunchConfiguration (org.eclipse.sisu.equinox.launching.internal.EquinoxInstallationLaunchConfiguration)1 EquinoxLaunchConfiguration (org.eclipse.sisu.equinox.launching.internal.EquinoxLaunchConfiguration)1 AbstractDirectorApplicationCommand (org.eclipse.tycho.p2.tools.director.shared.AbstractDirectorApplicationCommand)1 DirectorCommandException (org.eclipse.tycho.p2.tools.director.shared.DirectorCommandException)1