minor: rename depends annotation in script tests, add it to implicit imports
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
// this script expected parameter num : Int
|
// this script expected parameter num : Int
|
||||||
|
|
||||||
@file:org.jetbrains.kotlin.scripts.depends("@{runtime}")
|
@file:DependsOn("@{runtime}")
|
||||||
|
|
||||||
fun fib(n: Int): Int {
|
fun fib(n: Int): Int {
|
||||||
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
|
val v = if(n < 2) 1 else fib(n-1) + fib(n-2)
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class TestKotlinScriptDependenciesResolver : AnnotationBasedScriptDependenciesRe
|
|||||||
|
|
||||||
private val kotlinPaths by lazy { PathUtil.getKotlinPathsForCompiler() }
|
private val kotlinPaths by lazy { PathUtil.getKotlinPathsForCompiler() }
|
||||||
|
|
||||||
@AcceptedAnnotations(depends::class)
|
@AcceptedAnnotations(DependsOn::class)
|
||||||
override fun resolve(scriptFile: File?,
|
override fun resolve(scriptFile: File?,
|
||||||
annotations: Iterable<Annotation>,
|
annotations: Iterable<Annotation>,
|
||||||
environment: Map<String, Any?>?,
|
environment: Map<String, Any?>?,
|
||||||
@@ -131,13 +131,14 @@ class TestKotlinScriptDependenciesResolver : AnnotationBasedScriptDependenciesRe
|
|||||||
{
|
{
|
||||||
val cp = annotations.flatMap {
|
val cp = annotations.flatMap {
|
||||||
when (it) {
|
when (it) {
|
||||||
is depends -> listOf(if (it.path == "@{runtime}") kotlinPaths.runtimePath else File(it.path))
|
is DependsOn -> listOf(if (it.path == "@{runtime}") kotlinPaths.runtimePath else File(it.path))
|
||||||
is InvalidScriptResolverAnnotation -> throw Exception("Invalid annotation ${it.name}", it.error)
|
is InvalidScriptResolverAnnotation -> throw Exception("Invalid annotation ${it.name}", it.error)
|
||||||
else -> throw Exception("Unknown annotation ${it.javaClass}")
|
else -> throw Exception("Unknown annotation ${it.javaClass}")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return object : KotlinScriptExternalDependencies {
|
return object : KotlinScriptExternalDependencies {
|
||||||
override val classpath: Iterable<File> = classpathFromClassloader() + cp
|
override val classpath: Iterable<File> = classpathFromClassloader() + cp
|
||||||
|
override val imports: Iterable<String> = listOf("org.jetbrains.kotlin.scripts.DependsOn")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -165,4 +166,4 @@ abstract class ScriptWithBaseClass(num: Int, passthrough: Int) : TestDSLClassWit
|
|||||||
|
|
||||||
@Target(AnnotationTarget.FILE)
|
@Target(AnnotationTarget.FILE)
|
||||||
@Retention(AnnotationRetention.RUNTIME)
|
@Retention(AnnotationRetention.RUNTIME)
|
||||||
annotation class depends(val path: String)
|
annotation class DependsOn(val path: String)
|
||||||
|
|||||||
Reference in New Issue
Block a user