diff --git a/gradle.properties b/gradle.properties index 4e521f8..4aa8652 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ yarn.ignoreScripts = false kotlinVersion=1.9.20 -revealKtVersion=0.1.3 +revealKtVersion=0.1.4 kotlinCoroutinesVersion=1.7.3 ktorVersion=2.1.3 diff --git a/reveal-kt/script-definition/build.gradle.kts b/reveal-kt/script-definition/build.gradle.kts index 5adac03..581f24e 100644 --- a/reveal-kt/script-definition/build.gradle.kts +++ b/reveal-kt/script-definition/build.gradle.kts @@ -30,7 +30,7 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-scripting-common:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-scripting-jvm:$kotlinVersion") implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies:$kotlinVersion") - implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies-maven:$kotlinVersion") + implementation("org.jetbrains.kotlin:kotlin-scripting-dependencies-maven-all:$kotlinVersion") implementation(project(":reveal-kt:lib-dsl")) } diff --git a/reveal-kt/script-definition/src/main/kotlin/dev/limebeck/revealkt/scripts/scriptDef.kt b/reveal-kt/script-definition/src/main/kotlin/dev/limebeck/revealkt/scripts/scriptDef.kt index 47f030f..d7a7c70 100644 --- a/reveal-kt/script-definition/src/main/kotlin/dev/limebeck/revealkt/scripts/scriptDef.kt +++ b/reveal-kt/script-definition/src/main/kotlin/dev/limebeck/revealkt/scripts/scriptDef.kt @@ -15,9 +15,7 @@ import kotlin.script.experimental.jvm.jvm compilationConfiguration = RevealKtScriptCompilationConfiguration::class, evaluationConfiguration = RevealKtEvaluationConfiguration::class, ) -abstract class RevealKtScript { - -} +abstract class RevealKtScript object RevealKtScriptCompilationConfiguration : ScriptCompilationConfiguration({ jvm { @@ -33,6 +31,7 @@ object RevealKtScriptCompilationConfiguration : ScriptCompilationConfiguration({ ide { acceptedLocations(ScriptAcceptedLocation.Everywhere) } + compilerOptions.append("-Xadd-modules=ALL-MODULE-PATH") // Callbacks refineConfiguration { @@ -43,6 +42,7 @@ object RevealKtScriptCompilationConfiguration : ScriptCompilationConfiguration({ object RevealKtEvaluationConfiguration : ScriptEvaluationConfiguration({ scriptsInstancesSharing(false) + implicitReceivers(RevealKtBuilder()) }) // Handler that reconfigures the compilation on the fly diff --git a/reveal-kt/script-loader/src/main/kotlin/RevealKtScriptLoader.kt b/reveal-kt/script-loader/src/main/kotlin/RevealKtScriptLoader.kt index 9397bcd..d9bac54 100644 --- a/reveal-kt/script-loader/src/main/kotlin/RevealKtScriptLoader.kt +++ b/reveal-kt/script-loader/src/main/kotlin/RevealKtScriptLoader.kt @@ -2,10 +2,11 @@ package dev.limebeck.revealkt.scripts import dev.limebeck.revealkt.dsl.RevealKtBuilder import java.io.File -import kotlin.script.experimental.api.* +import kotlin.script.experimental.api.EvaluationResult +import kotlin.script.experimental.api.ResultWithDiagnostics +import kotlin.script.experimental.api.ScriptDiagnostic +import kotlin.script.experimental.api.valueOrNull import kotlin.script.experimental.host.toScriptSource -import kotlin.script.experimental.jvm.dependenciesFromCurrentContext -import kotlin.script.experimental.jvm.jvm import kotlin.script.experimental.jvmhost.BasicJvmScriptingHost import kotlin.script.experimental.jvmhost.createJvmCompilationConfigurationFromTemplate import kotlin.script.experimental.jvmhost.createJvmEvaluationConfigurationFromTemplate @@ -42,15 +43,8 @@ class RevealKtScriptLoader { } private fun BasicJvmScriptingHost.evalFile(scriptFile: File): ResultWithDiagnostics { - val compilationConfiguration = createJvmCompilationConfigurationFromTemplate { - jvm { - dependenciesFromCurrentContext(wholeClasspath = true) - } - compilerOptions.append("-Xadd-modules=ALL-MODULE-PATH") - } - val evaluationConfiguration = createJvmEvaluationConfigurationFromTemplate { - implicitReceivers(RevealKtBuilder()) - } + val compilationConfiguration = createJvmCompilationConfigurationFromTemplate { } + val evaluationConfiguration = createJvmEvaluationConfigurationFromTemplate { } return eval( script = scriptFile.toScriptSource(), compilationConfiguration = compilationConfiguration,