Search in sources :

Example 1 with EquinoxInstallation

use of org.eclipse.sisu.equinox.launching.EquinoxInstallation in project tycho by eclipse.

the class P2ApplicationLauncher method execute.

public int execute(int forkedProcessTimeoutInSeconds) {
    try {
        File installationFolder = newTemporaryFolder();
        try {
            final EquinoxInstallationDescription description = new DefaultEquinoxInstallationDescription();
            runtimeLocator.locateRuntime(new EquinoxRuntimeDescription() {

                @Override
                public void addPlatformProperty(String property, String value) {
                    description.addPlatformProperty(property, value);
                }

                @Override
                public void addInstallation(File location) {
                    for (File file : new File(location, "plugins").listFiles()) {
                        P2ApplicationLauncher.this.addBundle(description, file);
                    }
                }

                @Override
                public void addExtraSystemPackage(String systemPackages) {
                }

                @Override
                public void addBundle(File location) {
                    P2ApplicationLauncher.this.addBundle(description, location);
                }

                @Override
                public void addBundleStartLevel(String id, int level, boolean autostart) {
                    description.addBundleStartLevel(new BundleStartLevel(id, level, autostart));
                }
            });
            EquinoxInstallation installation = installationFactory.createInstallation(description, installationFolder);
            EquinoxLaunchConfiguration launchConfiguration = new EquinoxLaunchConfiguration(installation);
            launchConfiguration.setWorkingDirectory(workingDirectory);
            launchConfiguration.addProgramArguments("-configuration", installation.getConfigurationLocation().getAbsolutePath());
            if (logger.isDebugEnabled()) {
                launchConfiguration.addProgramArguments("-debug", "-consoleLog");
                launchConfiguration.addProgramArguments("-console");
            }
            // application and application arguments
            launchConfiguration.addProgramArguments("-nosplash", "-application", applicationName);
            launchConfiguration.addProgramArguments(args.toArray(new String[args.size()]));
            return launcher.execute(launchConfiguration, forkedProcessTimeoutInSeconds);
        } finally {
            try {
                FileUtils.deleteDirectory(installationFolder);
            } catch (IOException e) {
                // this may happen if child process did not close all file handles
                logger.warn("Failed to delete temp folder " + installationFolder);
            }
        }
    } catch (Exception e) {
        // TODO better exception?
        throw new RuntimeException(e);
    }
}
Also used : BundleStartLevel(org.eclipse.sisu.equinox.launching.BundleStartLevel) IOException(java.io.IOException) EquinoxInstallation(org.eclipse.sisu.equinox.launching.EquinoxInstallation) IOException(java.io.IOException) EquinoxInstallationDescription(org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription) DefaultEquinoxInstallationDescription(org.eclipse.sisu.equinox.launching.DefaultEquinoxInstallationDescription) EquinoxRuntimeDescription(org.eclipse.sisu.equinox.embedder.EquinoxRuntimeLocator.EquinoxRuntimeDescription) DefaultEquinoxInstallationDescription(org.eclipse.sisu.equinox.launching.DefaultEquinoxInstallationDescription) File(java.io.File)

Example 2 with EquinoxInstallation

use of org.eclipse.sisu.equinox.launching.EquinoxInstallation in project tycho by eclipse.

the class TestMojo method execute.

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
    if (shouldSkip()) {
        getLog().info("Skipping tests");
        return;
    }
    if (!"eclipse-test-plugin".equals(project.getPackaging())) {
        getLog().warn("Unsupported packaging type " + project.getPackaging());
        return;
    }
    EquinoxInstallation equinoxTestRuntime;
    if ("p2Installed".equals(testRuntime)) {
        equinoxTestRuntime = createProvisionedInstallation();
    } else if ("default".equals(testRuntime)) {
        equinoxTestRuntime = createEclipseInstallation();
    } else {
        throw new MojoExecutionException("Configured testRuntime parameter value '" + testRuntime + "' is unkown. Allowed values: 'default', 'p2Installed'.");
    }
    runTest(equinoxTestRuntime);
}
Also used : MojoExecutionException(org.apache.maven.plugin.MojoExecutionException) EquinoxInstallation(org.eclipse.sisu.equinox.launching.EquinoxInstallation)

Aggregations

EquinoxInstallation (org.eclipse.sisu.equinox.launching.EquinoxInstallation)2 File (java.io.File)1 IOException (java.io.IOException)1 MojoExecutionException (org.apache.maven.plugin.MojoExecutionException)1 EquinoxRuntimeDescription (org.eclipse.sisu.equinox.embedder.EquinoxRuntimeLocator.EquinoxRuntimeDescription)1 BundleStartLevel (org.eclipse.sisu.equinox.launching.BundleStartLevel)1 DefaultEquinoxInstallationDescription (org.eclipse.sisu.equinox.launching.DefaultEquinoxInstallationDescription)1 EquinoxInstallationDescription (org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription)1