mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Revert: Use JavaSdkType to query sdk for java.exe and tools.jar paths
This commit is contained in:
@@ -37,7 +37,6 @@ import com.intellij.openapi.projectRoots.SdkTypeId;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.profile.codeInspection.InspectionProjectProfileManager;
|
||||
@@ -347,15 +346,13 @@ public class CompilerManagerImpl extends CompilerManager {
|
||||
|
||||
final Pair<Sdk, JavaSdkVersion> runtime = BuildManager.getJavacRuntimeSdk(myProject);
|
||||
|
||||
String javaPath = null;
|
||||
String toolsPath = null;
|
||||
String javaHome = null;
|
||||
final Sdk sdk = runtime.getFirst();
|
||||
final SdkTypeId type = sdk.getSdkType();
|
||||
if (type instanceof JavaSdkType) {
|
||||
javaPath = StringUtil.nullize(((JavaSdkType)type).getVMExecutablePath(sdk), true);
|
||||
toolsPath = StringUtil.nullize(((JavaSdkType)type).getToolsPath(sdk), true);
|
||||
javaHome = sdk.getHomePath();
|
||||
}
|
||||
if (javaPath == null) {
|
||||
if (javaHome == null) {
|
||||
throw new IOException("Was not able to determine JDK for project " + myProject.getName());
|
||||
}
|
||||
|
||||
@@ -380,7 +377,7 @@ public class CompilerManagerImpl extends CompilerManager {
|
||||
|
||||
final ExternalJavacManager javacManager = getJavacManager();
|
||||
boolean compiledOk = javacManager != null && javacManager.forkJavac(
|
||||
javaPath, toolsPath, -1, Collections.emptyList(), options, platformCp, classpath, modulePath, sourcePath, files, outs, diagnostic, outputCollector,
|
||||
javaHome, -1, Collections.emptyList(), options, platformCp, classpath, modulePath, sourcePath, files, outs, diagnostic, outputCollector,
|
||||
new JavacCompilerTool(), CanceledStatus.NULL
|
||||
);
|
||||
|
||||
|
||||
@@ -172,7 +172,7 @@ public class ClasspathBootstrap {
|
||||
}
|
||||
}
|
||||
|
||||
public static List<File> getExternalJavacProcessClasspath(String javaPath, String toolsPath, JavaCompilingTool compilingTool) {
|
||||
public static List<File> getExternalJavacProcessClasspath(String sdkHome, JavaCompilingTool compilingTool) {
|
||||
final Set<File> cp = new LinkedHashSet<File>();
|
||||
cp.add(getResourceFile(ExternalJavacProcess.class)); // self
|
||||
// util
|
||||
@@ -208,8 +208,8 @@ public class ClasspathBootstrap {
|
||||
try {
|
||||
final String localJavaHome = FileUtil.toSystemIndependentName(SystemProperties.getJavaHome());
|
||||
// sdkHome is not the same as the sdk used to run this process
|
||||
File candidate = toolsPath == null ? null : new File(toolsPath);
|
||||
if (candidate != null && candidate.exists()) {
|
||||
final File candidate = new File(sdkHome, "lib/tools.jar");
|
||||
if (candidate.exists()) {
|
||||
cp.add(candidate);
|
||||
}
|
||||
else {
|
||||
@@ -223,8 +223,7 @@ public class ClasspathBootstrap {
|
||||
relPath = FileUtil.getRelativePath(FileUtil.toSystemIndependentName(new File(localJavaHome).getParent()), localJarPath, '/');
|
||||
}
|
||||
if (relPath != null) {
|
||||
File javaHome = new File(javaPath).getParentFile().getParentFile();
|
||||
File targetFile = new File(javaHome, relPath);
|
||||
final File targetFile = new File(sdkHome, relPath);
|
||||
cp.add(targetFile); // tools.jar
|
||||
}
|
||||
}
|
||||
|
||||
@@ -469,9 +469,8 @@ public class JavaBuilder extends ModuleLevelBuilder {
|
||||
final List<String> vmOptions = getCompilationVMOptions(context, compilingTool);
|
||||
final ExternalJavacManager server = ensureJavacServerStarted(context);
|
||||
rc = server.forkJavac(
|
||||
forkSdk.getFirst() + "/bin/java",
|
||||
forkSdk.getFirst() + "/lib/tools.jar",
|
||||
getExternalJavacHeapSize(context),
|
||||
forkSdk.getFirst(),
|
||||
getExternalJavacHeapSize(context),
|
||||
vmOptions, options, platformCp, classPath, modulePath, sourcePath,
|
||||
files, outs, diagnosticSink, classesConsumer, compilingTool, context.getCancelStatus()
|
||||
);
|
||||
|
||||
@@ -109,8 +109,7 @@ public class ExternalJavacManager {
|
||||
}
|
||||
|
||||
|
||||
public boolean forkJavac(String javaPath, String toolsPath,
|
||||
int heapSize, List<String> vmOptions, List<String> options,
|
||||
public boolean forkJavac(final String javaHome, final int heapSize, List<String> vmOptions, List<String> options,
|
||||
Collection<File> platformCp,
|
||||
Collection<File> classpath,
|
||||
Collection<File> modulePath,
|
||||
@@ -129,7 +128,7 @@ public class ExternalJavacManager {
|
||||
}
|
||||
try {
|
||||
final ExternalJavacProcessHandler processHandler = launchExternalJavacProcess(
|
||||
uuid, javaPath, toolsPath, heapSize, myListenPort, myWorkingDir, vmOptions, compilingTool
|
||||
uuid, javaHome, heapSize, myListenPort, myWorkingDir, vmOptions, compilingTool
|
||||
);
|
||||
processHandler.addProcessListener(new ProcessAdapter() {
|
||||
public void onTextAvailable(ProcessEvent event, Key outputType) {
|
||||
@@ -201,15 +200,14 @@ public class ExternalJavacManager {
|
||||
myChannelRegistrar.close().awaitUninterruptibly();
|
||||
}
|
||||
|
||||
private ExternalJavacProcessHandler launchExternalJavacProcess(UUID uuid,
|
||||
String javaPath, String toolsPath,
|
||||
int heapSize,
|
||||
int port,
|
||||
File workingDir,
|
||||
List<String> vmOptions,
|
||||
JavaCompilingTool compilingTool) throws Exception {
|
||||
private ExternalJavacProcessHandler launchExternalJavacProcess(UUID uuid, String sdkHomePath,
|
||||
int heapSize,
|
||||
int port,
|
||||
File workingDir,
|
||||
List<String> vmOptions,
|
||||
JavaCompilingTool compilingTool) throws Exception {
|
||||
final List<String> cmdLine = new ArrayList<String>();
|
||||
appendParam(cmdLine, javaPath);
|
||||
appendParam(cmdLine, getVMExecutablePath(sdkHomePath));
|
||||
//appendParam(cmdLine, "-XX:MaxPermSize=150m");
|
||||
//appendParam(cmdLine, "-XX:ReservedCodeCacheSize=64m");
|
||||
appendParam(cmdLine, "-Djava.awt.headless=true");
|
||||
@@ -261,7 +259,7 @@ public class ExternalJavacManager {
|
||||
|
||||
appendParam(cmdLine, "-classpath");
|
||||
|
||||
final List<File> cp = ClasspathBootstrap.getExternalJavacProcessClasspath(javaPath, toolsPath, compilingTool);
|
||||
final List<File> cp = ClasspathBootstrap.getExternalJavacProcessClasspath(sdkHomePath, compilingTool);
|
||||
final StringBuilder classpath = new StringBuilder();
|
||||
for (File file : cp) {
|
||||
if (classpath.length() > 0) {
|
||||
@@ -303,6 +301,10 @@ public class ExternalJavacManager {
|
||||
cmdLine.add(param);
|
||||
}
|
||||
|
||||
private static String getVMExecutablePath(String sdkHome) {
|
||||
return sdkHome + "/bin/java";
|
||||
}
|
||||
|
||||
protected static class ExternalJavacProcessHandler extends BaseOSProcessHandler {
|
||||
private volatile int myExitCode;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user