use of com.intellij.openapi.projectRoots.SimpleJavaSdkType 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.openapi.projectRoots.SimpleJavaSdkType 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());
}
use of com.intellij.openapi.projectRoots.SimpleJavaSdkType in project intellij-community by JetBrains.
the class GroovyScriptRunConfiguration method createJavaParametersWithSdk.
public static JavaParameters createJavaParametersWithSdk(@Nullable Module module) {
JavaParameters params = new JavaParameters();
params.setCharset(null);
if (module != null) {
final Sdk sdk = ModuleRootManager.getInstance(module).getSdk();
if (sdk != null && sdk.getSdkType() instanceof JavaSdkType) {
params.setJdk(sdk);
}
}
if (params.getJdk() == null) {
params.setJdk(new SimpleJavaSdkType().createJdk("tmp", SystemProperties.getJavaHome()));
}
return params;
}
Aggregations