All Downloads are FREE. Search and download functionalities are using the official Maven repository.

kotlin.script.experimental.jvm.jvmScriptEvaluation.kt Maven / Gradle / Ivy

There is a newer version: 2.1.0-RC
Show newest version
/*
 * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
 */

@file:Suppress("unused")

package kotlin.script.experimental.jvm

import kotlin.reflect.KClass
import kotlin.script.experimental.api.EvaluationResult
import kotlin.script.experimental.api.ScriptEvaluationConfiguration
import kotlin.script.experimental.api.ScriptEvaluationConfigurationKeys
import kotlin.script.experimental.api.hostConfiguration
import kotlin.script.experimental.host.ScriptingHostConfiguration
import kotlin.script.experimental.util.PropertiesCollection

interface JvmScriptEvaluationConfigurationKeys

open class JvmScriptEvaluationConfigurationBuilder : PropertiesCollection.Builder(), JvmScriptEvaluationConfigurationKeys {

    companion object : JvmScriptEvaluationConfigurationBuilder()
}

/**
 * The base classloader to use for script classes loading
 */
val JvmScriptEvaluationConfigurationKeys.baseClassLoader by PropertiesCollection.key(
    {
        get(ScriptEvaluationConfiguration.hostConfiguration)?.get(ScriptingHostConfiguration.jvm.baseClassLoader)
            ?: Thread.currentThread().contextClassLoader
    },
    isTransient = true
)

/**
 * Classloader of the last snippet (supposed to be used in REPL)
 */
val JvmScriptEvaluationConfigurationKeys.lastSnippetClassLoader by PropertiesCollection.key(isTransient = true)

/**
 * Load script dependencies before evaluation, true by default
 * If false, it is assumed that the all dependencies will be provided via baseClassLoader
 */
val JvmScriptEvaluationConfigurationKeys.loadDependencies by PropertiesCollection.key(true)

/**
 * Arguments of the main call, if script is executed via its main method
 */
val JvmScriptEvaluationConfigurationKeys.mainArguments by PropertiesCollection.key>()

internal val JvmScriptEvaluationConfigurationKeys.actualClassLoader by PropertiesCollection.key(isTransient = true)

internal val JvmScriptEvaluationConfigurationKeys.scriptsInstancesSharingMap by PropertiesCollection.key, EvaluationResult>>(
    isTransient = true
)

val ScriptEvaluationConfigurationKeys.jvm get() = JvmScriptEvaluationConfigurationBuilder()




© 2015 - 2024 Weber Informatics LLC | Privacy Policy