mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Copy Groovy runtime to WSL (IDEA-264994)
GitOrigin-RevId: 5bbec4eb91daddce72726b559398b74977b1bc57
This commit is contained in:
committed by
intellij-monorepo-bot
parent
ae2c5179dd
commit
e258d8e96c
@@ -6,6 +6,7 @@ import com.intellij.execution.ExecutionException;
|
||||
import com.intellij.execution.configurations.GeneralCommandLine;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Path;
|
||||
@@ -40,4 +41,7 @@ interface BuildCommandLineBuilder {
|
||||
|
||||
default void setupAdditionalVMOptions() {
|
||||
}
|
||||
|
||||
default void copyPathToTarget(File file) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1400,7 +1400,7 @@ public final class BuildManager implements Disposable {
|
||||
|
||||
final File projectSystemRoot = getProjectSystemDirectory(project);
|
||||
if (projectSystemRoot != null) {
|
||||
cmdLine.addParameter("-Djava.io.tmpdir=" + FileUtil.toSystemIndependentName(projectSystemRoot.getPath()) + "/" + TEMP_DIR_NAME);
|
||||
cmdLine.addPathParameter("-Djava.io.tmpdir=", FileUtil.toSystemIndependentName(projectSystemRoot.getPath()) + "/" + TEMP_DIR_NAME);
|
||||
}
|
||||
|
||||
for (BuildProcessParametersProvider provider : BuildProcessParametersProvider.EP_NAME.getExtensions(project)) {
|
||||
@@ -1449,6 +1449,13 @@ public final class BuildManager implements Disposable {
|
||||
final List<String> cp = myClasspathManager.getBuildProcessClasspath(project);
|
||||
cmdLine.addClasspathParameter(cp, isProfilingMode ? Collections.singletonList("yjp-controller-api-redist.jar") : Collections.emptyList());
|
||||
|
||||
for (BuildProcessParametersProvider buildProcessParametersProvider : BuildProcessParametersProvider.EP_NAME.getExtensions(project)) {
|
||||
List<String> pluginPaths = buildProcessParametersProvider.getAdditionalPluginPaths();
|
||||
for (String path : pluginPaths) {
|
||||
cmdLine.copyPathToTarget(new File(path));
|
||||
}
|
||||
}
|
||||
|
||||
cmdLine.addParameter(BuildMain.class.getName());
|
||||
cmdLine.addParameter(cmdLine.getHostIp());
|
||||
cmdLine.addParameter(Integer.toString(listenPort));
|
||||
|
||||
+8
@@ -32,6 +32,14 @@ public abstract class BuildProcessParametersProvider {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Override this method to specify list of files that are required for the build to work but shouldn't be added to the
|
||||
* build process classpath.
|
||||
*/
|
||||
public @NotNull List<String> getAdditionalPluginPaths() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public @NotNull List<String> getVMArguments() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jps.api.GlobalOptions;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.charset.Charset;
|
||||
@@ -124,6 +125,21 @@ final class WslBuildCommandLineBuilder implements BuildCommandLineBuilder {
|
||||
myCommandLine.addParameter(builder.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyPathToTarget(File file) {
|
||||
if (myClasspathDirectory != null && myHostClasspathDirectory != null) {
|
||||
Path targetPath = myHostClasspathDirectory.resolve(file.getName());
|
||||
if (!targetPath.toFile().exists()) {
|
||||
try {
|
||||
FileUtil.copyFileOrDir(file, targetPath.toFile());
|
||||
}
|
||||
catch (IOException e) {
|
||||
// ignore
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull Path getHostWorkingDirectory() {
|
||||
return Paths.get(myHostWorkingDirectory);
|
||||
|
||||
+2
-37
@@ -4,10 +4,10 @@ package org.jetbrains.jps.incremental.groovy;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import org.jetbrains.annotations.Nls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.groovy.compiler.rt.GroovyRtJarPaths;
|
||||
import org.jetbrains.jps.ModuleChunk;
|
||||
import org.jetbrains.jps.builders.DirtyFilesHolder;
|
||||
import org.jetbrains.jps.builders.java.JavaBuilderUtil;
|
||||
@@ -125,42 +125,7 @@ public class GroovyBuilder extends ModuleLevelBuilder {
|
||||
}
|
||||
|
||||
static List<String> getGroovyRtRoots() {
|
||||
return getGroovyRtRoots(ClasspathBootstrap.getResourceFile(GroovyBuilder.class));
|
||||
}
|
||||
|
||||
static List<String> getGroovyRtRoots(File jpsPluginRoot) {
|
||||
List<String> result = new ArrayList<>();
|
||||
addGroovyRtJarPath(jpsPluginRoot, "groovy-rt.jar",
|
||||
Collections.singletonList("intellij.groovy.rt"), "groovy-rt", result);
|
||||
addGroovyRtJarPath(jpsPluginRoot, "groovy-constants-rt.jar",
|
||||
Collections.singletonList("intellij.groovy.constants.rt"), "groovy-constants-rt", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void addGroovyRtJarPath(File jpsPluginClassesRoot, String jarNameInDistribution,
|
||||
List<String> moduleNames,
|
||||
String mavenArtifactNamePrefix,
|
||||
@NotNull List<String> to) {
|
||||
File parentDir = jpsPluginClassesRoot.getParentFile();
|
||||
if (jpsPluginClassesRoot.isFile()) {
|
||||
String fileName;
|
||||
if (jpsPluginClassesRoot.getName().equals("groovy-jps.jar")) {
|
||||
fileName = jarNameInDistribution;
|
||||
}
|
||||
else {
|
||||
String version = StringUtil.substringAfterLast(FileUtil.getNameWithoutExtension(jpsPluginClassesRoot), "-");
|
||||
fileName = mavenArtifactNamePrefix + "-" + version + ".jar";
|
||||
if (parentDir.getName().equals(version)) {
|
||||
parentDir = new File(parentDir.getParentFile().getParentFile(), mavenArtifactNamePrefix + "/" + version);
|
||||
}
|
||||
}
|
||||
to.add(new File(parentDir, fileName).getPath());
|
||||
}
|
||||
else {
|
||||
for (String moduleName : moduleNames) {
|
||||
to.add(new File(parentDir, moduleName).getPath());
|
||||
}
|
||||
}
|
||||
return GroovyRtJarPaths.getGroovyRtRoots(ClasspathBootstrap.getResourceFile(GroovyBuilder.class));
|
||||
}
|
||||
|
||||
public static boolean isGroovyFile(String path) {
|
||||
|
||||
+6
-4
@@ -3,6 +3,7 @@ package org.jetbrains.jps.incremental.groovy
|
||||
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.io.directoryContent
|
||||
import org.jetbrains.groovy.compiler.rt.GroovyRtJarPaths
|
||||
import org.junit.Assert
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
@@ -15,7 +16,7 @@ class GroovyRtPathsTest {
|
||||
dir("intellij.groovy.jps") {}
|
||||
dir("intellij.groovy.rt") {}
|
||||
}.generateInTempDir().toFile()
|
||||
val roots = GroovyBuilder.getGroovyRtRoots(File(out, "intellij.groovy.jps"))
|
||||
val roots = GroovyRtJarPaths.getGroovyRtRoots(File(out, "intellij.groovy.jps"))
|
||||
assertSameFiles(roots, File(out, "intellij.groovy.rt"), File(out, "intellij.groovy.constants.rt"))
|
||||
}
|
||||
|
||||
@@ -26,7 +27,7 @@ class GroovyRtPathsTest {
|
||||
file("groovy-constants-rt.jar")
|
||||
file("groovy-rt.jar")
|
||||
}.generateInTempDir().toFile()
|
||||
val roots = GroovyBuilder.getGroovyRtRoots(File(lib, "groovy-jps.jar"))
|
||||
val roots = GroovyRtJarPaths.getGroovyRtRoots(File(lib, "groovy-jps.jar"))
|
||||
assertSameFiles(roots, File(lib, "groovy-rt.jar"), File(lib, "groovy-constants-rt.jar"))
|
||||
}
|
||||
|
||||
@@ -37,7 +38,7 @@ class GroovyRtPathsTest {
|
||||
file("groovy-rt-193.239.jar")
|
||||
file("groovy-jps-193.239.jar")
|
||||
}.generateInTempDir().toFile()
|
||||
val roots = GroovyBuilder.getGroovyRtRoots(File(lib, "groovy-jps-193.239.jar"))
|
||||
val roots = GroovyRtJarPaths.getGroovyRtRoots(File(lib, "groovy-jps-193.239.jar"))
|
||||
assertSameFiles(roots, File(lib, "groovy-rt-193.239.jar"), File(lib, "groovy-constants-rt-193.239.jar"))
|
||||
}
|
||||
|
||||
@@ -62,7 +63,8 @@ class GroovyRtPathsTest {
|
||||
}
|
||||
}
|
||||
}.generateInTempDir().toFile()
|
||||
val roots = GroovyBuilder.getGroovyRtRoots(File(repo, "com/jetbrains/intellij/groovy/groovy-jps/193.239/groovy-jps-193.239.jar"))
|
||||
val roots = GroovyRtJarPaths.getGroovyRtRoots(
|
||||
File(repo, "com/jetbrains/intellij/groovy/groovy-jps/193.239/groovy-jps-193.239.jar"))
|
||||
assertSameFiles(roots, File(repo, "com/jetbrains/intellij/groovy/groovy-rt/193.239/groovy-rt-193.239.jar"),
|
||||
File(repo, "com/jetbrains/intellij/groovy/groovy-constants-rt/193.239/groovy-constants-rt-193.239.jar"))
|
||||
}
|
||||
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
// Copyright 2000-2021 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package org.jetbrains.groovy.compiler.rt;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
public class GroovyRtJarPaths {
|
||||
public static List<String> getGroovyRtRoots(File jpsPluginRoot) {
|
||||
List<String> result = new ArrayList<String>();
|
||||
addGroovyRtJarPath(jpsPluginRoot, "groovy-rt.jar",
|
||||
Collections.singletonList("intellij.groovy.rt"), "groovy-rt", result);
|
||||
addGroovyRtJarPath(jpsPluginRoot, "groovy-constants-rt.jar",
|
||||
Collections.singletonList("intellij.groovy.constants.rt"), "groovy-constants-rt", result);
|
||||
return result;
|
||||
}
|
||||
|
||||
private static void addGroovyRtJarPath(File jpsPluginClassesRoot,
|
||||
String jarNameInDistribution,
|
||||
List<String> moduleNames,
|
||||
String mavenArtifactNamePrefix,
|
||||
List<String> to) {
|
||||
File parentDir = jpsPluginClassesRoot.getParentFile();
|
||||
if (jpsPluginClassesRoot.isFile()) {
|
||||
String fileName;
|
||||
if (jpsPluginClassesRoot.getName().equals("groovy-jps.jar")) {
|
||||
fileName = jarNameInDistribution;
|
||||
}
|
||||
else {
|
||||
String name = jpsPluginClassesRoot.getName();
|
||||
int dotIndex = name.lastIndexOf('.');
|
||||
name = dotIndex < 0 ? name : name.substring(0, dotIndex);
|
||||
int dashIndex = name.lastIndexOf('-');
|
||||
String version = dashIndex < 0 ? null : name.substring(dashIndex + 1);
|
||||
fileName = mavenArtifactNamePrefix + "-" + version + ".jar";
|
||||
if (parentDir.getName().equals(version)) {
|
||||
parentDir = new File(parentDir.getParentFile().getParentFile(), mavenArtifactNamePrefix + "/" + version);
|
||||
}
|
||||
}
|
||||
to.add(new File(parentDir, fileName).getPath());
|
||||
}
|
||||
else {
|
||||
for (String moduleName : moduleNames) {
|
||||
to.add(new File(parentDir, moduleName).getPath());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,7 +10,7 @@
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
<orderEntry type="library" exported="" name="org.codehaus.groovy:groovy" level="project" />
|
||||
<orderEntry type="library" name="jetbrains-annotations-java5" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.groovy.constants.rt" />
|
||||
<orderEntry type="module" module-name="intellij.groovy.constants.rt" exported="" />
|
||||
<orderEntry type="library" scope="PROVIDED" name="Slf4j" level="project" />
|
||||
<orderEntry type="module" module-name="intellij.platform.util.rt" />
|
||||
</component>
|
||||
|
||||
+13
@@ -5,12 +5,16 @@ import com.intellij.compiler.CompilerConfiguration;
|
||||
import com.intellij.compiler.CompilerConfigurationImpl;
|
||||
import com.intellij.compiler.impl.javaCompiler.BackendCompiler;
|
||||
import com.intellij.compiler.server.BuildProcessParametersProvider;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.groovy.compiler.rt.GroovyRtJarPaths;
|
||||
import org.jetbrains.jps.builders.impl.java.EclipseCompilerTool;
|
||||
import org.jetbrains.jps.incremental.groovy.GreclipseBuilder;
|
||||
import org.jetbrains.jps.incremental.groovy.GroovyBuilder;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@@ -37,4 +41,13 @@ final class GrBuildProcessParametersProvider extends BuildProcessParametersProvi
|
||||
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NotNull List<String> getAdditionalPluginPaths() {
|
||||
Path jarPath = PathManager.getJarForClass(GroovyBuilder.class);
|
||||
if (jarPath == null) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return GroovyRtJarPaths.getGroovyRtRoots(jarPath.toFile());
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user