[CLI] Restore K2JVMCompilerArguments.classpath and javaModulePath
to support IDEs < 2023.2 Reverts: -9dcd40d7b7-fb66764c4dKTIJ-25227
This commit is contained in:
committed by
Space Team
parent
7fe3c5c423
commit
5d0bf2de24
+2
-2
@@ -17,7 +17,7 @@ fun copyK2JVMCompilerArguments(from: K2JVMCompilerArguments, to: K2JVMCompilerAr
|
|||||||
to.assertionsMode = from.assertionsMode
|
to.assertionsMode = from.assertionsMode
|
||||||
to.backendThreads = from.backendThreads
|
to.backendThreads = from.backendThreads
|
||||||
to.buildFile = from.buildFile
|
to.buildFile = from.buildFile
|
||||||
to.classpath = from.classpath?.copyOf()
|
to.classpath = from.classpath
|
||||||
to.compileJava = from.compileJava
|
to.compileJava = from.compileJava
|
||||||
to.declarationsOutputPath = from.declarationsOutputPath
|
to.declarationsOutputPath = from.declarationsOutputPath
|
||||||
to.defaultScriptExtension = from.defaultScriptExtension
|
to.defaultScriptExtension = from.defaultScriptExtension
|
||||||
@@ -33,7 +33,7 @@ fun copyK2JVMCompilerArguments(from: K2JVMCompilerArguments, to: K2JVMCompilerAr
|
|||||||
to.friendPaths = from.friendPaths?.copyOf()
|
to.friendPaths = from.friendPaths?.copyOf()
|
||||||
to.includeRuntime = from.includeRuntime
|
to.includeRuntime = from.includeRuntime
|
||||||
to.inheritMultifileParts = from.inheritMultifileParts
|
to.inheritMultifileParts = from.inheritMultifileParts
|
||||||
to.javaModulePath = from.javaModulePath?.copyOf()
|
to.javaModulePath = from.javaModulePath
|
||||||
to.javaPackagePrefix = from.javaPackagePrefix
|
to.javaPackagePrefix = from.javaPackagePrefix
|
||||||
to.javaParameters = from.javaParameters
|
to.javaParameters = from.javaParameters
|
||||||
to.javaSourceRoots = from.javaSourceRoots?.copyOf()
|
to.javaSourceRoots = from.javaSourceRoots?.copyOf()
|
||||||
|
|||||||
+4
-10
@@ -26,10 +26,9 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
|||||||
value = "-classpath",
|
value = "-classpath",
|
||||||
shortName = "-cp",
|
shortName = "-cp",
|
||||||
valueDescription = "<path>",
|
valueDescription = "<path>",
|
||||||
description = "List of directories and JAR/ZIP archives to search for user class files",
|
description = "List of directories and JAR/ZIP archives to search for user class files"
|
||||||
delimiter = Argument.Delimiters.pathSeparator
|
|
||||||
)
|
)
|
||||||
var classpath: Array<String>? = null
|
var classpath: String? = null
|
||||||
set(value) {
|
set(value) {
|
||||||
checkFrozen()
|
checkFrozen()
|
||||||
field = if (value.isNullOrEmpty()) null else value
|
field = if (value.isNullOrEmpty()) null else value
|
||||||
@@ -210,13 +209,8 @@ class K2JVMCompilerArguments : CommonCompilerArguments() {
|
|||||||
field = value
|
field = value
|
||||||
}
|
}
|
||||||
|
|
||||||
@Argument(
|
@Argument(value = "-Xmodule-path", valueDescription = "<path>", description = "Paths where to find Java 9+ modules")
|
||||||
value = "-Xmodule-path",
|
var javaModulePath: String? = null
|
||||||
valueDescription = "<path>",
|
|
||||||
description = "Paths where to find Java 9+ modules",
|
|
||||||
delimiter = Argument.Delimiters.pathSeparator
|
|
||||||
)
|
|
||||||
var javaModulePath: Array<String>? = null
|
|
||||||
set(value) {
|
set(value) {
|
||||||
checkFrozen()
|
checkFrozen()
|
||||||
field = if (value.isNullOrEmpty()) null else value
|
field = if (value.isNullOrEmpty()) null else value
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ fun writeOutputsIfNeeded(
|
|||||||
|
|
||||||
fun ModuleBuilder.configureFromArgs(args: K2JVMCompilerArguments) {
|
fun ModuleBuilder.configureFromArgs(args: K2JVMCompilerArguments) {
|
||||||
args.friendPaths?.forEach { addFriendDir(it) }
|
args.friendPaths?.forEach { addFriendDir(it) }
|
||||||
args.classpath?.forEach { addClasspathEntry(it) }
|
args.classpath?.split(File.pathSeparator)?.forEach { addClasspathEntry(it) }
|
||||||
args.javaSourceRoots?.forEach {
|
args.javaSourceRoots?.forEach {
|
||||||
addJavaSourceRoot(JavaRootPath(it, args.javaPackagePrefix))
|
addJavaSourceRoot(JavaRootPath(it, args.javaPackagePrefix))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -177,13 +177,13 @@ fun CompilerConfiguration.configureJdkHomeFromSystemProperty() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun CompilerConfiguration.configureJavaModulesContentRoots(arguments: K2JVMCompilerArguments) {
|
fun CompilerConfiguration.configureJavaModulesContentRoots(arguments: K2JVMCompilerArguments) {
|
||||||
for (modularRoot in arguments.javaModulePath.orEmpty()) {
|
for (modularRoot in arguments.javaModulePath?.split(File.pathSeparatorChar).orEmpty()) {
|
||||||
add(CLIConfigurationKeys.CONTENT_ROOTS, JvmModulePathRoot(File(modularRoot)))
|
add(CLIConfigurationKeys.CONTENT_ROOTS, JvmModulePathRoot(File(modularRoot)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun CompilerConfiguration.configureContentRootsFromClassPath(arguments: K2JVMCompilerArguments) {
|
fun CompilerConfiguration.configureContentRootsFromClassPath(arguments: K2JVMCompilerArguments) {
|
||||||
for (path in arguments.classpath.orEmpty()) {
|
for (path in arguments.classpath?.split(File.pathSeparatorChar).orEmpty()) {
|
||||||
add(CLIConfigurationKeys.CONTENT_ROOTS, JvmClasspathRoot(File(path)))
|
add(CLIConfigurationKeys.CONTENT_ROOTS, JvmClasspathRoot(File(path)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -77,7 +77,7 @@ abstract class AbstractFrontendModularizedTest : AbstractModularizedTest() {
|
|||||||
if (originalArguments != null) {
|
if (originalArguments != null) {
|
||||||
configuration.put(JVMConfigurationKeys.NO_JDK, originalArguments.noJdk)
|
configuration.put(JVMConfigurationKeys.NO_JDK, originalArguments.noJdk)
|
||||||
|
|
||||||
for (modularRoot in originalArguments.javaModulePath.orEmpty()) {
|
for (modularRoot in originalArguments.javaModulePath?.split(File.pathSeparatorChar).orEmpty()) {
|
||||||
configuration.add(CLIConfigurationKeys.CONTENT_ROOTS, JvmModulePathRoot(modularRoot.fixPath()))
|
configuration.add(CLIConfigurationKeys.CONTENT_ROOTS, JvmModulePathRoot(modularRoot.fixPath()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -342,7 +342,7 @@ fun CompilerConfiguration.configureBaseRoots(args: K2JVMCompilerArguments) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
args.classpath?.forEach { classpathRoot ->
|
args.classpath?.split(File.pathSeparator)?.forEach { classpathRoot ->
|
||||||
add(
|
add(
|
||||||
CLIConfigurationKeys.CONTENT_ROOTS,
|
CLIConfigurationKeys.CONTENT_ROOTS,
|
||||||
if (isJava9Module) JvmModulePathRoot(File(classpathRoot)) else JvmClasspathRoot(File(classpathRoot))
|
if (isJava9Module) JvmModulePathRoot(File(classpathRoot)) else JvmClasspathRoot(File(classpathRoot))
|
||||||
|
|||||||
+2
-2
@@ -550,7 +550,7 @@ var K2JVMCompilerArguments.destinationAsFile: File
|
|||||||
}
|
}
|
||||||
|
|
||||||
var K2JVMCompilerArguments.classpathAsList: List<File>
|
var K2JVMCompilerArguments.classpathAsList: List<File>
|
||||||
get() = classpath.orEmpty().map(::File)
|
get() = classpath.orEmpty().split(File.pathSeparator).map(::File)
|
||||||
set(value) {
|
set(value) {
|
||||||
classpath = value.map { it.path }.toTypedArray()
|
classpath = value.joinToString(separator = File.pathSeparator, transform = { it.path })
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -48,14 +48,14 @@ abstract class AbstractIncrementalJvmCompilerRunnerTest : AbstractIncrementalCom
|
|||||||
}
|
}
|
||||||
if (javaSources.isEmpty()) return TestCompilationResult(ExitCode.OK, emptyList(), emptyList())
|
if (javaSources.isEmpty()) return TestCompilationResult(ExitCode.OK, emptyList(), emptyList())
|
||||||
|
|
||||||
val javaClasspath = compileClasspath + kotlinClassesPath
|
val javaClasspath = compileClasspath + File.pathSeparator + kotlinClassesPath
|
||||||
val javaDestinationDir = File(workingDir, "java-classes").apply {
|
val javaDestinationDir = File(workingDir, "java-classes").apply {
|
||||||
if (exists()) {
|
if (exists()) {
|
||||||
deleteRecursively()
|
deleteRecursively()
|
||||||
}
|
}
|
||||||
mkdirs()
|
mkdirs()
|
||||||
}
|
}
|
||||||
val args = arrayOf("-cp", javaClasspath.joinToString(File.pathSeparator),
|
val args = arrayOf("-cp", javaClasspath,
|
||||||
"-d", javaDestinationDir.canonicalPath,
|
"-d", javaDestinationDir.canonicalPath,
|
||||||
*javaSources.map { it.canonicalPath }.toTypedArray()
|
*javaSources.map { it.canonicalPath }.toTypedArray()
|
||||||
)
|
)
|
||||||
@@ -73,12 +73,12 @@ abstract class AbstractIncrementalJvmCompilerRunnerTest : AbstractIncrementalCom
|
|||||||
K2JVMCompilerArguments().apply {
|
K2JVMCompilerArguments().apply {
|
||||||
moduleName = testDir.name
|
moduleName = testDir.name
|
||||||
destination = destinationDir.path
|
destination = destinationDir.path
|
||||||
classpath = compileClasspath.toTypedArray()
|
classpath = compileClasspath
|
||||||
}
|
}
|
||||||
|
|
||||||
private val compileClasspath =
|
private val compileClasspath =
|
||||||
listOf(
|
listOf(
|
||||||
kotlinStdlibJvm,
|
kotlinStdlibJvm,
|
||||||
KtTestUtil.getAnnotationsJar()
|
KtTestUtil.getAnnotationsJar()
|
||||||
).map { it.canonicalPath }
|
).joinToString(File.pathSeparator) { it.canonicalPath }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -181,7 +181,7 @@ class KotlinFacetSettings {
|
|||||||
if (compilerSettings != null) {
|
if (compilerSettings != null) {
|
||||||
parseCommandLineArguments(compilerSettings.additionalArgumentsAsList, this)
|
parseCommandLineArguments(compilerSettings.additionalArgumentsAsList, this)
|
||||||
}
|
}
|
||||||
if (this is K2JVMCompilerArguments) this.classpath = null
|
if (this is K2JVMCompilerArguments) this.classpath = ""
|
||||||
}
|
}
|
||||||
} else null
|
} else null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -230,7 +230,7 @@ fun CommonCompilerArguments.convertPathsToSystemIndependent() {
|
|||||||
when (this) {
|
when (this) {
|
||||||
is K2JVMCompilerArguments -> {
|
is K2JVMCompilerArguments -> {
|
||||||
destination = destination?.let(FileUtilRt::toSystemIndependentName)
|
destination = destination?.let(FileUtilRt::toSystemIndependentName)
|
||||||
classpath?.forEachIndexed { index, s -> classpath!![index] = FileUtilRt.toSystemIndependentName(s) }
|
classpath = classpath?.let(FileUtilRt::toSystemIndependentName)
|
||||||
jdkHome = jdkHome?.let(FileUtilRt::toSystemIndependentName)
|
jdkHome = jdkHome?.let(FileUtilRt::toSystemIndependentName)
|
||||||
kotlinHome = kotlinHome?.let(FileUtilRt::toSystemIndependentName)
|
kotlinHome = kotlinHome?.let(FileUtilRt::toSystemIndependentName)
|
||||||
friendPaths?.forEachIndexed { index, s -> friendPaths!![index] = FileUtilRt.toSystemIndependentName(s) }
|
friendPaths?.forEachIndexed { index, s -> friendPaths!![index] = FileUtilRt.toSystemIndependentName(s) }
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ class CompilerArgumentsSerializationTest {
|
|||||||
@Test
|
@Test
|
||||||
fun testLongClasspathArgumentJVM() {
|
fun testLongClasspathArgumentJVM() {
|
||||||
doSerializeDeserializeAndCompareTest<K2JVMCompilerArguments> {
|
doSerializeDeserializeAndCompareTest<K2JVMCompilerArguments> {
|
||||||
classpath = generateSequence { generateRandomString(50) }.take(10).toList().toTypedArray()
|
classpath = generateSequence { generateRandomString(50) }.take(10).toList().joinToString(File.pathSeparator)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -184,4 +184,4 @@ class CompilerArgumentsSerializationTest {
|
|||||||
.map(charPool::get)
|
.map(charPool::get)
|
||||||
.joinToString("")
|
.joinToString("")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import com.intellij.openapi.util.text.StringUtil
|
|||||||
import com.intellij.openapi.vfs.StandardFileSystems
|
import com.intellij.openapi.vfs.StandardFileSystems
|
||||||
import com.intellij.testFramework.LightVirtualFile
|
import com.intellij.testFramework.LightVirtualFile
|
||||||
import com.intellij.testFramework.UsefulTestCase
|
import com.intellij.testFramework.UsefulTestCase
|
||||||
import com.intellij.util.io.Decompressor
|
|
||||||
import com.intellij.util.io.URLUtil
|
import com.intellij.util.io.URLUtil
|
||||||
import com.intellij.util.io.ZipUtil
|
import com.intellij.util.io.ZipUtil
|
||||||
import org.jetbrains.jps.ModuleChunk
|
import org.jetbrains.jps.ModuleChunk
|
||||||
@@ -958,7 +957,7 @@ open class KotlinJpsBuildTest : KotlinJpsBuildTestBase() {
|
|||||||
Files.copy(libraryJar.toPath(), module1Lib.toPath(), StandardCopyOption.REPLACE_EXISTING)
|
Files.copy(libraryJar.toPath(), module1Lib.toPath(), StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
|
||||||
assert(module1Lib.exists())
|
assert(module1Lib.exists())
|
||||||
(facet.compilerArguments as K2JVMCompilerArguments).classpath = arrayOf(module1Lib.path)
|
(facet.compilerArguments as K2JVMCompilerArguments).classpath = module1Lib.path
|
||||||
|
|
||||||
it.container.setChild(
|
it.container.setChild(
|
||||||
JpsKotlinFacetModuleExtension.KIND,
|
JpsKotlinFacetModuleExtension.KIND,
|
||||||
|
|||||||
+5
-6
@@ -165,14 +165,13 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
|||||||
|
|
||||||
if (!classpathList.isEmpty()) {
|
if (!classpathList.isEmpty()) {
|
||||||
String classPathString = join(classpathList, File.pathSeparator);
|
String classPathString = join(classpathList, File.pathSeparator);
|
||||||
String[] classPath = classpathList.toArray(new String[0]);
|
|
||||||
if (isJava9Module(sourceRoots)) {
|
if (isJava9Module(sourceRoots)) {
|
||||||
getLog().debug("Module path: " + classPathString);
|
getLog().debug("Module path: " + classPathString);
|
||||||
arguments.setJavaModulePath(classPath);
|
arguments.setJavaModulePath(classPathString);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
getLog().debug("Classpath: " + classPathString);
|
getLog().debug("Classpath: " + classPathString);
|
||||||
arguments.setClasspath(classPath);
|
arguments.setClasspath(classPathString);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -256,19 +255,19 @@ public class K2JVMCompileMojo extends KotlinCompileMojoBase<K2JVMCompilerArgumen
|
|||||||
File classesDir = new File(destination);
|
File classesDir = new File(destination);
|
||||||
File kotlinClassesDir = new File(cachesDir, "classes");
|
File kotlinClassesDir = new File(cachesDir, "classes");
|
||||||
File snapshotsFile = new File(cachesDir, "snapshots.bin");
|
File snapshotsFile = new File(cachesDir, "snapshots.bin");
|
||||||
String[] classpath = arguments.getClasspath();
|
String classpath = arguments.getClasspath();
|
||||||
MavenICReporter icReporter = new MavenICReporter(getLog());
|
MavenICReporter icReporter = new MavenICReporter(getLog());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
arguments.setDestination(kotlinClassesDir.getAbsolutePath());
|
arguments.setDestination(kotlinClassesDir.getAbsolutePath());
|
||||||
if (classpath != null) {
|
if (classpath != null) {
|
||||||
List<String> filteredClasspath = new ArrayList<>();
|
List<String> filteredClasspath = new ArrayList<>();
|
||||||
for (String path : classpath) {
|
for (String path : classpath.split(File.pathSeparator)) {
|
||||||
if (!classesDir.equals(new File(path))) {
|
if (!classesDir.equals(new File(path))) {
|
||||||
filteredClasspath.add(path);
|
filteredClasspath.add(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
arguments.setClasspath(filteredClasspath.toArray(new String[0]));
|
arguments.setClasspath(StringUtil.join(filteredClasspath, File.pathSeparator));
|
||||||
}
|
}
|
||||||
|
|
||||||
IncrementalJvmCompilerRunnerKt.makeIncrementally(cachesDir, sourceRoots, arguments, messageCollector, icReporter);
|
IncrementalJvmCompilerRunnerKt.makeIncrementally(cachesDir, sourceRoots, arguments, messageCollector, icReporter);
|
||||||
|
|||||||
+1
-2
@@ -9,7 +9,6 @@ import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
|
|||||||
import org.jetbrains.kotlin.incremental.testingUtils.BuildLogFinder
|
import org.jetbrains.kotlin.incremental.testingUtils.BuildLogFinder
|
||||||
import org.junit.jupiter.api.fail
|
import org.junit.jupiter.api.fail
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.io.FilenameFilter
|
|
||||||
|
|
||||||
abstract class AbstractIncrementalFirJvmWithPluginCompilerRunnerTest : AbstractIncrementalFirJvmCompilerRunnerTest() {
|
abstract class AbstractIncrementalFirJvmWithPluginCompilerRunnerTest : AbstractIncrementalFirJvmCompilerRunnerTest() {
|
||||||
companion object {
|
companion object {
|
||||||
@@ -35,7 +34,7 @@ abstract class AbstractIncrementalFirJvmWithPluginCompilerRunnerTest : AbstractI
|
|||||||
val annotationsJar = findJar(ANNOTATIONS_JAR_DIR, ANNOTATIONS_JAR_NAME, ":plugins:fir-plugin-prototype:plugin-annotations:jar")
|
val annotationsJar = findJar(ANNOTATIONS_JAR_DIR, ANNOTATIONS_JAR_NAME, ":plugins:fir-plugin-prototype:plugin-annotations:jar")
|
||||||
val pluginJar = findJar(PLUGIN_JAR_DIR, PLUGIN_JAR_NAME, ":plugins:fir-plugin-prototype:jar")
|
val pluginJar = findJar(PLUGIN_JAR_DIR, PLUGIN_JAR_NAME, ":plugins:fir-plugin-prototype:jar")
|
||||||
|
|
||||||
classpath = classpath?.plus(annotationsJar)
|
classpath += "${File.pathSeparator}$annotationsJar"
|
||||||
pluginClasspaths = arrayOf(pluginJar)
|
pluginClasspaths = arrayOf(pluginJar)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ abstract class BaseJvmAbiTest : TestCase() {
|
|||||||
val compiler = K2JVMCompiler()
|
val compiler = K2JVMCompiler()
|
||||||
val args = compiler.createArguments().apply {
|
val args = compiler.createArguments().apply {
|
||||||
freeArgs = listOf(compilation.srcDir.canonicalPath)
|
freeArgs = listOf(compilation.srcDir.canonicalPath)
|
||||||
classpath = (abiDependencies + kotlinJvmStdlib).map { it.canonicalPath }.toTypedArray()
|
classpath = (abiDependencies + kotlinJvmStdlib).joinToString(File.pathSeparator) { it.canonicalPath }
|
||||||
pluginClasspaths = arrayOf(abiPluginJar.canonicalPath)
|
pluginClasspaths = arrayOf(abiPluginJar.canonicalPath)
|
||||||
pluginOptions = listOfNotNull(
|
pluginOptions = listOfNotNull(
|
||||||
abiOption(JvmAbiCommandLineProcessor.OUTPUT_PATH_OPTION.optionName, compilation.abiDir.canonicalPath),
|
abiOption(JvmAbiCommandLineProcessor.OUTPUT_PATH_OPTION.optionName, compilation.abiDir.canonicalPath),
|
||||||
|
|||||||
Reference in New Issue
Block a user