Commit 4b58682 Simon
committed
1 parent 76d0b4f commit 4b58682 Copy full SHA for 4b58682
File tree 3 files changed +9
-7
lines changed
main/kotlin/de/swirtz/ktsrunner/objectloader
test/kotlin/de/swirtz/ktsrunner/objectloader
3 files changed +9
-7
lines changed Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ import org.gradle.api.publish.maven.MavenPom
6
6
val kotlinVersion = plugins.getPlugin(KotlinPluginWrapper ::class .java).kotlinPluginVersion
7
7
8
8
project.group = " de.swirtz"
9
- project.version = " 0.0.5 "
9
+ project.version = " 0.0.6 "
10
10
val artifactID = " ktsRunner"
11
11
12
12
plugins {
13
- kotlin(" jvm" ) version " 1.2.51 "
13
+ kotlin(" jvm" ) version " 1.3.10 "
14
14
`maven- publish`
15
15
`java- library`
16
16
id(" com.jfrog.bintray" ) version " 1.8.0"
Original file line number Diff line number Diff line change @@ -4,11 +4,13 @@ import java.io.InputStream
4
4
import java.io.Reader
5
5
import javax.script.ScriptEngineManager
6
6
7
+ /* *
8
+ *
9
+ * This class is not thread-safe, don't use it for parallel executions and create new instances instead.
10
+ */
7
11
class KtsObjectLoader {
8
12
9
- companion object {
10
- val engine = ScriptEngineManager ().getEngineByExtension(" kts" )
11
- }
13
+ val engine = ScriptEngineManager ().getEngineByExtension(" kts" )
12
14
13
15
inline fun <reified T > load (script : String ): T = engine.eval(script).takeIf { it is T } as T
14
16
? : throw IllegalStateException (" Could not load script from .kts" )
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class KtsObjectLoaderTest {
14
14
15
15
@Test
16
16
fun `general ScriptEngineFactory test` () {
17
- KtsObjectLoader .engine.factory.apply {
17
+ KtsObjectLoader () .engine.factory.apply {
18
18
assertEquals(" kotlin" , languageName)
19
19
assertEquals(KotlinCompilerVersion .VERSION , languageVersion)
20
20
assertEquals(" kotlin" , engineName)
@@ -33,7 +33,7 @@ class KtsObjectLoaderTest {
33
33
34
34
@Test
35
35
fun `simple evaluations should work` () {
36
- with (KtsObjectLoader .engine as KotlinJsr223JvmLocalScriptEngine ) {
36
+ with (KtsObjectLoader () .engine as KotlinJsr223JvmLocalScriptEngine ) {
37
37
val res1 = eval(" val x = 3" )
38
38
assertNull(res1, " No returned value expected" )
39
39
val res2 = eval(" x + 2" )
You can’t perform that action at this time.
0 commit comments