Drop deprecated KotlinPaths.getRuntimePath, use getStdlibPath instead

This commit is contained in:
Alexander Udalov
2017-07-27 15:59:16 +03:00
parent b988582531
commit 8b149db0ec
10 changed files with 21 additions and 40 deletions
@@ -118,16 +118,11 @@ public class CompileEnvironmentUtil {
}
private static void writeRuntimeToJar(JarOutputStream stream) throws IOException {
File runtimePath = PathUtil.getKotlinPathsForCompiler().getRuntimePath();
if (!runtimePath.exists()) {
throw new CompileEnvironmentException("Couldn't find runtime library");
File stdlibPath = PathUtil.getKotlinPathsForCompiler().getStdlibPath();
if (!stdlibPath.exists()) {
throw new CompileEnvironmentException("Couldn't find kotlin-stdlib at " + stdlibPath);
}
File scriptRuntimePath = PathUtil.getKotlinPathsForCompiler().getScriptRuntimePath();
if (!scriptRuntimePath.exists()) {
throw new CompileEnvironmentException("Couldn't find script runtime library");
}
copyJarImpl(stream, runtimePath);
copyJarImpl(stream, stdlibPath);
}
private static void copyJarImpl(JarOutputStream stream, File jarPath) throws IOException {
+1 -1
View File
@@ -1,7 +1,7 @@
// this script expected parameter num : Int
@file:DependsOn("@{runtime}")
@file:DependsOn("@{kotlin-stdlib}")
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
+1 -1
View File
@@ -1,7 +1,7 @@
// this script expected parameter num : Int
@file:DependsOnTwo(path2 = "@{runtime}")
@file:DependsOnTwo(path2 = "@{kotlin-stdlib}")
fun fib(n: Int): Int {
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
+2 -2
View File
@@ -1,4 +1,4 @@
@file:DependsOn("@{runtime}")
@file:DependsOn("@{kotlin-stdlib}")
fun main() {
error("my error")
@@ -8,4 +8,4 @@ fun a() {
main()
}
a()
a()
@@ -401,22 +401,21 @@ open class TestKotlinScriptDependenciesResolver : TestKotlinScriptDummyDependenc
private val kotlinPaths by lazy { PathUtil.kotlinPathsForCompiler }
@AcceptedAnnotations(DependsOn::class, DependsOnTwo::class)
override fun resolve(scriptContents: ScriptContents,
environment: Environment
): ResolveResult
{
val cp = scriptContents.annotations.flatMap {
when (it) {
is DependsOn -> if (it.path == "@{runtime}") listOf(kotlinPaths.runtimePath, kotlinPaths.scriptRuntimePath) else listOf(File(it.path))
is DependsOnTwo -> listOf(it.path1, it.path2).flatMap {
override fun resolve(scriptContents: ScriptContents, environment: Environment): ResolveResult {
val cp = scriptContents.annotations.flatMap { annotation ->
when (annotation) {
is DependsOn ->
if (annotation.path == "@{kotlin-stdlib}") listOf(kotlinPaths.stdlibPath, kotlinPaths.scriptRuntimePath)
else listOf(File(annotation.path))
is DependsOnTwo -> listOf(annotation.path1, annotation.path2).flatMap {
when {
it.isBlank() -> emptyList()
it == "@{runtime}" -> listOf(kotlinPaths.runtimePath, kotlinPaths.scriptRuntimePath)
it == "@{kotlin-stdlib}" -> listOf(kotlinPaths.stdlibPath, kotlinPaths.scriptRuntimePath)
else -> listOf(File(it))
}
}
is InvalidScriptResolverAnnotation -> throw Exception("Invalid annotation ${it.name}", it.error)
else -> throw Exception("Unknown annotation ${it::class.java}")
is InvalidScriptResolverAnnotation -> throw Exception("Invalid annotation ${annotation.name}", annotation.error)
else -> throw Exception("Unknown annotation ${annotation::class.java}")
}
}
return ScriptDependencies(
@@ -27,12 +27,6 @@ public interface KotlinPaths {
@NotNull
File getLibPath();
/**
* @deprecated Use getStdlibPath() instead
*/
@NotNull
File getRuntimePath();
@NotNull
File getStdlibPath();
@@ -40,12 +40,6 @@ public class KotlinPathsFromHomeDir implements KotlinPaths {
return new File(homePath, "lib");
}
@Override
@NotNull
public File getRuntimePath() {
return getLibraryFile(PathUtil.KOTLIN_JAVA_RUNTIME_JAR);
}
@NotNull
@Override
public File getStdlibPath() {
@@ -30,7 +30,6 @@ object PathUtil {
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"
@@ -177,7 +177,7 @@ abstract class AbstractConfigureKotlinTest : PlatformTestCase() {
private val pathToNonexistentRuntimeJar: String
get() {
val pathToTempKotlinRuntimeJar = FileUtil.getTempDirectory() + "/" + PathUtil.KOTLIN_JAVA_RUNTIME_JAR
val pathToTempKotlinRuntimeJar = FileUtil.getTempDirectory() + "/kotlin-runtime.jar"
PlatformTestCase.myFilesToDelete.add(File(pathToTempKotlinRuntimeJar))
return pathToTempKotlinRuntimeJar
}
@@ -32,7 +32,7 @@ import java.io.File
*/
class ClasspathOrderTest : TestCaseWithTmpdir() {
companion object {
val sourceDir = File(KotlinTestUtils.getTestDataPathBase() + "/classpathOrder").absoluteFile
private val sourceDir = File(KotlinTestUtils.getTestDataPathBase() + "/classpathOrder").absoluteFile
}
fun testClasspathOrderForCLI() {
@@ -45,7 +45,7 @@ class ClasspathOrderTest : TestCaseWithTmpdir() {
File(tmpdir, "output").absolutePath,
listOf(sourceDir),
listOf(JvmSourceRoot(sourceDir)),
listOf(PathUtil.kotlinPathsForDistDirectory.runtimePath),
listOf(PathUtil.kotlinPathsForDistDirectory.stdlibPath),
null,
JavaModuleBuildTargetType.PRODUCTION.typeId,
JavaModuleBuildTargetType.PRODUCTION.isTests,