Test scripting with Gradle
This commit is contained in:
@@ -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
|
||||
|
||||
+10
@@ -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")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
dependencies {
|
||||
compile project(':script-template')
|
||||
}
|
||||
+6
@@ -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")
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
}
|
||||
+6
@@ -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"
|
||||
}
|
||||
+16
@@ -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!")
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
include ':script-template', ':app'
|
||||
Reference in New Issue
Block a user