use of com.intellij.execution.configurations.SimpleJavaParameters in project intellij-community by JetBrains.
the class XsltCommandLineState method createJavaParameters.
protected SimpleJavaParameters createJavaParameters() throws ExecutionException {
final Sdk jdk = myXsltRunConfiguration.getEffectiveJDK();
if (jdk == null) {
throw CantRunException.noJdkConfigured();
}
final SimpleJavaParameters parameters = new SimpleJavaParameters();
parameters.setJdk(jdk);
if (myXsltRunConfiguration.getJdkChoice() == XsltRunConfiguration.JdkChoice.FROM_MODULE) {
final Module module = myXsltRunConfiguration.getEffectiveModule();
// OK to run as if just a JDK has been selected (a missing JDK would already have been complained about above)
if (module != null) {
OrderEnumerator.orderEntries(module).productionOnly().recursively().classes().collectPaths(parameters.getClassPath());
}
}
final ParametersList vmParameters = parameters.getVMParametersList();
vmParameters.addParametersString(myXsltRunConfiguration.myVmArguments);
if (isEmpty(myXsltRunConfiguration.getXsltFile())) {
throw new CantRunException("No XSLT file selected");
}
vmParameters.defineProperty("xslt.file", myXsltRunConfiguration.getXsltFile());
if (isEmpty(myXsltRunConfiguration.getXmlInputFile())) {
throw new CantRunException("No XML input file selected");
}
vmParameters.defineProperty("xslt.input", myXsltRunConfiguration.getXmlInputFile());
final XsltRunConfiguration.OutputType outputType = myXsltRunConfiguration.getOutputType();
if (outputType == XsltRunConfiguration.OutputType.CONSOLE) {
//noinspection deprecation
myPort = NetUtils.tryToFindAvailableSocketPort(myXsltRunConfiguration.myRunnerPort);
vmParameters.defineProperty("xslt.listen-port", String.valueOf(myPort));
}
if (myXsltRunConfiguration.isSaveToFile()) {
vmParameters.defineProperty("xslt.output", myXsltRunConfiguration.myOutputFile);
}
for (Pair<String, String> pair : myXsltRunConfiguration.getParameters()) {
final String name = pair.getFirst();
final String value = pair.getSecond();
if (isEmpty(name) || value == null)
continue;
vmParameters.defineProperty("xslt.param." + name, value);
}
vmParameters.defineProperty("xslt.smart-error-handling", String.valueOf(myXsltRunConfiguration.mySmartErrorHandling));
final PluginId pluginId = PluginManagerCore.getPluginByClassName(getClass().getName());
assert pluginId != null || System.getProperty("xslt.plugin.path") != null : "PluginId not found - development builds need to specify -Dxslt.plugin.path=../out/classes/production/xslt-rt";
final File pluginPath;
if (pluginId != null) {
final IdeaPluginDescriptor descriptor = PluginManager.getPlugin(pluginId);
assert descriptor != null;
pluginPath = descriptor.getPath();
} else {
// -Dxslt.plugin.path=C:\work\java\intellij/ultimate\out\classes\production\xslt-rt
pluginPath = new File(System.getProperty("xslt.plugin.path"));
}
LOG.debug("Plugin Path = " + pluginPath.getAbsolutePath());
final char c = File.separatorChar;
File rtClasspath = new File(pluginPath, "lib" + c + "rt" + c + "xslt-rt.jar");
// File rtClasspath = new File("C:/Demetra/plugins/xpath/lib/rt/xslt-rt.jar");
if (!rtClasspath.exists()) {
LOG.warn("Plugin's Runtime classes not found in " + rtClasspath.getAbsolutePath());
if (!(rtClasspath = new File(pluginPath, "classes")).exists()) {
if (ApplicationManagerEx.getApplicationEx().isInternal() && new File(pluginPath, "org").exists()) {
rtClasspath = pluginPath;
} else {
throw new CantRunException("Runtime classes not found");
}
}
parameters.getVMParametersList().prepend("-ea");
}
parameters.getClassPath().addTail(rtClasspath.getAbsolutePath());
parameters.setMainClass("org.intellij.plugins.xslt.run.rt.XSLTRunner");
if (isEmpty(myXsltRunConfiguration.myWorkingDirectory)) {
parameters.setWorkingDirectory(new File(myXsltRunConfiguration.getXsltFile()).getParentFile().getAbsolutePath());
} else {
parameters.setWorkingDirectory(expandPath(myXsltRunConfiguration.myWorkingDirectory, myXsltRunConfiguration.getEffectiveModule(), myXsltRunConfiguration.getProject()));
}
myExtensionData = new UserDataHolderBase();
final List<XsltRunnerExtension> extensions = XsltRunnerExtension.getExtensions(myXsltRunConfiguration, myIsDebugger);
for (XsltRunnerExtension extension : extensions) {
extension.patchParameters(parameters, myXsltRunConfiguration, myExtensionData);
}
parameters.setUseDynamicClasspath(JdkUtil.useDynamicClasspath(myXsltRunConfiguration.getProject()));
return parameters;
}
use of com.intellij.execution.configurations.SimpleJavaParameters in project intellij-community by JetBrains.
the class RemoteExternalSystemCommunicationManager method createRunProfileState.
private RunProfileState createRunProfileState(final String configuration) {
return new CommandLineState(null) {
private SimpleJavaParameters createJavaParameters() throws ExecutionException {
final SimpleJavaParameters params = new SimpleJavaParameters();
params.setJdk(new SimpleJavaSdkType().createJdk("tmp", SystemProperties.getJavaHome()));
File myWorkingDirectory = new File(configuration);
params.setWorkingDirectory(myWorkingDirectory.isDirectory() ? myWorkingDirectory.getPath() : PathManager.getBinPath());
final List<String> classPath = ContainerUtilRt.newArrayList();
// IDE jars.
classPath.addAll(PathManager.getUtilClassPath());
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(ProjectBundle.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(PlaceHolder.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(DebuggerView.class));
ExternalSystemApiUtil.addBundle(params.getClassPath(), "messages.ProjectBundle", ProjectBundle.class);
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(PsiBundle.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(Alarm.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(DependencyScope.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(ExtensionPointName.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(StorageUtilKt.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(ExternalSystemTaskNotificationListener.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(StdModuleTypes.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(JavaModuleType.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(ModuleType.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(EmptyModuleType.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(LanguageLevel.class));
// add Kotlin runtime
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(Unit.class));
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(KotlinReflectionInternalError.class));
// External system module jars
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(getClass()));
// external-system-rt.jar
ContainerUtil.addIfNotNull(classPath, PathUtil.getJarPathForClass(ExternalSystemException.class));
ExternalSystemApiUtil.addBundle(params.getClassPath(), "messages.CommonBundle", CommonBundle.class);
params.getClassPath().addAll(classPath);
params.setMainClass(MAIN_CLASS_NAME);
params.getVMParametersList().addParametersString("-Djava.awt.headless=true");
// It may take a while for external system api to resolve external dependencies. Default RMI timeout
// is 15 seconds (http://download.oracle.com/javase/6/docs/technotes/guides/rmi/sunrmiproperties.html#connectionTimeout),
// we don't want to get EOFException because of that.
params.getVMParametersList().addParametersString("-Dsun.rmi.transport.connectionTimeout=" + String.valueOf(TimeUnit.HOURS.toMillis(1)));
final String debugPort = System.getProperty(ExternalSystemConstants.EXTERNAL_SYSTEM_REMOTE_COMMUNICATION_MANAGER_DEBUG_PORT);
if (debugPort != null) {
params.getVMParametersList().addParametersString("-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=" + debugPort);
}
ProjectSystemId externalSystemId = myTargetExternalSystemId.get();
if (externalSystemId != null) {
ExternalSystemManager<?, ?, ?, ?, ?> manager = ExternalSystemApiUtil.getManager(externalSystemId);
if (manager != null) {
params.getClassPath().add(PathUtil.getJarPathForClass(manager.getProjectResolverClass()));
params.getProgramParametersList().add(manager.getProjectResolverClass().getName());
params.getProgramParametersList().add(manager.getTaskManagerClass().getName());
manager.enhanceRemoteProcessing(params);
}
}
return params;
}
@Override
@NotNull
public ExecutionResult execute(@NotNull Executor executor, @NotNull ProgramRunner runner) throws ExecutionException {
ProcessHandler processHandler = startProcess();
return new DefaultExecutionResult(processHandler);
}
@Override
@NotNull
protected OSProcessHandler startProcess() throws ExecutionException {
SimpleJavaParameters params = createJavaParameters();
GeneralCommandLine commandLine = params.toCommandLine();
OSProcessHandler processHandler = new OSProcessHandler(commandLine);
ProcessTerminatedListener.attach(processHandler);
return processHandler;
}
};
}
use of com.intellij.execution.configurations.SimpleJavaParameters in project intellij-plugins by JetBrains.
the class Flexmojos4GenerateConfigTask method runGeneratorServer.
private void runGeneratorServer(MavenProjectsManager mavenProjectsManager, Project project) throws IOException, ExecutionException, MavenProcessCanceledException {
final SimpleJavaParameters params = new SimpleJavaParameters();
params.setJdk(new SimpleJavaSdkType().createJdk("tmp", SystemProperties.getJavaHome()));
final MavenGeneralSettings mavenGeneralSettings = mavenProjectsManager.getGeneralSettings();
final ParametersList programParametersList = params.getProgramParametersList();
programParametersList.add(getSettingsFilePath(mavenGeneralSettings.getEffectiveGlobalSettingsIoFile()));
programParametersList.add(getSettingsFilePath(mavenGeneralSettings.getEffectiveUserSettingsIoFile()));
programParametersList.add(mavenGeneralSettings.getEffectiveLocalRepository().getAbsolutePath());
programParametersList.add(mavenGeneralSettings.isWorkOffline() ? "t" : "f");
//noinspection ConstantConditions
programParametersList.add(project.getBaseDir().getPath() + "/.idea/flexmojos");
configureMavenClassPath(mavenGeneralSettings, params.getClassPath());
final File userVmP = new File(SystemProperties.getUserHome(), "fcg-vmp");
if (userVmP.exists()) {
params.getVMParametersList().addParametersString(FileUtil.loadFile(userVmP));
}
params.setMainClass("com.intellij.flex.maven.GeneratorServer");
final GeneralCommandLine commandLine = params.toCommandLine();
commandLine.setRedirectErrorStream(true);
LOG.info("Generate Flex Configs Task:" + commandLine.getCommandLineString());
indicator.checkCanceled();
process = commandLine.createProcess();
ApplicationManager.getApplication().executeOnPooledThread(new OutputReader(project));
//noinspection IOResourceOpenedButNotSafelyClosed
out = new DataOutputStream(new BufferedOutputStream(process.getOutputStream()));
writeExplicitProfiles(mavenProjectsManager.getExplicitProfiles().getEnabledProfiles());
writeWorkspaceMap(myTree.getProjects());
out.writeUTF(FlexCommonUtils.getPathToBundledJar("flexmojos-idea-configurator.jar"));
out.writeUTF(getIdeaConfiguratorClassName());
}
Aggregations