Add tests for java-library support.
This commit is contained in:
+32
@@ -2,6 +2,7 @@ package org.jetbrains.kotlin.gradle
|
|||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
import org.jetbrains.kotlin.gradle.util.getFileByName
|
||||||
import org.jetbrains.kotlin.gradle.util.modify
|
import org.jetbrains.kotlin.gradle.util.modify
|
||||||
|
import org.junit.Assume
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
@@ -125,4 +126,35 @@ class KotlinGradlePluginMultiVersionIT : BaseMultiGradleVersionIT() {
|
|||||||
assertContains(":compileKotlin", ":compileTestKotlin")
|
assertContains(":compileKotlin", ":compileTestKotlin")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testJavaLibraryCompatibility() {
|
||||||
|
Assume.assumeTrue("The java-library plugin is supported only in Gradle 3.4+ (current: $gradleVersion)",
|
||||||
|
gradleVersion.split(".").map(String::toInt).let { (major, minor) ->
|
||||||
|
major > 3 || major == 3 && minor >= 4
|
||||||
|
})
|
||||||
|
|
||||||
|
val project = Project("javaLibraryProject", gradleVersion)
|
||||||
|
val compileKotlinTasks = listOf(":libA:compileKotlin", ":libB:compileKotlin", ":app:compileKotlin")
|
||||||
|
project.build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertNotContains("Could not register Kotlin output")
|
||||||
|
assertTasksExecuted(compileKotlinTasks)
|
||||||
|
}
|
||||||
|
|
||||||
|
// Modify a library source and its usage and re-build the project:
|
||||||
|
for (path in listOf("libA/src/main/kotlin/HelloA.kt", "libB/src/main/kotlin/HelloB.kt", "app/src/main/kotlin/App.kt")) {
|
||||||
|
File(project.projectDir, path).modify { original ->
|
||||||
|
original.replace("helloA", "helloA1")
|
||||||
|
.replace("helloB", "helloB1")
|
||||||
|
.apply { assert(!equals(original)) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
project.build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertNotContains("Could not register Kotlin output")
|
||||||
|
assertTasksExecuted(compileKotlinTasks)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
apply plugin: 'java'
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
compile project(':libB')
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
import com.example.*
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
println(helloA())
|
||||||
|
println(helloB())
|
||||||
|
}
|
||||||
+14
@@ -0,0 +1,14 @@
|
|||||||
|
buildscript {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
subprojects {
|
||||||
|
repositories {
|
||||||
|
mavenLocal()
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
apply plugin: 'java-library'
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package com.example
|
||||||
|
|
||||||
|
fun helloA() = "Hello"
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
apply plugin: 'java-library'
|
||||||
|
apply plugin: 'kotlin'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||||
|
api project(':libA')
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
package com.example
|
||||||
|
|
||||||
|
fun helloB() = helloA()
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
include ':libA', ':libB', ':app'
|
||||||
Reference in New Issue
Block a user