use of org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription in project tycho by eclipse.
the class TestMojo method createEclipseInstallation.
private EquinoxInstallation createEclipseInstallation() throws MojoExecutionException {
DependencyResolver platformResolver = dependencyResolverLocator.lookupDependencyResolver(project);
final List<Dependency> extraDependencies = getExtraDependencies();
List<ReactorProject> reactorProjects = getReactorProjects();
final DependencyResolverConfiguration resolverConfiguration = new DependencyResolverConfiguration() {
@Override
public OptionalResolutionAction getOptionalResolutionAction() {
return OptionalResolutionAction.IGNORE;
}
@Override
public List<Dependency> getExtraRequirements() {
return extraDependencies;
}
};
DependencyArtifacts testRuntimeArtifacts = platformResolver.resolveDependencies(session, project, null, reactorProjects, resolverConfiguration);
if (testRuntimeArtifacts == null) {
throw new MojoExecutionException("Cannot determinate build target platform location -- not executing tests");
}
work.mkdirs();
EquinoxInstallationDescription testRuntime = new DefaultEquinoxInstallationDescription();
testRuntime.setDefaultBundleStartLevel(defaultStartLevel);
testRuntime.addBundlesToExplode(getBundlesToExplode());
testRuntime.addFrameworkExtensions(getFrameworkExtensions());
if (bundleStartLevel != null) {
for (BundleStartLevel level : bundleStartLevel) {
testRuntime.addBundleStartLevel(level);
}
}
TestFrameworkProvider provider = providerHelper.selectProvider(getProjectType().getClasspath(project), getMergedProviderProperties(), providerHint);
createSurefireProperties(provider);
for (ArtifactDescriptor artifact : testRuntimeArtifacts.getArtifacts(ArtifactType.TYPE_ECLIPSE_PLUGIN)) {
// note that this project is added as directory structure rooted at project basedir.
// project classes and test-classes are added via dev.properties file (see #createDevProperties())
// all other projects are added as bundle jars.
ReactorProject otherProject = artifact.getMavenProject();
if (otherProject != null) {
if (otherProject.sameProject(project)) {
testRuntime.addBundle(artifact.getKey(), project.getBasedir());
continue;
}
File file = otherProject.getArtifact(artifact.getClassifier());
if (file != null) {
testRuntime.addBundle(artifact.getKey(), file);
continue;
}
}
testRuntime.addBundle(artifact);
}
Set<Artifact> testFrameworkBundles = providerHelper.filterTestFrameworkBundles(provider, pluginArtifacts);
for (Artifact artifact : testFrameworkBundles) {
DevBundleInfo devInfo = workspaceState.getBundleInfo(session, artifact.getGroupId(), artifact.getArtifactId(), artifact.getVersion(), project.getPluginArtifactRepositories());
if (devInfo != null) {
testRuntime.addBundle(devInfo.getArtifactKey(), devInfo.getLocation(), true);
testRuntime.addDevEntries(devInfo.getSymbolicName(), devInfo.getDevEntries());
} else {
File bundleLocation = artifact.getFile();
ArtifactKey bundleArtifactKey = getBundleArtifactKey(bundleLocation);
testRuntime.addBundle(bundleArtifactKey, bundleLocation, true);
}
}
testRuntime.addDevEntries(getTestBundleSymbolicName(), getBuildOutputDirectories());
reportsDirectory.mkdirs();
return installationFactory.createInstallation(testRuntime, work);
}
use of org.eclipse.sisu.equinox.launching.EquinoxInstallationDescription 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);
}
}
Aggregations