Test scripting with Gradle

This commit is contained in:
Alexey Tsvetkov
2018-05-24 23:51:52 +03:00
parent 0b22a3c67b
commit 1085abedcd
9 changed files with 63 additions and 1 deletions
@@ -52,7 +52,9 @@ test.dependsOn(":kotlin-allopen:install",
":kotlin-test:kotlin-test-jvm:install",
":kotlin-gradle-subplugin-example:install",
":kotlin-stdlib-jre8:install",
":examples:annotation-processor-example:install")
":examples:annotation-processor-example:install",
":kotlin-scripting-common:install",
":kotlin-scripting-jvm:install")
// Validate that all dependencies 'install' tasks are added to 'test' dependencies
@@ -807,4 +807,14 @@ class KotlinGradleIT : BaseGradleIT() {
}
}
@Test
fun testScripting() {
Project("kotlinScripting").build("build") {
assertSuccessful()
assertCompiledKotlinSources(
listOf("app/src/main/kotlin/world.greet.kts", "script-template/src/main/kotlin/GreetScriptTemplate.kt")
)
assertFileExists("${kotlinClassesDir("app", "main")}World_greet.class")
}
}
}
@@ -0,0 +1,5 @@
apply plugin: 'kotlin'
dependencies {
compile project(':script-template')
}
@@ -0,0 +1,6 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
greet("World")
@@ -0,0 +1,16 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
mavenLocal()
mavenCentral()
}
}
@@ -0,0 +1,6 @@
apply plugin: 'kotlin'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile "org.jetbrains.kotlin:kotlin-scripting-common:$kotlin_version"
}
@@ -0,0 +1,16 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package org.jetbrains.kotlin.test
import kotlin.script.experimental.annotations.*
@KotlinScript
@KotlinScriptFileExtension("greet.kts")
abstract class GreetScriptTemplate {
fun greet(subject: String) {
println("Hello, $subject!")
}
}