Add test for IC of non-kts scripts in Gradle
This commit is contained in:
+29
-1
@@ -6,6 +6,7 @@
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import kotlin.test.assertTrue
|
||||
@@ -114,7 +115,7 @@ class SubpluginsIT : BaseGradleIT() {
|
||||
|
||||
@Test
|
||||
fun testScripting() {
|
||||
Project("kotlinScripting").build("build") {
|
||||
Project("scripting").build("build") {
|
||||
assertSuccessful()
|
||||
assertCompiledKotlinSources(
|
||||
listOf("app/src/main/kotlin/world.greet.kts", "script-template/src/main/kotlin/GreetScriptTemplate.kt")
|
||||
@@ -123,6 +124,33 @@ class SubpluginsIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScriptingCustomExtensionIncremental() {
|
||||
val project = Project("scriptingCustomExtension")
|
||||
val options = defaultBuildOptions().copy(incremental = true, kotlinDaemonDebugPort = null)
|
||||
|
||||
project.setupWorkingDir()
|
||||
val bobGreet = project.projectFile("bob.greet")
|
||||
val aliceGreet = project.projectFile("alice.greet")
|
||||
val worldGreet = project.projectFile("world.greet")
|
||||
val greetScriptTemplateKt = project.projectFile("GreetScriptTemplate.kt")
|
||||
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
assertCompiledKotlinSources(project.relativize(bobGreet, aliceGreet, worldGreet, greetScriptTemplateKt))
|
||||
val classesDir = kotlinClassesDir("app", "main")
|
||||
assertFileExists("${classesDir}World.class")
|
||||
assertFileExists("${classesDir}Alice.class")
|
||||
assertFileExists("${classesDir}Bob.class")
|
||||
}
|
||||
|
||||
bobGreet.modify { it.replace("Bob", "Uncle Bob") }
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
assertCompiledKotlinSources(project.relativize(bobGreet))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAllOpenFromNestedBuildscript() {
|
||||
Project("allOpenFromNestedBuildscript").build("build") {
|
||||
|
||||
+6
@@ -0,0 +1,6 @@
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
dependencies {
|
||||
compile project(':script-template')
|
||||
kotlinScriptDef 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("Alice")
|
||||
+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("Bob")
|
||||
+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"
|
||||
}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
/*
|
||||
* 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(fileExtension = "greet")
|
||||
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