Skip to content

Commit

Permalink
V0.1.4: Fix dependencies resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
LimeBeck committed Dec 19, 2023
1 parent 33c96f8 commit 21efe0e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 17 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion reveal-kt/script-definition/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -33,6 +31,7 @@ object RevealKtScriptCompilationConfiguration : ScriptCompilationConfiguration({
ide {
acceptedLocations(ScriptAcceptedLocation.Everywhere)
}
compilerOptions.append("-Xadd-modules=ALL-MODULE-PATH")

// Callbacks
refineConfiguration {
Expand All @@ -43,6 +42,7 @@ object RevealKtScriptCompilationConfiguration : ScriptCompilationConfiguration({

object RevealKtEvaluationConfiguration : ScriptEvaluationConfiguration({
scriptsInstancesSharing(false)
implicitReceivers(RevealKtBuilder())
})

// Handler that reconfigures the compilation on the fly
Expand Down
18 changes: 6 additions & 12 deletions reveal-kt/script-loader/src/main/kotlin/RevealKtScriptLoader.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,15 +43,8 @@ class RevealKtScriptLoader {
}

private fun BasicJvmScriptingHost.evalFile(scriptFile: File): ResultWithDiagnostics<EvaluationResult> {
val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<RevealKtScript> {
jvm {
dependenciesFromCurrentContext(wholeClasspath = true)
}
compilerOptions.append("-Xadd-modules=ALL-MODULE-PATH")
}
val evaluationConfiguration = createJvmEvaluationConfigurationFromTemplate<RevealKtScript> {
implicitReceivers(RevealKtBuilder())
}
val compilationConfiguration = createJvmCompilationConfigurationFromTemplate<RevealKtScript> { }
val evaluationConfiguration = createJvmEvaluationConfigurationFromTemplate<RevealKtScript> { }
return eval(
script = scriptFile.toScriptSource(),
compilationConfiguration = compilationConfiguration,
Expand Down

0 comments on commit 21efe0e

Please sign in to comment.