mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
restore JDK jars in groovyc's classpath, suppress loading "java." classes in the loader (IDEA-166169)
some JDK jars (e.g. tools.jar) are not in the default classpath and so compilation might fail if they're used
This commit is contained in:
@@ -51,11 +51,6 @@ public class ProjectPaths {
|
||||
return getClasspathFiles(chunk, JpsJavaClasspathKind.compile(chunk.containsTests()), excludeMainModuleOutput, ClasspathPart.BEFORE_PLUS_JDK, true);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Collection<File> getRuntimeBootClasspath(@NotNull ModuleChunk chunk) {
|
||||
return getClasspathFiles(chunk, JpsJavaClasspathKind.compile(chunk.containsTests()), false, ClasspathPart.BEFORE_JDK, false);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static Collection<File> getCompilationClasspath(ModuleChunk chunk, boolean excludeMainModuleOutput) {
|
||||
return getClasspathFiles(chunk, JpsJavaClasspathKind.compile(chunk.containsTests()), excludeMainModuleOutput, ClasspathPart.AFTER_JDK, true);
|
||||
|
||||
+10
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package org.jetbrains.jps.incremental.groovy;
|
||||
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.lang.ClassPath;
|
||||
import com.intellij.util.lang.UrlClassLoader;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -23,15 +24,23 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author peter
|
||||
*/
|
||||
class JointCompilationClassLoader extends UrlClassLoader {
|
||||
private static final boolean ourExplicitlyAvoidLoadingJava = SystemProperties.getBooleanProperty("groovy.classloader.skip.java.package", true);
|
||||
@NotNull private final Builder myBuilder;
|
||||
@NotNull private ClassPath myClassPath;
|
||||
|
||||
|
||||
public JointCompilationClassLoader(@NotNull Builder builder) {
|
||||
super(builder);
|
||||
myBuilder = builder;
|
||||
myClassPath = super.getClassPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class findClass(String name) throws ClassNotFoundException {
|
||||
if (ourExplicitlyAvoidLoadingJava && name.startsWith("java.")) return null;
|
||||
|
||||
return super.findClass(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Class _defineClass(String name, byte[] b) {
|
||||
try {
|
||||
|
||||
+2
-12
@@ -23,7 +23,6 @@ import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.util.SystemProperties;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -389,11 +388,8 @@ public abstract class JpsGroovycRunner<R extends BuildRootDescriptor, T extends
|
||||
// IMPORTANT! must be the first in classpath
|
||||
cp.addAll(GroovyBuilder.getGroovyRtRoots());
|
||||
|
||||
if (SystemProperties.getBooleanProperty("groovyc.include.jdk.into.compilation.classpath", false)) {
|
||||
addFilePaths(cp, ProjectPaths.getCompilationClasspathFiles(chunk, chunk.containsTests(), false, false));
|
||||
} else {
|
||||
addFilePaths(cp, ProjectPaths.getRuntimeBootClasspath(chunk));
|
||||
addFilePaths(cp, ProjectPaths.getCompilationModulePath(chunk, false));
|
||||
for (File file : ProjectPaths.getCompilationClasspathFiles(chunk, chunk.containsTests(), false, false)) {
|
||||
cp.add(FileUtil.toCanonicalPath(file.getPath()));
|
||||
}
|
||||
|
||||
for (GroovyBuilderExtension extension : JpsServiceManager.getInstance().getExtensions(GroovyBuilderExtension.class)) {
|
||||
@@ -403,12 +399,6 @@ public abstract class JpsGroovycRunner<R extends BuildRootDescriptor, T extends
|
||||
return cp;
|
||||
}
|
||||
|
||||
private static void addFilePaths(Set<String> cp, Collection<File> files) {
|
||||
for (File file : files) {
|
||||
cp.add(FileUtil.toCanonicalPath(file.getPath()));
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, String> buildClassToSourceMap(ModuleChunk chunk, CompileContext context, Set<String> toCompilePaths, Map<T, String> finalOutputs) throws IOException {
|
||||
final Map<String, String> class2Src = new HashMap<String, String>();
|
||||
JpsJavaCompilerConfiguration configuration = JpsJavaExtensionService.getInstance().getOrCreateCompilerConfiguration(
|
||||
|
||||
Reference in New Issue
Block a user