From 51888154e19144bc08d92b853b09b8cb88ba9971 Mon Sep 17 00:00:00 2001 From: Ilya Chernikov Date: Thu, 26 Apr 2018 13:10:09 +0200 Subject: [PATCH] Change custom script examples file extensions: fixes shadowing of the gradle script definitions after these example script defs are loaded via discovery mechanisms --- .../script/examples/jvm/resolve/maven/test/resolveTest.kt | 6 +++--- ...ror.kts => hello-maven-resolve-error.scriptwithdeps.kts} | 0 ...nit.kts => hello-maven-resolve-junit.scriptwithdeps.kts} | 0 ...-junit.kts => hello-unresolved-junit.scriptwithdeps.kts} | 0 .../kotlin/script/examples/jvm/resolve/maven/scriptDef.kt | 2 ++ .../kotlin/script/examples/jvm/simple/test/simpleTest.kt | 4 ++-- .../host/testData/{error.kts => error.simplescript.kts} | 0 .../host/testData/{hello.kts => hello.simplescript.kts} | 0 .../kotlin/script/examples/jvm/simple/scriptDef.kt | 2 ++ 9 files changed, 9 insertions(+), 5 deletions(-) rename libraries/examples/scripting/jvm-maven-deps/host/testData/{hello-maven-resolve-error.kts => hello-maven-resolve-error.scriptwithdeps.kts} (100%) rename libraries/examples/scripting/jvm-maven-deps/host/testData/{hello-maven-resolve-junit.kts => hello-maven-resolve-junit.scriptwithdeps.kts} (100%) rename libraries/examples/scripting/jvm-maven-deps/host/testData/{hello-unresolved-junit.kts => hello-unresolved-junit.scriptwithdeps.kts} (100%) rename libraries/examples/scripting/jvm-simple-script/host/testData/{error.kts => error.simplescript.kts} (100%) rename libraries/examples/scripting/jvm-simple-script/host/testData/{hello.kts => hello.simplescript.kts} (100%) diff --git a/libraries/examples/scripting/jvm-maven-deps/host/test/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/test/resolveTest.kt b/libraries/examples/scripting/jvm-maven-deps/host/test/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/test/resolveTest.kt index 2350c5fb511..45015d00b03 100644 --- a/libraries/examples/scripting/jvm-maven-deps/host/test/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/test/resolveTest.kt +++ b/libraries/examples/scripting/jvm-maven-deps/host/test/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/test/resolveTest.kt @@ -15,7 +15,7 @@ class ResolveTest { @Test fun testResolveJunit() { - val res = evalFile(File("testData/hello-maven-resolve-junit.kts")) + val res = evalFile(File("testData/hello-maven-resolve-junit.scriptwithdeps.kts")) Assert.assertTrue( "test failed:\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}", @@ -25,7 +25,7 @@ class ResolveTest { @Test fun testUnresolvedJunit() { - val res = evalFile(File("testData/hello-unresolved-junit.kts")) + val res = evalFile(File("testData/hello-unresolved-junit.scriptwithdeps.kts")) Assert.assertTrue( "test failed - expecting a failure with the message \"Unresolved reference: junit\" but received " + @@ -36,7 +36,7 @@ class ResolveTest { @Test fun testResolveError() { - val res = evalFile(File("testData/hello-maven-resolve-error.kts")) + val res = evalFile(File("testData/hello-maven-resolve-error.scriptwithdeps.kts")) Assert.assertTrue( "test failed - expecting a failure with the message \"Unknown set of arguments to maven resolver: abracadabra\" but received " + diff --git a/libraries/examples/scripting/jvm-maven-deps/host/testData/hello-maven-resolve-error.kts b/libraries/examples/scripting/jvm-maven-deps/host/testData/hello-maven-resolve-error.scriptwithdeps.kts similarity index 100% rename from libraries/examples/scripting/jvm-maven-deps/host/testData/hello-maven-resolve-error.kts rename to libraries/examples/scripting/jvm-maven-deps/host/testData/hello-maven-resolve-error.scriptwithdeps.kts diff --git a/libraries/examples/scripting/jvm-maven-deps/host/testData/hello-maven-resolve-junit.kts b/libraries/examples/scripting/jvm-maven-deps/host/testData/hello-maven-resolve-junit.scriptwithdeps.kts similarity index 100% rename from libraries/examples/scripting/jvm-maven-deps/host/testData/hello-maven-resolve-junit.kts rename to libraries/examples/scripting/jvm-maven-deps/host/testData/hello-maven-resolve-junit.scriptwithdeps.kts diff --git a/libraries/examples/scripting/jvm-maven-deps/host/testData/hello-unresolved-junit.kts b/libraries/examples/scripting/jvm-maven-deps/host/testData/hello-unresolved-junit.scriptwithdeps.kts similarity index 100% rename from libraries/examples/scripting/jvm-maven-deps/host/testData/hello-unresolved-junit.kts rename to libraries/examples/scripting/jvm-maven-deps/host/testData/hello-unresolved-junit.scriptwithdeps.kts diff --git a/libraries/examples/scripting/jvm-maven-deps/script/src/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/scriptDef.kt b/libraries/examples/scripting/jvm-maven-deps/script/src/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/scriptDef.kt index 355e3cf6196..ed74f60f2dd 100644 --- a/libraries/examples/scripting/jvm-maven-deps/script/src/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/scriptDef.kt +++ b/libraries/examples/scripting/jvm-maven-deps/script/src/org/jetbrains/kotlin/script/examples/jvm/resolve/maven/scriptDef.kt @@ -15,12 +15,14 @@ import kotlin.script.dependencies.ScriptDependenciesResolver import kotlin.script.experimental.annotations.KotlinScript import kotlin.script.experimental.annotations.KotlinScriptCompilationConfigurator import kotlin.script.experimental.annotations.KotlinScriptEvaluator +import kotlin.script.experimental.annotations.KotlinScriptFileExtension import kotlin.script.experimental.api.* import kotlin.script.experimental.jvm.* import kotlin.script.experimental.jvm.runners.BasicJvmScriptEvaluator import kotlin.script.experimental.misc.* @KotlinScript +@KotlinScriptFileExtension("scriptwithdeps.kts") @KotlinScriptCompilationConfigurator(MyConfigurator::class) @KotlinScriptEvaluator(BasicJvmScriptEvaluator::class) abstract class MyScriptWithMavenDeps { diff --git a/libraries/examples/scripting/jvm-simple-script/host/test/org/jetbrains/kotlin/script/examples/jvm/simple/test/simpleTest.kt b/libraries/examples/scripting/jvm-simple-script/host/test/org/jetbrains/kotlin/script/examples/jvm/simple/test/simpleTest.kt index d4e1ac8bb76..c97d1b69b35 100644 --- a/libraries/examples/scripting/jvm-simple-script/host/test/org/jetbrains/kotlin/script/examples/jvm/simple/test/simpleTest.kt +++ b/libraries/examples/scripting/jvm-simple-script/host/test/org/jetbrains/kotlin/script/examples/jvm/simple/test/simpleTest.kt @@ -15,7 +15,7 @@ class SimpleTest { @Test fun testSimple() { - val res = evalFile(File("testData/hello.kts")) + val res = evalFile(File("testData/hello.simplescript.kts")) Assert.assertTrue( "test failed:\n ${res.reports.joinToString("\n ") { it.message + if (it.exception == null) "" else ": ${it.exception}" }}", @@ -25,7 +25,7 @@ class SimpleTest { @Test fun testError() { - val res = evalFile(File("testData/error.kts")) + val res = evalFile(File("testData/error.simplescript.kts")) Assert.assertTrue( "test failed - expecting a failure with the message \"Unresolved reference: abracadabra\" but received " + diff --git a/libraries/examples/scripting/jvm-simple-script/host/testData/error.kts b/libraries/examples/scripting/jvm-simple-script/host/testData/error.simplescript.kts similarity index 100% rename from libraries/examples/scripting/jvm-simple-script/host/testData/error.kts rename to libraries/examples/scripting/jvm-simple-script/host/testData/error.simplescript.kts diff --git a/libraries/examples/scripting/jvm-simple-script/host/testData/hello.kts b/libraries/examples/scripting/jvm-simple-script/host/testData/hello.simplescript.kts similarity index 100% rename from libraries/examples/scripting/jvm-simple-script/host/testData/hello.kts rename to libraries/examples/scripting/jvm-simple-script/host/testData/hello.simplescript.kts diff --git a/libraries/examples/scripting/jvm-simple-script/script/src/org/jetbrains/kotlin/script/examples/jvm/simple/scriptDef.kt b/libraries/examples/scripting/jvm-simple-script/script/src/org/jetbrains/kotlin/script/examples/jvm/simple/scriptDef.kt index 9792bf84b40..5b62314265b 100644 --- a/libraries/examples/scripting/jvm-simple-script/script/src/org/jetbrains/kotlin/script/examples/jvm/simple/scriptDef.kt +++ b/libraries/examples/scripting/jvm-simple-script/script/src/org/jetbrains/kotlin/script/examples/jvm/simple/scriptDef.kt @@ -7,10 +7,12 @@ package org.jetbrains.kotlin.script.examples.jvm.simple import kotlin.script.experimental.annotations.KotlinScript import kotlin.script.experimental.annotations.KotlinScriptEvaluator +import kotlin.script.experimental.annotations.KotlinScriptFileExtension import kotlin.script.experimental.jvm.runners.BasicJvmScriptEvaluator @KotlinScript @KotlinScriptEvaluator(BasicJvmScriptEvaluator::class) +@KotlinScriptFileExtension("simplescript.kts") abstract class MyScript { // abstract fun body(vararg args: String): Int }