J2K PathUtil: convert and prettify

This commit is contained in:
Alexander Udalov
2017-07-05 19:24:37 +03:00
parent 3beb6a86f7
commit 46a01ec131
28 changed files with 158 additions and 178 deletions
@@ -62,7 +62,7 @@ class K2JVMCompiler : CLICompiler<K2JVMCompilerArguments>() {
val paths = if (arguments.kotlinHome != null)
KotlinPathsFromHomeDir(File(arguments.kotlinHome))
else
PathUtil.getKotlinPathsForCompiler()
PathUtil.kotlinPathsForCompiler
messageCollector.report(LOGGING, "Using Kotlin home directory ${paths.homePath}")
PerformanceCounter.setTimeCounterEnabled(arguments.reportPerf)
@@ -477,7 +477,7 @@ class KotlinCoreEnvironment private constructor(
var pluginRoot =
configuration.get(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT)?.let(::File)
?: configuration.get(CLIConfigurationKeys.COMPILER_JAR_LOCATOR)?.compilerJar
?: PathUtil.getPathUtilJar()
?: PathUtil.pathUtilJar
val app = ApplicationManager.getApplication()
val parentFile = pluginRoot.parentFile
@@ -51,7 +51,7 @@ open class KotlinJvmReplService(
protected val configuration = CompilerConfiguration().apply {
addJvmClasspathRoots(PathUtil.getJdkClassesRootsFromCurrentJre())
addJvmClasspathRoots(PathUtil.getKotlinPathsForCompiler().let { listOf(it.stdlibPath, it.reflectPath, it.scriptRuntimePath) })
addJvmClasspathRoots(PathUtil.kotlinPathsForCompiler.let { listOf(it.stdlibPath, it.reflectPath, it.scriptRuntimePath) })
addJvmClasspathRoots(templateClasspath)
put(CommonConfigurationKeys.MODULE_NAME, "kotlin-script")
languageVersionSettings = LanguageVersionSettingsImpl(
@@ -214,7 +214,7 @@ object MockLibraryUtil {
@Synchronized
private fun createCompilerClassLoader(): ClassLoader {
return ClassPreloadingUtils.preloadClasses(
listOf(PathUtil.getKotlinPathsForDistDirectory().compilerPath),
listOf(PathUtil.kotlinPathsForDistDirectory.compilerPath),
Preloader.DEFAULT_CLASS_NUMBER_ESTIMATE, null, null
)
}
@@ -20,7 +20,6 @@ import com.intellij.execution.configurations.GeneralCommandLine
import com.intellij.execution.util.ExecUtil
import com.intellij.openapi.util.SystemInfo
import com.intellij.openapi.util.text.StringUtil
import org.jetbrains.kotlin.cli.common.ExitCode
import org.jetbrains.kotlin.test.KotlinTestUtils
import org.jetbrains.kotlin.test.TestCaseWithTmpdir
import org.jetbrains.kotlin.utils.PathUtil
@@ -36,7 +35,7 @@ class LauncherScriptTest : TestCaseWithTmpdir() {
workDirectory: File? = null
) {
val executableFileName = if (SystemInfo.isWindows) "$executableName.bat" else executableName
val launcherFile = File(PathUtil.getKotlinPathsForDistDirectory().homePath, "bin/$executableFileName")
val launcherFile = File(PathUtil.kotlinPathsForDistDirectory.homePath, "bin/$executableFileName")
assertTrue("Launcher script not found, run 'ant dist': ${launcherFile.absolutePath}", launcherFile.exists())
val cmd = GeneralCommandLine(launcherFile.absolutePath, *args)
@@ -398,7 +398,7 @@ private fun classpathFromClassloader(): List<File> =
open class TestKotlinScriptDependenciesResolver : TestKotlinScriptDummyDependenciesResolver() {
private val kotlinPaths by lazy { PathUtil.getKotlinPathsForCompiler() }
private val kotlinPaths by lazy { PathUtil.kotlinPathsForCompiler }
@AcceptedAnnotations(DependsOn::class, DependsOnTwo::class)
override fun resolve(scriptContents: ScriptContents,
@@ -14,163 +14,144 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.utils;
package org.jetbrains.kotlin.utils
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.application.PathManager;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jps.model.java.impl.JavaSdkUtil;
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.PathManager
import org.jetbrains.jps.model.java.impl.JavaSdkUtil
import java.io.File;
import java.util.List;
import java.util.regex.Pattern;
import java.io.File
import java.util.regex.Pattern
public class PathUtil {
object PathUtil {
const val JPS_KOTLIN_HOME_PROPERTY = "jps.kotlin.home"
public static final String JPS_KOTLIN_HOME_PROPERTY = "jps.kotlin.home";
const val JS_LIB_JAR_NAME = "kotlin-stdlib-js.jar"
const val JS_LIB_10_JAR_NAME = "kotlin-jslib.jar"
const val ALLOPEN_PLUGIN_JAR_NAME = "allopen-compiler-plugin.jar"
const val NOARG_PLUGIN_JAR_NAME = "noarg-compiler-plugin.jar"
const val SAM_WITH_RECEIVER_PLUGIN_JAR_NAME = "sam-with-receiver-compiler-plugin.jar"
const val JS_LIB_SRC_JAR_NAME = "kotlin-stdlib-js-sources.jar"
const val KOTLIN_JAVA_RUNTIME_JAR = "kotlin-runtime.jar"
const val KOTLIN_JAVA_RUNTIME_JRE7_JAR = "kotlin-stdlib-jre7.jar"
const val KOTLIN_JAVA_RUNTIME_JRE8_JAR = "kotlin-stdlib-jre8.jar"
const val KOTLIN_JAVA_RUNTIME_JRE7_SRC_JAR = "kotlin-stdlib-jre7-sources.jar"
const val KOTLIN_JAVA_RUNTIME_JRE8_SRC_JAR = "kotlin-stdlib-jre8-sources.jar"
const val KOTLIN_JAVA_STDLIB_JAR = "kotlin-stdlib.jar"
const val KOTLIN_JAVA_REFLECT_JAR = "kotlin-reflect.jar"
const val KOTLIN_JAVA_SCRIPT_RUNTIME_JAR = "kotlin-script-runtime.jar"
const val KOTLIN_TEST_JAR = "kotlin-test.jar"
const val KOTLIN_TEST_JS_JAR = "kotlin-test-js.jar"
const val KOTLIN_JAVA_STDLIB_SRC_JAR = "kotlin-stdlib-sources.jar"
const val KOTLIN_JAVA_STDLIB_SRC_JAR_OLD = "kotlin-runtime-sources.jar"
const val KOTLIN_REFLECT_SRC_JAR = "kotlin-reflect-sources.jar"
const val KOTLIN_TEST_SRC_JAR = "kotlin-test-sources.jar"
const val KOTLIN_COMPILER_JAR = "kotlin-compiler.jar"
public static final String JS_LIB_JAR_NAME = "kotlin-stdlib-js.jar";
public static final String JS_LIB_10_JAR_NAME = "kotlin-jslib.jar";
public static final String ALLOPEN_PLUGIN_JAR_NAME = "allopen-compiler-plugin.jar";
public static final String NOARG_PLUGIN_JAR_NAME = "noarg-compiler-plugin.jar";
public static final String SAM_WITH_RECEIVER_PLUGIN_JAR_NAME = "sam-with-receiver-compiler-plugin.jar";
public static final String JS_LIB_SRC_JAR_NAME = "kotlin-stdlib-js-sources.jar";
public static final String KOTLIN_JAVA_RUNTIME_JAR = "kotlin-runtime.jar";
public static final String KOTLIN_JAVA_RUNTIME_JRE7_JAR = "kotlin-stdlib-jre7.jar";
public static final String KOTLIN_JAVA_RUNTIME_JRE8_JAR = "kotlin-stdlib-jre8.jar";
public static final String KOTLIN_JAVA_RUNTIME_JRE7_SRC_JAR = "kotlin-stdlib-jre7-sources.jar";
public static final String KOTLIN_JAVA_RUNTIME_JRE8_SRC_JAR = "kotlin-stdlib-jre8-sources.jar";
public static final String KOTLIN_JAVA_STDLIB_JAR = "kotlin-stdlib.jar";
public static final String KOTLIN_JAVA_REFLECT_JAR = "kotlin-reflect.jar";
public static final String KOTLIN_JAVA_SCRIPT_RUNTIME_JAR = "kotlin-script-runtime.jar";
public static final String KOTLIN_TEST_JAR = "kotlin-test.jar";
public static final String KOTLIN_TEST_JS_JAR = "kotlin-test-js.jar";
public static final String KOTLIN_JAVA_STDLIB_SRC_JAR = "kotlin-stdlib-sources.jar";
public static final String KOTLIN_JAVA_STDLIB_SRC_JAR_OLD = "kotlin-runtime-sources.jar";
public static final String KOTLIN_REFLECT_SRC_JAR = "kotlin-reflect-sources.jar";
public static final String KOTLIN_TEST_SRC_JAR = "kotlin-test-sources.jar";
public static final String KOTLIN_COMPILER_JAR = "kotlin-compiler.jar";
@JvmField
val KOTLIN_RUNTIME_JAR_PATTERN: Pattern = Pattern.compile("kotlin-(stdlib|runtime)(-\\d[\\d.]+(-.+)?)?\\.jar")
val KOTLIN_STDLIB_JS_JAR_PATTERN: Pattern = Pattern.compile("kotlin-stdlib-js.*\\.jar")
val KOTLIN_JS_LIBRARY_JAR_PATTERN: Pattern = Pattern.compile("kotlin-js-library.*\\.jar")
public static final Pattern KOTLIN_RUNTIME_JAR_PATTERN = Pattern.compile("kotlin-(stdlib|runtime)(-\\d[\\d.]+(-.+)?)?\\.jar");
public static final Pattern KOTLIN_STDLIB_JS_JAR_PATTERN = Pattern.compile("kotlin-stdlib-js.*\\.jar");
public static final Pattern KOTLIN_JS_LIBRARY_JAR_PATTERN = Pattern.compile("kotlin-js-library.*\\.jar");
private const val HOME_FOLDER_NAME = "kotlinc"
private val NO_PATH = File("<no_path>")
public static final String HOME_FOLDER_NAME = "kotlinc";
private static final File NO_PATH = new File("<no_path>");
@JvmStatic
val kotlinPathsForIdeaPlugin: KotlinPaths
get() = if (ApplicationManager.getApplication().isUnitTestMode)
kotlinPathsForDistDirectory
else
KotlinPathsFromHomeDir(compilerPathForIdeaPlugin)
private PathUtil() {}
@NotNull
public static KotlinPaths getKotlinPathsForIdeaPlugin() {
return ApplicationManager.getApplication().isUnitTestMode()
? getKotlinPathsForDistDirectory()
: new KotlinPathsFromHomeDir(getCompilerPathForIdeaPlugin());
}
@NotNull
public static KotlinPaths getKotlinPathsForJpsPlugin() {
// When JPS is run on TeamCity, it can not rely on Kotlin plugin layout,
// so the path to Kotlin is specified in a system property
String jpsKotlinHome = System.getProperty(JPS_KOTLIN_HOME_PROPERTY);
if (jpsKotlinHome != null) {
return new KotlinPathsFromHomeDir(new File(jpsKotlinHome));
// When JPS is run on TeamCity, it can not rely on Kotlin plugin layout,
// so the path to Kotlin is specified in a system property
private val kotlinPathsForJpsPlugin: KotlinPaths
get() {
val jpsKotlinHome = System.getProperty(JPS_KOTLIN_HOME_PROPERTY)
return if (jpsKotlinHome != null) {
KotlinPathsFromHomeDir(File(jpsKotlinHome))
}
else KotlinPathsFromHomeDir(compilerPathForJpsPlugin)
}
return new KotlinPathsFromHomeDir(getCompilerPathForJpsPlugin());
}
@NotNull
public static KotlinPaths getKotlinPathsForJpsPluginOrJpsTests() {
if ("true".equalsIgnoreCase(System.getProperty("kotlin.jps.tests"))) {
return getKotlinPathsForDistDirectory();
val kotlinPathsForJpsPluginOrJpsTests: KotlinPaths
get() = if ("true".equals(System.getProperty("kotlin.jps.tests"), ignoreCase = true)) {
kotlinPathsForDistDirectory
}
return getKotlinPathsForJpsPlugin();
}
else kotlinPathsForJpsPlugin
@NotNull
public static KotlinPaths getKotlinPathsForCompiler() {
if (!getPathUtilJar().isFile()) {
@JvmStatic
val kotlinPathsForCompiler: KotlinPaths
get() = if (!pathUtilJar.isFile) {
// Not running from a jar, i.e. it is it must be a unit test
return getKotlinPathsForDistDirectory();
kotlinPathsForDistDirectory
}
return new KotlinPathsFromHomeDir(getCompilerPathForCompilerJar());
}
else KotlinPathsFromHomeDir(compilerPathForCompilerJar)
@NotNull
public static KotlinPaths getKotlinPathsForDistDirectory() {
return new KotlinPathsFromHomeDir(new File("dist", HOME_FOLDER_NAME));
}
@JvmStatic
val kotlinPathsForDistDirectory: KotlinPaths
get() = KotlinPathsFromHomeDir(File("dist", HOME_FOLDER_NAME))
@NotNull
private static File getCompilerPathForCompilerJar() {
File jar = getPathUtilJar();
private val compilerPathForCompilerJar: File
get() {
val jar = pathUtilJar
if (!jar.exists()) return NO_PATH
if (!jar.exists()) return NO_PATH;
if (jar.name == KOTLIN_COMPILER_JAR) {
val lib = jar.parentFile
return lib.parentFile
}
if (jar.getName().equals(KOTLIN_COMPILER_JAR)) {
File lib = jar.getParentFile();
return lib.getParentFile();
return NO_PATH
}
return NO_PATH;
}
private val compilerPathForJpsPlugin: File
get() {
val jar = pathUtilJar
if (!jar.exists()) return NO_PATH
@NotNull
private static File getCompilerPathForJpsPlugin() {
File jar = getPathUtilJar();
if (jar.name == "kotlin-jps-plugin.jar") {
val pluginHome = jar.parentFile.parentFile.parentFile
return File(pluginHome, HOME_FOLDER_NAME)
}
if (!jar.exists()) return NO_PATH;
if (jar.getName().equals("kotlin-jps-plugin.jar")) {
File pluginHome = jar.getParentFile().getParentFile().getParentFile();
return new File(pluginHome, HOME_FOLDER_NAME);
return NO_PATH
}
return NO_PATH;
}
private val compilerPathForIdeaPlugin: File
get() {
val jar = pathUtilJar
if (!jar.exists()) return NO_PATH
@NotNull
private static File getCompilerPathForIdeaPlugin() {
File jar = getPathUtilJar();
if (jar.name == "kotlin-plugin.jar") {
val lib = jar.parentFile
val pluginHome = lib.parentFile
if (!jar.exists()) return NO_PATH;
return File(pluginHome, HOME_FOLDER_NAME)
}
if (jar.getName().equals("kotlin-plugin.jar")) {
File lib = jar.getParentFile();
File pluginHome = lib.getParentFile();
return new File(pluginHome, HOME_FOLDER_NAME);
return NO_PATH
}
return NO_PATH;
val pathUtilJar: File
get() = getResourcePathForClass(PathUtil::class.java)
@JvmStatic
fun getResourcePathForClass(aClass: Class<*>): File {
val path = "/" + aClass.name.replace('.', '/') + ".class"
val resourceRoot = PathManager.getResourceRoot(aClass, path) ?: throw IllegalStateException("Resource not found: $path")
return File(resourceRoot).absoluteFile
}
@NotNull
public static File getPathUtilJar() {
return getResourcePathForClass(PathUtil.class);
}
@JvmStatic
fun getJdkClassesRootsFromCurrentJre(): List<File> =
getJdkClassesRootsFromJre(System.getProperty("java.home"))
@NotNull
public static File getResourcePathForClass(@NotNull Class aClass) {
String path = "/" + aClass.getName().replace('.', '/') + ".class";
String resourceRoot = PathManager.getResourceRoot(aClass, path);
if (resourceRoot == null) {
throw new IllegalStateException("Resource not found: " + path);
}
return new File(resourceRoot).getAbsoluteFile();
}
@JvmStatic
fun getJdkClassesRootsFromJre(javaHome: String): List<File> =
JavaSdkUtil.getJdkClassesRoots(File(javaHome), true)
@NotNull
public static List<File> getJdkClassesRootsFromCurrentJre() {
return getJdkClassesRootsFromJre(System.getProperty("java.home"));
}
@NotNull
public static List<File> getJdkClassesRootsFromJre(@NotNull String javaHome) {
return JavaSdkUtil.getJdkClassesRoots(new File(javaHome), true);
}
@NotNull
public static List<File> getJdkClassesRoots(@NotNull File jdkHome) {
return JavaSdkUtil.getJdkClassesRoots(jdkHome, false);
}
@JvmStatic
fun getJdkClassesRoots(jdkHome: File): List<File> =
JavaSdkUtil.getJdkClassesRoots(jdkHome, false)
}
@@ -24,7 +24,6 @@ import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.module.Module
import com.intellij.openapi.project.Project
import com.intellij.openapi.projectRoots.JavaSdkType
import com.intellij.openapi.projectRoots.JdkUtil
import com.intellij.openapi.projectRoots.SimpleJavaSdkType
import com.intellij.openapi.roots.ModuleRootManager
import com.intellij.openapi.roots.OrderEnumerator
@@ -68,7 +67,7 @@ class KotlinConsoleKeeper(val project: Project) {
// use to debug repl process
//paramList.add("-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005")
val kotlinPaths = PathUtil.getKotlinPathsForIdeaPlugin()
val kotlinPaths = PathUtil.kotlinPathsForIdeaPlugin
val replClassPath = listOf(kotlinPaths.compilerPath, kotlinPaths.reflectPath, kotlinPaths.stdlibPath, kotlinPaths.scriptRuntimePath)
.joinToString(File.pathSeparator) { it.absolutePath }
@@ -112,4 +111,4 @@ class KotlinConsoleKeeper(val project: Project) {
companion object {
@JvmStatic fun getInstance(project: Project) = ServiceManager.getService(project, KotlinConsoleKeeper::class.java)
}
}
}
@@ -44,7 +44,7 @@ class KotlinJsr223JvmScriptEngine4Idea(
) : KotlinJsr223JvmScriptEngineBase(factory) {
private val daemon by lazy {
val path = PathUtil.getKotlinPathsForIdeaPlugin().compilerPath
val path = PathUtil.kotlinPathsForIdeaPlugin.compilerPath
assert(path.exists())
val compilerId = CompilerId.makeCompilerId(path)
val daemonOptions = configureDaemonOptions()
@@ -58,7 +58,7 @@ fun classpathFromClassloader(classLoader: ClassLoader): List<File>? =
private val kotlinCompilerJar: File by lazy {
// highest prio - explicit property
System.getProperty("kotlin.compiler.jar")?.let(::File)?.takeIf(File::exists)
?: PathUtil.getKotlinPathsForIdeaPlugin().compilerPath
?: PathUtil.kotlinPathsForIdeaPlugin.compilerPath
?: throw FileNotFoundException("Cannot find kotlin compiler jar, set kotlin.compiler.jar property to proper location")
}
@@ -83,4 +83,4 @@ private val kotlinScriptRuntimeJar: File? by lazy {
?: File(kotlinCompilerJar.parentFile, KOTLIN_JAVA_SCRIPT_RUNTIME_JAR).takeIf(File::exists)
}
private val kotlinScriptStandardJars by lazy { listOf(kotlinStdlibJar, kotlinScriptRuntimeJar) }
private val kotlinScriptStandardJars by lazy { listOf(kotlinStdlibJar, kotlinScriptRuntimeJar) }
@@ -59,15 +59,13 @@ object ConfigLibraryUtil {
fun configureKotlinJsRuntimeAndSdk(module: Module, sdk: Sdk) {
configureSdk(module, sdk)
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_JS_STDLIB_NAME,
PathUtil.getKotlinPathsForDistDirectory().jsStdLibJarPath), module,
PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath), module,
JSLibraryKind)
}
fun configureKotlinRuntime(module: Module) {
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_JAVA_RUNTIME_LIB_NAME, PathUtil.getKotlinPathsForDistDirectory().stdlibPath),
module)
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_TEST_LIB_NAME, PathUtil.getKotlinPathsForDistDirectory().kotlinTestPath),
module)
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_JAVA_RUNTIME_LIB_NAME, PathUtil.kotlinPathsForDistDirectory.stdlibPath), module)
addLibrary(getKotlinRuntimeLibEditor(DEFAULT_KOTLIN_TEST_LIB_NAME, PathUtil.kotlinPathsForDistDirectory.kotlinTestPath), module)
}
fun unConfigureKotlinRuntime(module: Module) {
@@ -191,7 +191,7 @@ private class ScriptCommandLineState(
val scriptVFile = LocalFileSystem.getInstance().findFileByIoFile(File(filePath)) ?:
throw CantRunException("Script file was not found in project")
params.classPath.add(PathUtil.getKotlinPathsForIdeaPlugin().compilerPath)
params.classPath.add(PathUtil.kotlinPathsForIdeaPlugin.compilerPath)
val scriptClasspath = ScriptDependenciesManager.getInstance(environment.project).getScriptClasspath(scriptVFile)
scriptClasspath.forEach {
@@ -60,7 +60,7 @@ class BundledKotlinScriptDependenciesResolver : DependenciesResolver {
val javaHome = environment.get("sdk") as String?
val dependencies = ScriptDependencies(
javaHome = javaHome?.let(::File),
classpath = with(PathUtil.getKotlinPathsForIdeaPlugin()) {
classpath = with(PathUtil.kotlinPathsForIdeaPlugin) {
listOf(
reflectPath,
stdlibPath,
@@ -198,7 +198,7 @@ enum class LibraryJarDescriptor(val jarName: String,
return LibraryUtils.getJarFile(Arrays.asList(*library.getFiles(orderRootType)), jarName)
}
fun getPathInPlugin() = getPath(PathUtil.getKotlinPathsForIdeaPlugin())
fun getPathInPlugin() = getPath(PathUtil.kotlinPathsForIdeaPlugin)
}
fun bundledRuntimeVersion(): String {
@@ -206,7 +206,7 @@ fun bundledRuntimeVersion(): String {
}
private val bundledRuntimeBuildNumber: String? by lazy {
val file = PathUtil.getKotlinPathsForIdeaPlugin().buildNumberFile
val file = PathUtil.kotlinPathsForIdeaPlugin.buildNumberFile
if (file.exists()) file.readText().trim() else null
}
@@ -190,10 +190,10 @@ abstract class AbstractConfigureKotlinTest : PlatformTestCase() {
}
private val pathToExistentRuntimeJar: String
get() = PathUtil.getKotlinPathsForDistDirectory().stdlibPath.parent
get() = PathUtil.kotlinPathsForDistDirectory.stdlibPath.parent
private val pathToExistentJsJar: String
get() = PathUtil.getKotlinPathsForDistDirectory().jsStdLibJarPath.parent
get() = PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath.parent
protected fun assertNotConfigured(module: Module, configurator: KotlinWithLibraryConfigurator) {
TestCase.assertFalse(
@@ -73,7 +73,7 @@ abstract class AbstractScriptConfigurationTest : AbstractPsiCheckerTest() {
protected fun configureScriptEnvironment(path: String) {
val templateOutDir = compileLibToDir(
File("${path}template"),
PathUtil.getKotlinPathsForDistDirectory().scriptRuntimePath.path
PathUtil.kotlinPathsForDistDirectory.scriptRuntimePath.path
)
val libSrcDir = File("${path}lib")
@@ -333,7 +333,7 @@ class KotlinJpsBuildTest : AbstractKotlinJpsBuildTestCase() {
fun testKotlinJavaScriptProjectWithDirectoryAsStdlib() {
initProject()
val jslibJar = PathUtil.getKotlinPathsForDistDirectory().jsStdLibJarPath
val jslibJar = PathUtil.kotlinPathsForDistDirectory.jsStdLibJarPath
val jslibDir = File(workDir, "KotlinJavaScript")
try {
ZipUtil.extract(jslibJar, jslibDir, null)
@@ -45,7 +45,7 @@ class ClasspathOrderTest : TestCaseWithTmpdir() {
File(tmpdir, "output").absolutePath,
listOf(sourceDir),
listOf(JvmSourceRoot(sourceDir)),
listOf(PathUtil.getKotlinPathsForDistDirectory().runtimePath),
listOf(PathUtil.kotlinPathsForDistDirectory.runtimePath),
null,
JavaModuleBuildTargetType.PRODUCTION.typeId,
JavaModuleBuildTargetType.PRODUCTION.isTests,
@@ -58,4 +58,4 @@ class ClasspathOrderTest : TestCaseWithTmpdir() {
MockLibraryUtil.compileKotlinModule(xml.absolutePath)
}
}
}
@@ -51,8 +51,11 @@ import org.jetbrains.kotlin.compilerRunner.JpsCompilerEnvironment
import org.jetbrains.kotlin.compilerRunner.JpsKotlinCompilerRunner
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollector
import org.jetbrains.kotlin.compilerRunner.OutputItemsCollectorImpl
import org.jetbrains.kotlin.config.*
import org.jetbrains.kotlin.config.CompilerRunnerConstants
import org.jetbrains.kotlin.config.CompilerRunnerConstants.INTERNAL_ERROR_PREFIX
import org.jetbrains.kotlin.config.IncrementalCompilation
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.config.Services
import org.jetbrains.kotlin.daemon.common.isDaemonEnabled
import org.jetbrains.kotlin.incremental.*
import org.jetbrains.kotlin.incremental.components.LookupTracker
@@ -469,7 +472,7 @@ class KotlinBuilder : ModuleLevelBuilder(BuilderCategory.SOURCE_PROCESSOR) {
}
return JpsCompilerEnvironment(
PathUtil.getKotlinPathsForJpsPluginOrJpsTests(),
PathUtil.kotlinPathsForJpsPluginOrJpsTests,
compilerServices,
ClassCondition { className ->
className.startsWith("org.jetbrains.kotlin.load.kotlin.incremental.components.")
@@ -25,7 +25,7 @@ class AllOpenGradleProjectImportHandler : AbstractGradleImportHandler() {
override val pluginName = "allopen"
override val annotationOptionName = AllOpenCommandLineProcessor.ANNOTATION_OPTION.name
override val dataStorageTaskName = "allOpenDataStorageTask"
override val pluginJarFileFromIdea = PathUtil.getKotlinPathsForIdeaPlugin().allOpenPluginJarPath
override val pluginJarFileFromIdea = PathUtil.kotlinPathsForIdeaPlugin.allOpenPluginJarPath
override fun getAnnotationsForPreset(presetName: String): List<String> {
for ((name, annotations) in AllOpenCommandLineProcessor.SUPPORTED_PRESETS.entries) {
@@ -36,4 +36,4 @@ class AllOpenGradleProjectImportHandler : AbstractGradleImportHandler() {
return super.getAnnotationsForPreset(presetName)
}
}
}
@@ -29,7 +29,7 @@ class AllOpenMavenProjectImportHandler : AbstractMavenImportHandler() {
override val pluginName = "allopen"
override val annotationOptionName = AllOpenCommandLineProcessor.ANNOTATION_OPTION.name
override val mavenPluginArtifactName = "kotlin-maven-allopen"
override val pluginJarFileFromIdea = PathUtil.getKotlinPathsForIdeaPlugin().allOpenPluginJarPath
override val pluginJarFileFromIdea = PathUtil.kotlinPathsForIdeaPlugin.allOpenPluginJarPath
override fun getAnnotations(enabledCompilerPlugins: List<String>, compilerPluginOptions: List<String>): List<String>? {
if ("all-open" !in enabledCompilerPlugins && "spring" !in enabledCompilerPlugins) {
@@ -51,4 +51,4 @@ class AllOpenMavenProjectImportHandler : AbstractMavenImportHandler() {
return annotations
}
}
}
@@ -151,7 +151,7 @@ abstract class AbstractKotlinKapt3IntegrationTest : CodegenTestCase() {
options: Map<String, String>,
stubsOutputDir: File,
incrementalDataOutputDir: File
) : AbstractKapt3Extension(PathUtil.getJdkClassesRootsFromCurrentJre() + PathUtil.getKotlinPathsForIdeaPlugin().stdlibPath,
) : AbstractKapt3Extension(PathUtil.getJdkClassesRootsFromCurrentJre() + PathUtil.kotlinPathsForIdeaPlugin.stdlibPath,
emptyList(), javaSourceRoots, outputDir, outputDir,
stubsOutputDir, incrementalDataOutputDir, options, emptyMap(), "", STUBS_AND_APT, System.currentTimeMillis(),
KaptLogger(true), correctErrorTypes = true, compilerConfiguration = CompilerConfiguration.EMPTY
@@ -188,4 +188,4 @@ abstract class AbstractKotlinKapt3IntegrationTest : CodegenTestCase() {
super.saveIncrementalData(kaptContext, messageCollector, converter)
}
}
}
}
@@ -124,10 +124,10 @@ abstract class AbstractKotlinKaptContextTest : AbstractKotlinKapt3Test() {
val sourceOutputDir = Files.createTempDirectory("kaptRunner").toFile()
try {
kaptContext.doAnnotationProcessing(emptyList(), listOf(JavaKaptContextTest.simpleProcessor()),
compileClasspath = PathUtil.getJdkClassesRootsFromCurrentJre() + PathUtil.getKotlinPathsForIdeaPlugin().stdlibPath,
annotationProcessingClasspath = emptyList(), annotationProcessors = "",
sourcesOutputDir = sourceOutputDir, classesOutputDir = sourceOutputDir,
additionalSources = compilationUnits, withJdk = true)
compileClasspath = PathUtil.getJdkClassesRootsFromCurrentJre() + PathUtil.kotlinPathsForIdeaPlugin.stdlibPath,
annotationProcessingClasspath = emptyList(), annotationProcessors = "",
sourcesOutputDir = sourceOutputDir, classesOutputDir = sourceOutputDir,
additionalSources = compilationUnits, withJdk = true)
val javaFiles = sourceOutputDir.walkTopDown().filter { it.isFile && it.extension == "java" }
val actualRaw = javaFiles.sortedBy { it.name }.joinToString(FILE_SEPARATOR) { it.name + ":\n\n" + it.readText() }
@@ -137,4 +137,4 @@ abstract class AbstractKotlinKaptContextTest : AbstractKotlinKapt3Test() {
sourceOutputDir.deleteRecursively()
}
}
}
}
@@ -16,8 +16,8 @@
package org.jetbrains.kotlin.noarg.ide
import org.jetbrains.kotlin.noarg.NoArgCommandLineProcessor
import org.jetbrains.kotlin.annotation.plugin.ide.AbstractGradleImportHandler
import org.jetbrains.kotlin.noarg.NoArgCommandLineProcessor
import org.jetbrains.kotlin.utils.PathUtil
class NoArgGradleProjectImportHandler : AbstractGradleImportHandler() {
@@ -25,7 +25,7 @@ class NoArgGradleProjectImportHandler : AbstractGradleImportHandler() {
override val pluginName = "noarg"
override val annotationOptionName = NoArgCommandLineProcessor.ANNOTATION_OPTION.name
override val dataStorageTaskName = "noArgDataStorageTask"
override val pluginJarFileFromIdea = PathUtil.getKotlinPathsForIdeaPlugin().noArgPluginJarPath
override val pluginJarFileFromIdea = PathUtil.kotlinPathsForIdeaPlugin.noArgPluginJarPath
override fun getAnnotationsForPreset(presetName: String): List<String> {
for ((name, annotations) in NoArgCommandLineProcessor.SUPPORTED_PRESETS.entries) {
@@ -36,4 +36,4 @@ class NoArgGradleProjectImportHandler : AbstractGradleImportHandler() {
return super.getAnnotationsForPreset(presetName)
}
}
}
@@ -16,8 +16,8 @@
package org.jetbrains.kotlin.noarg.ide
import org.jetbrains.kotlin.noarg.NoArgCommandLineProcessor
import org.jetbrains.kotlin.annotation.plugin.ide.AbstractMavenImportHandler
import org.jetbrains.kotlin.noarg.NoArgCommandLineProcessor
import org.jetbrains.kotlin.utils.PathUtil
class NoArgMavenProjectImportHandler : AbstractMavenImportHandler() {
@@ -29,7 +29,7 @@ class NoArgMavenProjectImportHandler : AbstractMavenImportHandler() {
override val pluginName = "noarg"
override val annotationOptionName = NoArgCommandLineProcessor.ANNOTATION_OPTION.name
override val mavenPluginArtifactName = "kotlin-maven-noarg"
override val pluginJarFileFromIdea = PathUtil.getKotlinPathsForIdeaPlugin().noArgPluginJarPath
override val pluginJarFileFromIdea = PathUtil.kotlinPathsForIdeaPlugin.noArgPluginJarPath
override fun getAnnotations(enabledCompilerPlugins: List<String>, compilerPluginOptions: List<String>): List<String>? {
if ("no-arg" !in enabledCompilerPlugins && "jpa" !in enabledCompilerPlugins) {
@@ -50,4 +50,4 @@ class NoArgMavenProjectImportHandler : AbstractMavenImportHandler() {
return annotations
}
}
}
@@ -25,7 +25,7 @@ class SamWithReceiverGradleProjectImportHandler : AbstractGradleImportHandler()
override val pluginName = "sam-with-receiver"
override val annotationOptionName = SamWithReceiverCommandLineProcessor.ANNOTATION_OPTION.name
override val dataStorageTaskName = "samWithReceiverDataStorageTask"
override val pluginJarFileFromIdea = PathUtil.getKotlinPathsForIdeaPlugin().allOpenPluginJarPath
override val pluginJarFileFromIdea = PathUtil.kotlinPathsForIdeaPlugin.allOpenPluginJarPath
override fun getAnnotationsForPreset(presetName: String): List<String> {
for ((name, annotations) in SamWithReceiverCommandLineProcessor.SUPPORTED_PRESETS.entries) {
@@ -36,4 +36,4 @@ class SamWithReceiverGradleProjectImportHandler : AbstractGradleImportHandler()
return super.getAnnotationsForPreset(presetName)
}
}
}
@@ -29,7 +29,7 @@ class SamWithReceiverMavenProjectImportHandler : AbstractMavenImportHandler() {
override val pluginName = "samWithReceiver"
override val annotationOptionName = SamWithReceiverCommandLineProcessor.ANNOTATION_OPTION.name
override val mavenPluginArtifactName = "kotlin-maven-sam-with-receiver"
override val pluginJarFileFromIdea = PathUtil.getKotlinPathsForIdeaPlugin().allOpenPluginJarPath
override val pluginJarFileFromIdea = PathUtil.kotlinPathsForIdeaPlugin.allOpenPluginJarPath
override fun getAnnotations(enabledCompilerPlugins: List<String>, compilerPluginOptions: List<String>): List<String>? {
if ("sam-with-receiver" !in enabledCompilerPlugins) {
@@ -51,4 +51,4 @@ class SamWithReceiverMavenProjectImportHandler : AbstractMavenImportHandler() {
return annotations
}
}
}
@@ -53,7 +53,7 @@ class SourceSectionsTest : TestCaseWithTmpdir() {
}
private val kotlinPaths: KotlinPaths by lazy {
val paths = PathUtil.getKotlinPathsForDistDirectory()
val paths = PathUtil.kotlinPathsForDistDirectory
TestCase.assertTrue("Lib directory doesn't exist. Run 'ant dist'", paths.libPath.absoluteFile.isDirectory)
paths
}