Move property with template to script definition interface
This commit is contained in:
+7
@@ -27,10 +27,17 @@ import org.jetbrains.kotlin.utils.KotlinPathsFromHomeDir
|
||||
import org.jetbrains.kotlin.utils.PathUtil
|
||||
import java.io.File
|
||||
import java.util.concurrent.Future
|
||||
import kotlin.reflect.KClass
|
||||
import kotlin.script.StandardScriptTemplate
|
||||
|
||||
|
||||
data class KotlinConfigurableScriptDefinition(val config: KotlinScriptConfig, val environmentVars: Map<String, List<String>>?) : KotlinScriptDefinition {
|
||||
override val name = config.name
|
||||
|
||||
// This is a temporary workaround: this class will be removed later
|
||||
override val template: KClass<out Any>
|
||||
get() = StandardScriptTemplate::class
|
||||
|
||||
override fun getScriptParameters(scriptDescriptor: ScriptDescriptor): List<ScriptParameter> =
|
||||
config.parameters.map { ScriptParameter(Name.identifier(it.name), getKotlinTypeByFqName(scriptDescriptor, it.type)) }
|
||||
|
||||
|
||||
@@ -43,6 +43,8 @@ import kotlin.script.StandardScriptTemplate
|
||||
interface KotlinScriptDefinition {
|
||||
val name: String get() = "Kotlin Script"
|
||||
|
||||
val template: KClass<out Any>
|
||||
|
||||
// TODO: consider creating separate type (subtype? for kotlin scripts)
|
||||
val fileType: LanguageFileType get() = KotlinFileType.INSTANCE
|
||||
|
||||
|
||||
@@ -81,6 +81,9 @@ data class KotlinScriptConfig(
|
||||
@Tag("files")
|
||||
var fileNameMatch: String = ".*\\.kts",
|
||||
|
||||
@Tag("template")
|
||||
var template: String = "kotlin.script.StandardScriptTemplate",
|
||||
|
||||
@Tag("classpath")
|
||||
@AbstractCollection(surroundWithTag = false, elementTag = "path", elementValueAttribute = "")
|
||||
var classpath: MutableList<String> = ArrayList(),
|
||||
|
||||
@@ -35,7 +35,7 @@ import kotlin.reflect.KClass
|
||||
import kotlin.reflect.memberFunctions
|
||||
import kotlin.reflect.primaryConstructor
|
||||
|
||||
open class KotlinScriptDefinitionFromTemplate(val template: KClass<out Any>,
|
||||
open class KotlinScriptDefinitionFromTemplate(final override val template: KClass<out Any>,
|
||||
val resolver: ScriptDependenciesResolver? = null,
|
||||
val scriptFilePattern: String? = null,
|
||||
val environment: Map<String, Any?>? = null
|
||||
|
||||
Reference in New Issue
Block a user