Convert KotlinPaths to kotlin
This commit is contained in:
@@ -96,13 +96,13 @@ fun CompilerConfiguration.configureStandardLibs(paths: KotlinPaths?, arguments:
|
||||
}
|
||||
|
||||
if (!arguments.noStdlib) {
|
||||
addRoot("kotlin.stdlib", PathUtil.KOTLIN_JAVA_STDLIB_JAR, KotlinPaths::getStdlibPath, "'-no-stdlib'")
|
||||
addRoot("kotlin.script.runtime", PathUtil.KOTLIN_JAVA_SCRIPT_RUNTIME_JAR, KotlinPaths::getScriptRuntimePath, "'-no-stdlib'")
|
||||
addRoot("kotlin.stdlib", PathUtil.KOTLIN_JAVA_STDLIB_JAR, KotlinPaths::stdlibPath, "'-no-stdlib'")
|
||||
addRoot("kotlin.script.runtime", PathUtil.KOTLIN_JAVA_SCRIPT_RUNTIME_JAR, KotlinPaths::scriptRuntimePath, "'-no-stdlib'")
|
||||
}
|
||||
// "-no-stdlib" implies "-no-reflect": otherwise we would be able to transitively read stdlib classes through kotlin-reflect,
|
||||
// which is likely not what user wants since s/he manually provided "-no-stdlib"
|
||||
if (!arguments.noReflect && !arguments.noStdlib) {
|
||||
addRoot("kotlin.reflect", PathUtil.KOTLIN_JAVA_REFLECT_JAR, KotlinPaths::getReflectPath, "'-no-reflect' or '-no-stdlib'")
|
||||
addRoot("kotlin.reflect", PathUtil.KOTLIN_JAVA_REFLECT_JAR, { it.reflectPath }, "'-no-reflect' or '-no-stdlib'")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,60 +14,41 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.utils;
|
||||
package org.jetbrains.kotlin.utils
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.io.File
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
interface KotlinPaths {
|
||||
val homePath: File
|
||||
|
||||
public interface KotlinPaths {
|
||||
@NotNull
|
||||
File getHomePath();
|
||||
val libPath: File
|
||||
|
||||
@NotNull
|
||||
File getLibPath();
|
||||
val stdlibPath: File
|
||||
|
||||
@NotNull
|
||||
File getStdlibPath();
|
||||
val reflectPath: File
|
||||
|
||||
@NotNull
|
||||
File getReflectPath();
|
||||
val scriptRuntimePath: File
|
||||
|
||||
@NotNull
|
||||
File getScriptRuntimePath();
|
||||
val kotlinTestPath: File
|
||||
|
||||
@NotNull
|
||||
File getKotlinTestPath();
|
||||
val stdlibSourcesPath: File
|
||||
|
||||
@NotNull
|
||||
File getStdlibSourcesPath();
|
||||
val jsStdLibJarPath: File
|
||||
|
||||
@NotNull
|
||||
File getJsStdLibJarPath();
|
||||
val jsStdLibSrcJarPath: File
|
||||
|
||||
@NotNull
|
||||
File getJsStdLibSrcJarPath();
|
||||
val jsKotlinTestJarPath: File
|
||||
|
||||
@NotNull
|
||||
File getJsKotlinTestJarPath();
|
||||
val allOpenPluginJarPath: File
|
||||
|
||||
@NotNull
|
||||
File getAllOpenPluginJarPath();
|
||||
val noArgPluginJarPath: File
|
||||
|
||||
@NotNull
|
||||
File getNoArgPluginJarPath();
|
||||
val samWithReceiverJarPath: File
|
||||
|
||||
@NotNull
|
||||
File getSamWithReceiverJarPath();
|
||||
val trove4jJarPath: File
|
||||
|
||||
@NotNull
|
||||
File getTrove4jJarPath();
|
||||
val compilerClasspath: List<File>
|
||||
|
||||
@NotNull
|
||||
List<File> getCompilerClasspath();
|
||||
|
||||
@NotNull
|
||||
File getCompilerPath();
|
||||
val compilerPath: File
|
||||
|
||||
}
|
||||
|
||||
@@ -14,120 +14,62 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.utils;
|
||||
package org.jetbrains.kotlin.utils
|
||||
|
||||
import kotlin.collections.CollectionsKt;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import kotlin.collections.*
|
||||
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import java.io.File
|
||||
|
||||
public class KotlinPathsFromHomeDir implements KotlinPaths {
|
||||
// kotlinc directory
|
||||
private final File homePath;
|
||||
class KotlinPathsFromHomeDir(
|
||||
override val homePath: File // kotlinc directory
|
||||
) : KotlinPaths {
|
||||
|
||||
public KotlinPathsFromHomeDir(@NotNull File homePath) {
|
||||
this.homePath = homePath;
|
||||
}
|
||||
override val libPath: File
|
||||
get() = File(homePath, "lib")
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File getHomePath() {
|
||||
return homePath;
|
||||
}
|
||||
override val stdlibPath: File
|
||||
get() = getLibraryFile(PathUtil.KOTLIN_JAVA_STDLIB_JAR)
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File getLibPath() {
|
||||
return new File(homePath, "lib");
|
||||
}
|
||||
override val reflectPath: File
|
||||
get() = getLibraryFile(PathUtil.KOTLIN_JAVA_REFLECT_JAR)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getStdlibPath() {
|
||||
return getLibraryFile(PathUtil.KOTLIN_JAVA_STDLIB_JAR);
|
||||
}
|
||||
override val scriptRuntimePath: File
|
||||
get() = getLibraryFile(PathUtil.KOTLIN_JAVA_SCRIPT_RUNTIME_JAR)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getReflectPath() {
|
||||
return getLibraryFile(PathUtil.KOTLIN_JAVA_REFLECT_JAR);
|
||||
}
|
||||
override val kotlinTestPath: File
|
||||
get() = getLibraryFile(PathUtil.KOTLIN_TEST_JAR)
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File getScriptRuntimePath() {
|
||||
return getLibraryFile(PathUtil.KOTLIN_JAVA_SCRIPT_RUNTIME_JAR);
|
||||
}
|
||||
override val stdlibSourcesPath: File
|
||||
get() = getLibraryFile(PathUtil.KOTLIN_JAVA_STDLIB_SRC_JAR)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getKotlinTestPath() {
|
||||
return getLibraryFile(PathUtil.KOTLIN_TEST_JAR);
|
||||
}
|
||||
override val jsStdLibJarPath: File
|
||||
get() = getLibraryFile(PathUtil.JS_LIB_JAR_NAME)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getStdlibSourcesPath() {
|
||||
return getLibraryFile(PathUtil.KOTLIN_JAVA_STDLIB_SRC_JAR);
|
||||
}
|
||||
override val jsStdLibSrcJarPath: File
|
||||
get() = getLibraryFile(PathUtil.JS_LIB_SRC_JAR_NAME)
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File getJsStdLibJarPath() {
|
||||
return getLibraryFile(PathUtil.JS_LIB_JAR_NAME);
|
||||
}
|
||||
override val jsKotlinTestJarPath: File
|
||||
get() = getLibraryFile(PathUtil.KOTLIN_TEST_JS_JAR)
|
||||
|
||||
@Override
|
||||
@NotNull
|
||||
public File getJsStdLibSrcJarPath() {
|
||||
return getLibraryFile(PathUtil.JS_LIB_SRC_JAR_NAME);
|
||||
}
|
||||
override val allOpenPluginJarPath: File
|
||||
get() = getLibraryFile(PathUtil.ALLOPEN_PLUGIN_JAR_NAME)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getJsKotlinTestJarPath() {
|
||||
return getLibraryFile(PathUtil.KOTLIN_TEST_JS_JAR);
|
||||
}
|
||||
override val noArgPluginJarPath: File
|
||||
get() = getLibraryFile(PathUtil.NOARG_PLUGIN_JAR_NAME)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getAllOpenPluginJarPath() {
|
||||
return getLibraryFile(PathUtil.ALLOPEN_PLUGIN_JAR_NAME);
|
||||
}
|
||||
override val samWithReceiverJarPath: File
|
||||
get() = getLibraryFile(PathUtil.SAM_WITH_RECEIVER_PLUGIN_JAR_NAME)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getNoArgPluginJarPath() {
|
||||
return getLibraryFile(PathUtil.NOARG_PLUGIN_JAR_NAME);
|
||||
}
|
||||
override val trove4jJarPath: File
|
||||
get() = getLibraryFile(PathUtil.TROVE4J_NAME)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getSamWithReceiverJarPath() {
|
||||
return getLibraryFile(PathUtil.SAM_WITH_RECEIVER_PLUGIN_JAR_NAME);
|
||||
}
|
||||
override val compilerClasspath: List<File>
|
||||
get() = listOf(stdlibPath, reflectPath, scriptRuntimePath, trove4jJarPath)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getTrove4jJarPath() {
|
||||
return getLibraryFile(PathUtil.TROVE4J_NAME);
|
||||
}
|
||||
override val compilerPath: File
|
||||
get() = getLibraryFile(PathUtil.KOTLIN_COMPILER_JAR)
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<File> getCompilerClasspath() {
|
||||
return CollectionsKt.listOf(getStdlibPath(), getReflectPath(), getScriptRuntimePath(), getTrove4jJarPath());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public File getCompilerPath() {
|
||||
return getLibraryFile(PathUtil.KOTLIN_COMPILER_JAR);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private File getLibraryFile(@NotNull String fileName) {
|
||||
return new File(getLibPath(), fileName);
|
||||
private fun getLibraryFile(fileName: String): File {
|
||||
return File(libPath, fileName)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,16 +89,16 @@ enum class LibraryJarDescriptor(
|
||||
val shouldExist: Boolean,
|
||||
val getPath: (KotlinPaths) -> File = { paths -> File(paths.libPath, jarName) }
|
||||
) {
|
||||
RUNTIME_JAR(PathUtil.KOTLIN_JAVA_STDLIB_JAR, OrderRootType.CLASSES, true, KotlinPaths::getStdlibPath) {
|
||||
RUNTIME_JAR(PathUtil.KOTLIN_JAVA_STDLIB_JAR, OrderRootType.CLASSES, true, { it.stdlibPath }) {
|
||||
override fun findExistingJar(library: Library): VirtualFile? {
|
||||
if (isExternalLibrary(library)) return null
|
||||
return JavaRuntimeDetectionUtil.getRuntimeJar(Arrays.asList(*library.getFiles(OrderRootType.CLASSES)))
|
||||
}
|
||||
},
|
||||
|
||||
REFLECT_JAR(PathUtil.KOTLIN_JAVA_REFLECT_JAR, OrderRootType.CLASSES, false, KotlinPaths::getReflectPath),
|
||||
SCRIPT_RUNTIME_JAR(PathUtil.KOTLIN_JAVA_SCRIPT_RUNTIME_JAR, OrderRootType.CLASSES, true, KotlinPaths::getScriptRuntimePath),
|
||||
TEST_JAR(PathUtil.KOTLIN_TEST_JAR, OrderRootType.CLASSES, false, KotlinPaths::getKotlinTestPath),
|
||||
REFLECT_JAR(PathUtil.KOTLIN_JAVA_REFLECT_JAR, OrderRootType.CLASSES, false, { it.reflectPath }),
|
||||
SCRIPT_RUNTIME_JAR(PathUtil.KOTLIN_JAVA_SCRIPT_RUNTIME_JAR, OrderRootType.CLASSES, true, { it.scriptRuntimePath }),
|
||||
TEST_JAR(PathUtil.KOTLIN_TEST_JAR, OrderRootType.CLASSES, false, { it.kotlinTestPath }),
|
||||
|
||||
@Deprecated("RUNTIME_JDK7_JAR should be used since 1.2")
|
||||
RUNTIME_JRE7_JAR(PathUtil.KOTLIN_JAVA_RUNTIME_JRE7_JAR, OrderRootType.CLASSES, false),
|
||||
@@ -116,7 +116,7 @@ enum class LibraryJarDescriptor(
|
||||
RUNTIME_JRE8_SOURCES_JAR(PathUtil.KOTLIN_JAVA_RUNTIME_JRE8_SRC_JAR, OrderRootType.SOURCES, false),
|
||||
RUNTIME_JDK8_SOURCES_JAR(PathUtil.KOTLIN_JAVA_RUNTIME_JDK8_SRC_JAR, OrderRootType.SOURCES, false),
|
||||
|
||||
RUNTIME_SRC_JAR(PathUtil.KOTLIN_JAVA_STDLIB_SRC_JAR, OrderRootType.SOURCES, false, KotlinPaths::getStdlibSourcesPath) {
|
||||
RUNTIME_SRC_JAR(PathUtil.KOTLIN_JAVA_STDLIB_SRC_JAR, OrderRootType.SOURCES, false, { it.stdlibSourcesPath }) {
|
||||
override fun findExistingJar(library: Library): VirtualFile? {
|
||||
return super.findExistingJar(library) ?: LibraryUtils.getJarFile(
|
||||
library.getFiles(orderRootType).toList(),
|
||||
@@ -127,8 +127,8 @@ enum class LibraryJarDescriptor(
|
||||
REFLECT_SRC_JAR(PathUtil.KOTLIN_REFLECT_SRC_JAR, OrderRootType.SOURCES, false),
|
||||
TEST_SRC_JAR(PathUtil.KOTLIN_TEST_SRC_JAR, OrderRootType.SOURCES, false),
|
||||
|
||||
JS_STDLIB_JAR(PathUtil.JS_LIB_JAR_NAME, OrderRootType.CLASSES, true, KotlinPaths::getJsStdLibJarPath),
|
||||
JS_STDLIB_SRC_JAR(PathUtil.JS_LIB_SRC_JAR_NAME, OrderRootType.SOURCES, false, KotlinPaths::getJsStdLibSrcJarPath);
|
||||
JS_STDLIB_JAR(PathUtil.JS_LIB_JAR_NAME, OrderRootType.CLASSES, true, { it.jsStdLibJarPath }),
|
||||
JS_STDLIB_SRC_JAR(PathUtil.JS_LIB_SRC_JAR_NAME, OrderRootType.SOURCES, false, { it.jsStdLibSrcJarPath });
|
||||
|
||||
open fun findExistingJar(library: Library): VirtualFile? {
|
||||
if (isExternalLibrary(library)) return null
|
||||
|
||||
Reference in New Issue
Block a user