}
if (jdkForRun == null) {
throw CantRunException.noJdkConfigured();
}
JavaParameters params = new JavaParameters();
// working directory and JVM
if (myRunConfiguration.isGenerateWorkingDir()) {
myWorkingDir = new File(PathManager.getSystemPath(), "osmorc/run." + System.currentTimeMillis());
}
else {
myWorkingDir = new File(myRunConfiguration.getWorkingDir());
}
if (!myWorkingDir.isDirectory() && !myWorkingDir.mkdirs()) {
throw new CantRunException("Cannot create work directory '" + myWorkingDir.getPath() + "'");
}
params.setWorkingDirectory(myWorkingDir);
// only add JDK classes to the classpath, the rest is to be provided by bundles
params.configureByProject(myRunConfiguration.getProject(), JavaParameters.JDK_ONLY, jdkForRun);
// class path
Collection<SelectedBundle> systemBundles = myInstanceManager.getFrameworkBundles(myInstance, FrameworkBundleType.SYSTEM);
if (systemBundles.isEmpty()) {
throw new CantRunException("Libraries required to start the framework not found - please check the installation");
}
for (SelectedBundle bundle : systemBundles) {
String path = bundle.getBundlePath();
assert path != null : bundle;
params.getClassPath().add(path);
}
if (GenericRunProperties.isStartConsole(myAdditionalProperties)) {
Collection<SelectedBundle> shellBundles = myInstanceManager.getFrameworkBundles(myInstance, FrameworkBundleType.SHELL);
if (shellBundles.isEmpty()) {
throw new CantRunException("Console requested but no shell bundles can be found - please check the installation");
}
List<SelectedBundle> allBundles = ContainerUtil.newArrayList(shellBundles);
allBundles.addAll(myBundles);
myBundles = allBundles;
}
if (myRunConfiguration.isIncludeAllBundlesInClassPath()) {
for (SelectedBundle bundle : myBundles) {
String path = bundle.getBundlePath();
if (path != null) {
params.getClassPath().add(path);
}
}
}
// runner options
params.setUseDynamicVMOptions(!myBundles.isEmpty());
params.getVMParametersList().addAll(HttpConfigurable.convertArguments(HttpConfigurable.getJvmPropertiesList(false, null)));
params.getVMParametersList().addParametersString(myRunConfiguration.getVmParameters());
String additionalProgramParams = myRunConfiguration.getProgramParameters();
if (!StringUtil.isEmptyOrSpaces(additionalProgramParams)) {
params.getProgramParametersList().addParametersString(additionalProgramParams);
}
String bootDelegation = GenericRunProperties.getBootDelegation(myAdditionalProperties);
if (!StringUtil.isEmptyOrSpaces(bootDelegation)) {
params.getVMParametersList().addProperty("org.osgi.framework.bootdelegation", bootDelegation);
}
String systemPackages = GenericRunProperties.getSystemPackages(myAdditionalProperties);
if (!StringUtil.isEmptyOrSpaces(systemPackages)) {
params.getVMParametersList().addProperty("org.osgi.framework.system.packages.extra", systemPackages);
}
// framework-specific options
setupParameters(params);