use of org.eclipse.pde.core.target.LoadTargetDefinitionJob in project xtext-eclipse by eclipse.
the class TargetPlatformUtil method setTargetPlatform.
/**
* Sets the target platform for tests (to be used in tycho mainly)
* @param context any class of the test bundle to be able to determine the test bundle
* @since 2.14
*/
public static void setTargetPlatform(Class<?> context) throws Exception {
if (isPdeLaunch()) {
return;
}
Bundle currentBundle = FrameworkUtil.getBundle(context);
ITargetPlatformService tpService = TargetPlatformService.getDefault();
ITargetDefinition targetDef = tpService.newTarget();
targetDef.setName("Tycho platform");
Bundle[] bundles = FrameworkUtil.getBundle(Platform.class).getBundleContext().getBundles();
List<ITargetLocation> bundleContainers = new ArrayList<ITargetLocation>();
Set<File> dirs = new HashSet<File>();
for (Bundle bundle : bundles) {
if (bundle.equals(currentBundle)) {
// errors during our tests.
continue;
}
EquinoxBundle bundleImpl = (EquinoxBundle) bundle;
Generation generation = (Generation) bundleImpl.getModule().getCurrentRevision().getRevisionInfo();
File file = generation.getBundleFile().getBaseFile();
File folder = file.getParentFile();
if ((file.isFile() || Platform.inDevelopmentMode()) && !dirs.contains(folder)) {
dirs.add(folder);
bundleContainers.add(tpService.newDirectoryLocation(folder.getAbsolutePath()));
}
}
targetDef.setTargetLocations(bundleContainers.toArray(new ITargetLocation[bundleContainers.size()]));
targetDef.setArch(Platform.getOSArch());
targetDef.setOS(Platform.getOS());
targetDef.setWS(Platform.getWS());
targetDef.setNL(Platform.getNL());
// targetDef.setJREContainer()
tpService.saveTargetDefinition(targetDef);
Job job = new LoadTargetDefinitionJob(targetDef);
job.schedule();
job.join();
}
use of org.eclipse.pde.core.target.LoadTargetDefinitionJob in project xtext-eclipse by eclipse.
the class TargetPlatformUtil method setTargetPlatform.
/**
* Sets the target platform for tests (to be used in tycho mainly)
* @param context any class of the test bundle to be able to determine the test bundle
* @since 2.14
*/
public static void setTargetPlatform(Class<?> context) throws Exception {
if (isPdeLaunch()) {
return;
}
Bundle currentBundle = FrameworkUtil.getBundle(context);
ITargetPlatformService tpService = TargetPlatformService.getDefault();
ITargetDefinition targetDef = tpService.newTarget();
targetDef.setName("Tycho platform");
Bundle[] bundles = FrameworkUtil.getBundle(Platform.class).getBundleContext().getBundles();
List<ITargetLocation> bundleContainers = new ArrayList<ITargetLocation>();
Set<File> dirs = new HashSet<File>();
for (Bundle bundle : bundles) {
if (bundle.equals(currentBundle)) {
// errors during our tests.
continue;
}
EquinoxBundle bundleImpl = (EquinoxBundle) bundle;
Generation generation = (Generation) bundleImpl.getModule().getCurrentRevision().getRevisionInfo();
File file = generation.getBundleFile().getBaseFile();
File folder = file.getParentFile();
if (!dirs.contains(folder)) {
dirs.add(folder);
bundleContainers.add(tpService.newDirectoryLocation(folder.getAbsolutePath()));
}
}
targetDef.setTargetLocations(bundleContainers.toArray(new ITargetLocation[bundleContainers.size()]));
targetDef.setArch(Platform.getOSArch());
targetDef.setOS(Platform.getOS());
targetDef.setWS(Platform.getWS());
targetDef.setNL(Platform.getNL());
// targetDef.setJREContainer()
tpService.saveTargetDefinition(targetDef);
Job job = new LoadTargetDefinitionJob(targetDef);
job.schedule();
job.join();
}
Aggregations