Migrate SubpluginsIT to new test DSL
^KT-45745 In Progress
This commit is contained in:
@@ -63,6 +63,7 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
|
||||
":kotlin-stdlib-js",
|
||||
":kotlin-stdlib-wasm",
|
||||
":examples:annotation-processor-example",
|
||||
":kotlin-sam-with-receiver",
|
||||
":kotlin-script-runtime",
|
||||
":kotlin-scripting-common",
|
||||
":kotlin-scripting-jvm",
|
||||
@@ -72,7 +73,8 @@ val kotlinGradlePluginAndItsRequired = arrayOf(
|
||||
":kotlin-test-js-runner",
|
||||
":native:kotlin-klib-commonizer-embeddable",
|
||||
":native:kotlin-klib-commonizer-api",
|
||||
":native:kotlin-native-utils"
|
||||
":native:kotlin-native-utils",
|
||||
":kotlin-lombok"
|
||||
)
|
||||
|
||||
fun Task.dependsOnKotlinGradlePluginInstall() {
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'maven-publish'
|
||||
apply plugin: 'jps-compatible'
|
||||
import plugins.KotlinBuildPublishingPlugin
|
||||
|
||||
plugins {
|
||||
id("java-gradle-plugin")
|
||||
id("gradle-plugin-common-configuration")
|
||||
id("com.gradle.plugin-publish")
|
||||
id("jps-compatible")
|
||||
}
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
@@ -16,7 +21,7 @@ dependencies {
|
||||
// Use this dependency instead when building apart from the other modules:
|
||||
// compile "org.jetbrains.kotlin:kotlin-gradle-plugin-api:$kotlin_version"
|
||||
|
||||
api project(':kotlin-test::kotlin-test-junit')
|
||||
api project(':kotlin-test:kotlin-test-junit')
|
||||
|
||||
compileOnly kotlinStdlib()
|
||||
compileOnly project(':compiler')
|
||||
@@ -34,26 +39,40 @@ dependencies {
|
||||
ArtifactsKt.runtimeJar(project, EmbeddableKt.rewriteDefaultJarDepsToShadedCompiler(project, {}), {})
|
||||
// In a standalone build, you can setup the relocation with the Shadow plugin.
|
||||
|
||||
publishing {
|
||||
publications {
|
||||
main(MavenPublication) {
|
||||
artifact tasks.named("embeddable")
|
||||
// You should configure your own Gradle plugin publication!
|
||||
extensions.configure(GradlePluginDevelopmentExtension) {
|
||||
it.setAutomatedPublishing(false)
|
||||
}
|
||||
|
||||
gradlePlugin {
|
||||
plugins {
|
||||
create("gradle-subplugin-example") {
|
||||
id = "org.jetbrains.kotlin.gradle-subplugin-example"
|
||||
implementationClass = "example.ExampleSubplugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tasks.register("install") {
|
||||
dependsOn(tasks.named("publishToMavenLocal"))
|
||||
pluginBundle {
|
||||
plugins {
|
||||
named("gradle-subplugin-example") {
|
||||
id = "org.jetbrains.kotlin.gradle-subplugin-example"
|
||||
displayName = "Kotlin Gradle subplugin example"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// workaround for Gradle configuration cache
|
||||
// TODO: remove it when https://github.com/gradle/gradle/pull/16945 merged into used in build Gradle version
|
||||
tasks.withType(PublishToMavenLocal) {
|
||||
def originalTask = it
|
||||
def serializablePublishTask =
|
||||
tasks.register(originalTask.name + "Serializable", PublishToMavenLocalSerializable) {
|
||||
publication = originalTask.publication
|
||||
PluginMarkersKt.publishPluginMarkers(project, true)
|
||||
|
||||
// Disable releasing for this plugin
|
||||
// It is not intended to be released publicly
|
||||
tasks.withType(PublishToMavenRepository)
|
||||
.configureEach {
|
||||
if (it.name.endsWith("PublicationTo${KotlinBuildPublishingPlugin.REPOSITORY_NAME}Repository")) {
|
||||
setEnabled(false)
|
||||
}
|
||||
originalTask.onlyIf { false }
|
||||
originalTask.dependsOn(serializablePublishTask)
|
||||
}
|
||||
|
||||
tasks.named("publishPlugins") {
|
||||
enabled = false
|
||||
}
|
||||
|
||||
+100
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* 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.gradle
|
||||
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import org.junit.jupiter.api.condition.DisabledOnOs
|
||||
import org.junit.jupiter.api.condition.OS
|
||||
import kotlin.io.path.relativeTo
|
||||
|
||||
@DisabledOnOs(
|
||||
OS.WINDOWS,
|
||||
disabledReason = "Compiler plugin is leaking file descriptor preventing cleaning the project"
|
||||
)
|
||||
@DisplayName("Scripting plugin")
|
||||
@OtherGradlePluginTests
|
||||
class ScriptingIT : KGPBaseTest() {
|
||||
|
||||
@DisplayName("basic script is working")
|
||||
@GradleTest
|
||||
fun testScripting(gradleVersion: GradleVersion) {
|
||||
project("scripting", gradleVersion) {
|
||||
build("assemble", buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)) {
|
||||
assertCompiledKotlinSources(
|
||||
listOf(
|
||||
subProject("app").kotlinSourcesDir().resolve("world.greet.kts").relativeTo(projectPath),
|
||||
subProject("script-template").kotlinSourcesDir().resolve("GreetScriptTemplate.kt").relativeTo(projectPath)
|
||||
),
|
||||
output
|
||||
)
|
||||
assertFileExists(
|
||||
subProject("app").kotlinClassesDir().resolve("World_greet.class")
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("With custom file extension compiled non-incremental")
|
||||
@GradleTest
|
||||
fun testScriptingCustomExtensionNonIncremental(gradleVersion: GradleVersion) {
|
||||
testScriptingCustomExtensionImpl(gradleVersion, withIC = false)
|
||||
}
|
||||
|
||||
@DisplayName("With custom file extension compiled incremental")
|
||||
@GradleTest
|
||||
fun testScriptingCustomExtensionIncremental(gradleVersion: GradleVersion) {
|
||||
testScriptingCustomExtensionImpl(gradleVersion, withIC = true)
|
||||
}
|
||||
|
||||
private fun testScriptingCustomExtensionImpl(
|
||||
gradleVersion: GradleVersion,
|
||||
withIC: Boolean
|
||||
) {
|
||||
project(
|
||||
"scriptingCustomExtension",
|
||||
gradleVersion,
|
||||
buildOptions = defaultBuildOptions.copy(
|
||||
incremental = withIC,
|
||||
logLevel = if (withIC) LogLevel.DEBUG else defaultBuildOptions.logLevel
|
||||
)
|
||||
) {
|
||||
val appSubproject = subProject("app")
|
||||
val bobGreetSource = appSubproject.kotlinSourcesDir().resolve("bob.greet")
|
||||
val bobGreet = bobGreetSource.relativeTo(projectPath)
|
||||
val aliceGreet = appSubproject.kotlinSourcesDir().resolve("alice.greet").relativeTo(projectPath)
|
||||
val worldGreet = appSubproject.kotlinSourcesDir().resolve("world.greet").relativeTo(projectPath)
|
||||
val greetScriptTemplateKt = subProject("script-template")
|
||||
.kotlinSourcesDir()
|
||||
.resolve("GreetScriptTemplate.kt")
|
||||
.relativeTo(projectPath)
|
||||
|
||||
build("assemble") {
|
||||
val classesDir = appSubproject.kotlinClassesDir()
|
||||
assertFileExists(classesDir.resolve("World.class"))
|
||||
assertFileExists(classesDir.resolve("Alice.class"))
|
||||
assertFileExists(classesDir.resolve("Bob.class"))
|
||||
|
||||
if (withIC) {
|
||||
// compile iterations are not logged when IC is disabled
|
||||
assertCompiledKotlinSources(
|
||||
listOf(bobGreet, aliceGreet, worldGreet, greetScriptTemplateKt),
|
||||
output
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
bobGreetSource.modify { it.replace("Bob", "Uncle Bob") }
|
||||
build("assemble") {
|
||||
if (withIC) {
|
||||
assertCompiledKotlinSources(listOf(bobGreet), output)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+201
-244
@@ -5,299 +5,256 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle
|
||||
|
||||
import org.gradle.api.logging.configuration.WarningMode
|
||||
import org.jetbrains.kotlin.gradle.util.AGPVersion
|
||||
import org.gradle.api.logging.LogLevel
|
||||
import org.gradle.util.GradleVersion
|
||||
import org.jetbrains.kotlin.gradle.testbase.*
|
||||
import org.jetbrains.kotlin.gradle.util.checkBytecodeContains
|
||||
import org.jetbrains.kotlin.gradle.util.modify
|
||||
import org.jetbrains.kotlin.test.util.KtTestUtil
|
||||
import org.junit.Test
|
||||
import java.io.File
|
||||
import kotlin.test.assertTrue
|
||||
import org.jetbrains.kotlin.test.util.JUnit4Assertions.assertTrue
|
||||
import org.junit.jupiter.api.DisplayName
|
||||
import kotlin.io.path.readText
|
||||
|
||||
class SubpluginsIT : BaseGradleIT() {
|
||||
@DisplayName("Other plugins tests")
|
||||
@OtherGradlePluginTests
|
||||
class SubpuginsIT : KGPBaseTest() {
|
||||
|
||||
override fun defaultBuildOptions(): BuildOptions {
|
||||
return super.defaultBuildOptions().copy(warningMode = WarningMode.Summary)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testGradleSubplugin() {
|
||||
val project = Project("kotlinGradleSubplugin")
|
||||
|
||||
project.build("compileKotlin", "build") {
|
||||
assertSuccessful()
|
||||
assertContains("ExampleSubplugin loaded")
|
||||
assertContains("ExampleLegacySubplugin loaded")
|
||||
assertContains("Project component registration: exampleValue")
|
||||
assertContains("Project component registration: exampleLegacyValue")
|
||||
assertTasksExecuted(":compileKotlin")
|
||||
}
|
||||
|
||||
project.build("compileKotlin", "build") {
|
||||
assertSuccessful()
|
||||
assertContains("ExampleSubplugin loaded")
|
||||
assertContains("ExampleLegacySubplugin loaded")
|
||||
assertNotContains("Project component registration: exampleValue")
|
||||
assertNotContains("Project component registration: exampleLegacyValue")
|
||||
assertTasksUpToDate(":compileKotlin")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAllOpenPlugin() {
|
||||
Project("allOpenSimple").build("build") {
|
||||
assertSuccessful()
|
||||
|
||||
val classesDir = File(project.projectDir, kotlinClassesDir())
|
||||
val openClass = File(classesDir, "test/OpenClass.class")
|
||||
val closedClass = File(classesDir, "test/ClosedClass.class")
|
||||
assertTrue(openClass.exists())
|
||||
assertTrue(closedClass.exists())
|
||||
|
||||
checkBytecodeContains(
|
||||
openClass,
|
||||
"public class test/OpenClass {",
|
||||
"public method()V"
|
||||
)
|
||||
|
||||
checkBytecodeContains(
|
||||
closedClass,
|
||||
"public final class test/ClosedClass {",
|
||||
"public final method()V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinSpringPlugin() {
|
||||
Project("allOpenSpring").build("build") {
|
||||
assertSuccessful()
|
||||
|
||||
val classesDir = File(project.projectDir, kotlinClassesDir())
|
||||
val openClass = File(classesDir, "test/OpenClass.class")
|
||||
val closedClass = File(classesDir, "test/ClosedClass.class")
|
||||
assertTrue(openClass.exists())
|
||||
assertTrue(closedClass.exists())
|
||||
|
||||
checkBytecodeContains(
|
||||
openClass,
|
||||
"public class test/OpenClass {",
|
||||
"public method()V"
|
||||
)
|
||||
|
||||
checkBytecodeContains(
|
||||
closedClass,
|
||||
"public final class test/ClosedClass {",
|
||||
"public final method()V"
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinJpaPlugin() {
|
||||
Project("noArgJpa").build("build") {
|
||||
assertSuccessful()
|
||||
|
||||
val classesDir = File(project.projectDir, kotlinClassesDir())
|
||||
|
||||
fun checkClass(name: String) {
|
||||
val testClass = File(classesDir, "test/$name.class")
|
||||
assertTrue(testClass.exists())
|
||||
checkBytecodeContains(testClass, "public <init>()V")
|
||||
@DisplayName("Subplugin example works as expected")
|
||||
@GradleTest
|
||||
fun testGradleSubplugin(gradleVersion: GradleVersion) {
|
||||
project("kotlinGradleSubplugin", gradleVersion) {
|
||||
build("compileKotlin", "build") {
|
||||
assertTasksExecuted(":compileKotlin")
|
||||
assertOutputContains("ExampleSubplugin loaded")
|
||||
assertOutputContains("ExampleLegacySubplugin loaded")
|
||||
assertOutputContains("Project component registration: exampleValue")
|
||||
assertOutputContains("Project component registration: exampleLegacyValue")
|
||||
}
|
||||
|
||||
checkClass("Test")
|
||||
checkClass("Test2")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testNoArgKt18668() {
|
||||
Project("noArgKt18668").build("build") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSamWithReceiverSimple() {
|
||||
Project("samWithReceiverSimple").build("build") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScripting() {
|
||||
Project("scripting").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")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScriptingCustomExtensionNonIncremental() {
|
||||
testScriptingCustomExtensionImpl(withIC = false)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testScriptingCustomExtensionIncremental() {
|
||||
testScriptingCustomExtensionImpl(withIC = true)
|
||||
}
|
||||
|
||||
private fun testScriptingCustomExtensionImpl(withIC: Boolean) {
|
||||
val project = Project("scriptingCustomExtension")
|
||||
val options = defaultBuildOptions().copy(incremental = withIC)
|
||||
|
||||
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")
|
||||
|
||||
var isFailed = false
|
||||
project.build("build", options = options) {
|
||||
val classesDir = kotlinClassesDir("app", "main")
|
||||
assertSuccessful()
|
||||
assertFileExists("${classesDir}World.class")
|
||||
assertFileExists("${classesDir}Alice.class")
|
||||
assertFileExists("${classesDir}Bob.class")
|
||||
|
||||
if (withIC) {
|
||||
// compile iterations are not logged when IC is disabled
|
||||
assertCompiledKotlinSources(project.relativize(bobGreet, aliceGreet, worldGreet, greetScriptTemplateKt))
|
||||
build("compileKotlin", "build") {
|
||||
assertTasksUpToDate(":compileKotlin")
|
||||
assertOutputContains("ExampleSubplugin loaded")
|
||||
assertOutputContains("ExampleLegacySubplugin loaded")
|
||||
assertOutputDoesNotContain("Project component registration: exampleValue")
|
||||
assertOutputDoesNotContain("Project component registration: exampleLegacyValue")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!isFailed) {
|
||||
bobGreet.modify { it.replace("Bob", "Uncle Bob") }
|
||||
project.build("build", options = options) {
|
||||
assertSuccessful()
|
||||
@DisplayName("Allopen plugin opens classes and methods")
|
||||
@GradleTest
|
||||
fun testAllOpenPlugin(gradleVersion: GradleVersion) {
|
||||
project("allOpenSimple", gradleVersion) {
|
||||
build("assemble") {
|
||||
val classesDir = kotlinClassesDir()
|
||||
val openClass = classesDir.resolve("test/OpenClass.class")
|
||||
val closedClass = classesDir.resolve("test/ClosedClass.class")
|
||||
assertFileExists(openClass)
|
||||
assertFileExists(closedClass)
|
||||
|
||||
if (withIC) {
|
||||
assertCompiledKotlinSources(project.relativize(bobGreet))
|
||||
checkBytecodeContains(
|
||||
openClass.toFile(),
|
||||
"public class test/OpenClass {",
|
||||
"public method()V"
|
||||
)
|
||||
|
||||
checkBytecodeContains(
|
||||
closedClass.toFile(),
|
||||
"public final class test/ClosedClass {",
|
||||
"public final method()V"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Kotlin Spring plugin opens classes and methods")
|
||||
@GradleTest
|
||||
fun testKotlinSpringPlugin(gradleVersion: GradleVersion) {
|
||||
project("allOpenSpring", gradleVersion) {
|
||||
build("assemble") {
|
||||
|
||||
val classesDir = kotlinClassesDir()
|
||||
val openClass = classesDir.resolve("test/OpenClass.class")
|
||||
val closedClass = classesDir.resolve("test/ClosedClass.class")
|
||||
|
||||
assertFileExists(openClass)
|
||||
assertFileExists(closedClass)
|
||||
|
||||
checkBytecodeContains(
|
||||
openClass.toFile(),
|
||||
"public class test/OpenClass {",
|
||||
"public method()V"
|
||||
)
|
||||
|
||||
checkBytecodeContains(
|
||||
closedClass.toFile(),
|
||||
"public final class test/ClosedClass {",
|
||||
"public final method()V"
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("Jpa plugin generates no-arg constructor")
|
||||
@GradleTest
|
||||
fun testKotlinJpaPlugin(gradleVersion: GradleVersion) {
|
||||
project("noArgJpa", gradleVersion) {
|
||||
build("assemble") {
|
||||
val classesDir = kotlinClassesDir()
|
||||
|
||||
fun checkClass(name: String) {
|
||||
val testClass = classesDir.resolve("test/$name.class")
|
||||
assertFileExists(testClass)
|
||||
checkBytecodeContains(testClass.toFile(), "public <init>()V")
|
||||
}
|
||||
|
||||
checkClass("Test")
|
||||
checkClass("Test2")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAllOpenFromNestedBuildscript() {
|
||||
Project("allOpenFromNestedBuildscript").build("build") {
|
||||
assertSuccessful()
|
||||
assertFileExists("${kotlinClassesDir(subproject = "a/b", sourceSet = "main")}MyClass.class")
|
||||
assertFileExists("${kotlinClassesDir(subproject = "a/b", sourceSet = "test")}MyTestClass.class")
|
||||
@DisplayName("NoArg: Don't invoke initializers by default")
|
||||
@GradleTest
|
||||
fun testNoArgKt18668(gradleVersion: GradleVersion) {
|
||||
project("noArgKt18668", gradleVersion) {
|
||||
build("assemble")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testAllopenFromScript() {
|
||||
Project("allOpenFromScript").build("build") {
|
||||
assertSuccessful()
|
||||
assertFileExists("${kotlinClassesDir(sourceSet = "main")}MyClass.class")
|
||||
assertFileExists("${kotlinClassesDir(sourceSet = "test")}MyTestClass.class")
|
||||
@DisplayName("sam-with-receiver works")
|
||||
@GradleTest
|
||||
fun testSamWithReceiverSimple(gradleVersion: GradleVersion) {
|
||||
project("samWithReceiverSimple", gradleVersion) {
|
||||
build("assemble")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinVersionDowngradeInSupbrojectKt39809() = with(
|
||||
Project(
|
||||
"android-dagger",
|
||||
directoryPrefix = "kapt2"
|
||||
)
|
||||
) {
|
||||
setupWorkingDir()
|
||||
@DisplayName("Allopen plugin works when classpath dependency is not declared in current or root project ")
|
||||
@GradleTest
|
||||
fun testAllOpenFromNestedBuildscript(gradleVersion: GradleVersion) {
|
||||
project("allOpenFromNestedBuildscript", gradleVersion) {
|
||||
build("build") {
|
||||
val nestedSubproject = subProject("a/b")
|
||||
assertFileExists(nestedSubproject.kotlinClassesDir().resolve("MyClass.class"))
|
||||
assertFileExists(nestedSubproject.kotlinClassesDir("test").resolve("MyTestClass.class"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
gradleBuildScript("app").modify {
|
||||
"""
|
||||
@DisplayName("Allopen applied from script works")
|
||||
@GradleTest
|
||||
fun testAllopenFromScript(gradleVersion: GradleVersion) {
|
||||
project("allOpenFromScript", gradleVersion) {
|
||||
build("build") {
|
||||
assertFileExists(kotlinClassesDir().resolve("MyClass.class"))
|
||||
assertFileExists(kotlinClassesDir(sourceSet = "test").resolve("MyTestClass.class"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-39809: kapt subplugin legacy loading does not fail the build")
|
||||
@GradleTest
|
||||
fun testKotlinVersionDowngradeInSupbrojectKt39809(gradleVersion: GradleVersion) {
|
||||
project("kapt2/android-dagger", gradleVersion) {
|
||||
subProject("app").buildGradle.modify {
|
||||
"""
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.72")
|
||||
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${TestVersions.Kotlin.STABLE_RELEASE}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$it
|
||||
""".trimIndent()
|
||||
}
|
||||
build(
|
||||
":app:compileDebugKotlin",
|
||||
options = defaultBuildOptions().copy(
|
||||
androidGradlePluginVersion = AGPVersion.v4_2_0,
|
||||
androidHome = KtTestUtil.findAndroidSdk()
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
build(
|
||||
":app:compileDebugKotlin",
|
||||
buildOptions = defaultBuildOptions.copy(
|
||||
androidVersion = TestVersions.AGP.AGP_42
|
||||
)
|
||||
)
|
||||
) {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKotlinVersionDowngradeWithNewerSubpluginsKt39809() = with(Project("multiprojectWithDependency")) {
|
||||
setupWorkingDir()
|
||||
@DisplayName("KT-39809: subplugins legacy loading does not fail the build")
|
||||
@GradleTest
|
||||
fun testKotlinVersionDowngradeWithNewerSubpluginsKt39809(gradleVersion: GradleVersion) {
|
||||
project("multiprojectWithDependency", gradleVersion) {
|
||||
|
||||
val subprojectBuildGradle = projectDir.resolve("projA/build.gradle")
|
||||
val originalScript = subprojectBuildGradle.readText()
|
||||
val projectA = subProject("projA")
|
||||
val subprojectBuildGradle = projectA.buildGradle
|
||||
val originalScript = subprojectBuildGradle.readText()
|
||||
|
||||
listOf("allopen", "noarg", "sam-with-receiver", "serialization").forEach { plugin ->
|
||||
projectDir.resolve("projA/build.gradle").modify {
|
||||
"""
|
||||
listOf("allopen", "noarg", "sam-with-receiver", "serialization").forEach { plugin ->
|
||||
subprojectBuildGradle.modify {
|
||||
"""
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-$plugin:${defaultBuildOptions().kotlinVersion}")
|
||||
classpath("org.jetbrains.kotlin:kotlin-$plugin:${defaultBuildOptions.kotlinVersion}")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
apply plugin: "org.jetbrains.kotlin.plugin.${plugin.replace("-", ".")}"
|
||||
|
||||
|
||||
$originalScript
|
||||
""".trimIndent()
|
||||
}
|
||||
build(":projA:compileKotlin", options = defaultBuildOptions().copy(kotlinVersion = "1.3.72")) {
|
||||
assertFailed()
|
||||
assertContains(
|
||||
"This version of the kotlin-$plugin Gradle plugin is built for a newer Kotlin version. " +
|
||||
"Please use an older version of kotlin-$plugin or upgrade the Kotlin Gradle plugin version to make them match."
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLombokPlugin() {
|
||||
Project("lombokProject").build("build") {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Test // KT-47921
|
||||
fun testSerializationPluginOrderedFirst() = with(Project("allOpenSimple")) {
|
||||
setupWorkingDir()
|
||||
// Ensure that there are also allopen, noarg, and serialization plugins applied:
|
||||
gradleBuildScript().appendText(
|
||||
"""
|
||||
buildscript {
|
||||
dependencies {
|
||||
classpath("org.jetbrains.kotlin:kotlin-noarg:${defaultBuildOptions().kotlinVersion}")
|
||||
classpath("org.jetbrains.kotlin:kotlin-serialization:${defaultBuildOptions().kotlinVersion}")
|
||||
buildAndFail(
|
||||
":projA:compileKotlin",
|
||||
buildOptions = defaultBuildOptions.copy(kotlinVersion = "1.3.72")
|
||||
) {
|
||||
assertOutputContains(
|
||||
"This version of the kotlin-$plugin Gradle plugin is built for a newer Kotlin version. " +
|
||||
"Please use an older version of kotlin-$plugin or upgrade the Kotlin Gradle plugin version to make them match."
|
||||
)
|
||||
}
|
||||
}
|
||||
apply plugin: "org.jetbrains.kotlin.plugin.noarg"
|
||||
apply plugin: "org.jetbrains.kotlin.plugin.serialization"
|
||||
""".trimIndent()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
build("compileKotlin") {
|
||||
assertSuccessful()
|
||||
val xPlugin = output.split(" ").single { it.startsWith("-Xplugin") }.substringAfter("-Xplugin").split(",")
|
||||
assertTrue("Expected serialization plugin to go first; actual order: $xPlugin") { xPlugin.first().contains("serialization") }
|
||||
@DisplayName("Lombok plugin is working")
|
||||
@GradleTest
|
||||
fun testLombokPlugin(gradleVersion: GradleVersion) {
|
||||
project("lombokProject", gradleVersion) {
|
||||
build("build")
|
||||
}
|
||||
}
|
||||
|
||||
@DisplayName("KT-47921: serialization plugin passed first to the compiler")
|
||||
@GradleTest
|
||||
fun testSerializationPluginOrderedFirst(gradleVersion: GradleVersion) {
|
||||
project("allOpenSimple", gradleVersion) {
|
||||
// Ensure that there are also allopen, noarg, and serialization plugins applied:
|
||||
buildGradle.modify {
|
||||
"""
|
||||
|plugins {
|
||||
| id "org.jetbrains.kotlin.plugin.noarg"
|
||||
| id "org.jetbrains.kotlin.plugin.serialization"
|
||||
|${it.substringAfter("plugins {")}
|
||||
""".trimMargin()
|
||||
}
|
||||
|
||||
build(
|
||||
"compileKotlin",
|
||||
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG)
|
||||
) {
|
||||
val xPlugin = output
|
||||
.split(" ")
|
||||
.single { it.startsWith("-Xplugin") }
|
||||
.substringAfter("-Xplugin")
|
||||
.split(",")
|
||||
assertTrue(xPlugin.first().contains("serialization")) {
|
||||
"Expected serialization plugin to go first; actual order: $xPlugin"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+18
@@ -26,7 +26,13 @@ internal val DEFAULT_GROOVY_SETTINGS_FILE =
|
||||
id "org.jetbrains.kotlin.multiplatform" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.multiplatform.pm20" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.allopen" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.spring" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.jpa" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.noarg" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.lombok" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.plugin.serialization" version "${'$'}kotlin_version"
|
||||
id "org.jetbrains.kotlin.test.fixes.android" version "${'$'}test_fixes_version"
|
||||
id "org.jetbrains.kotlin.gradle-subplugin-example" version "${'$'}kotlin_version"
|
||||
}
|
||||
|
||||
resolutionStrategy {
|
||||
@@ -48,6 +54,10 @@ internal val DEFAULT_GROOVY_SETTINGS_FILE =
|
||||
break
|
||||
case "kotlin2js":
|
||||
useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${'$'}kotlin_version")
|
||||
break
|
||||
case "org.jetbrains.kotlin.plugin.sam.with.receiver":
|
||||
useModule("org.jetbrains.kotlin:kotlin-sam-with-receiver:${'$'}kotlin_version")
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -76,7 +86,13 @@ internal val DEFAULT_KOTLIN_SETTINGS_FILE =
|
||||
id("org.jetbrains.kotlin.multiplatform") version kotlin_version
|
||||
id("org.jetbrains.kotlin.multiplatform.pm20") version kotlin_version
|
||||
id("org.jetbrains.kotlin.plugin.allopen") version kotlin_version
|
||||
id("org.jetbrains.kotlin.plugin.spring") version kotlin_version
|
||||
id("org.jetbrains.kotlin.plugin.jpa") version kotlin_version
|
||||
id("org.jetbrains.kotlin.plugin.noarg") version kotlin_version
|
||||
id("org.jetbrains.kotlin.plugin.lombok") version kotlin_version
|
||||
id("org.jetbrains.kotlin.plugin.serialization") version kotlin_version
|
||||
id("org.jetbrains.kotlin.test.fixes.android") version test_fixes_version
|
||||
id("org.jetbrains.kotlin.gradle-subplugin-example") version kotlin_version
|
||||
}
|
||||
|
||||
resolutionStrategy {
|
||||
@@ -93,6 +109,8 @@ internal val DEFAULT_KOTLIN_SETTINGS_FILE =
|
||||
"com.android.feature" -> useModule("com.android.tools.build:gradle:${'$'}android_tools_version")
|
||||
"kotlin-dce-js" -> useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${'$'}kotlin_version")
|
||||
"kotlin2js" -> useModule("org.jetbrains.kotlin:kotlin-gradle-plugin:${'$'}kotlin_version")
|
||||
"org.jetbrains.kotlin.plugin.sam.with.receiver" ->
|
||||
useModule("org.jetbrains.kotlin:kotlin-sam-with-receiver:${'$'}kotlin_version")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-16
@@ -1,17 +1,8 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
id "org.jetbrains.kotlin.plugin.allopen"
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "kotlin-allopen"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
@@ -24,7 +15,3 @@ sourceSets {
|
||||
allOpen {
|
||||
annotation("lib.AllOpen")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
+3
-16
@@ -1,17 +1,8 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-allopen:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
id "org.jetbrains.kotlin.plugin.spring"
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "kotlin-spring"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
@@ -20,7 +11,3 @@ repositories {
|
||||
sourceSets {
|
||||
main.kotlin.srcDir 'src'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
+3
-16
@@ -1,22 +1,9 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-subplugin-example:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id("org.jetbrains.kotlin.jvm")
|
||||
id("org.jetbrains.kotlin.gradle-subplugin-example")
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "kotlin-example-subplugin"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
|
||||
-12
@@ -1,15 +1,3 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-lombok:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
+2
-10
@@ -1,14 +1,6 @@
|
||||
plugins {
|
||||
id "java"
|
||||
id "kotlin"
|
||||
id "kotlin-lombok"
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
id "org.jetbrains.kotlin.plugin.lombok"
|
||||
id "io.freefair.lombok" version "5.3.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+3
-9
@@ -1,14 +1,12 @@
|
||||
plugins {
|
||||
id "java"
|
||||
id "kotlin"
|
||||
id "kotlin-kapt"
|
||||
id "kotlin-lombok"
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
id "org.jetbrains.kotlin.kapt"
|
||||
id "org.jetbrains.kotlin.plugin.lombok"
|
||||
id "io.freefair.lombok" version "5.3.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
kapt "com.google.dagger:dagger-compiler:2.33"
|
||||
}
|
||||
|
||||
@@ -19,7 +17,3 @@ kapt {
|
||||
kotlinLombok {
|
||||
lombokConfigurationFile file("lombok.config")
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+3
-9
@@ -1,21 +1,15 @@
|
||||
plugins {
|
||||
id "java"
|
||||
id "kotlin"
|
||||
id "kotlin-kapt"
|
||||
id "kotlin-lombok"
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
id "org.jetbrains.kotlin.kapt"
|
||||
id "org.jetbrains.kotlin.plugin.lombok"
|
||||
id "io.freefair.lombok" version "5.3.0"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
kapt "com.google.dagger:dagger-compiler:2.33"
|
||||
}
|
||||
|
||||
kapt {
|
||||
keepJavacAnnotationProcessors = true
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+3
-16
@@ -1,17 +1,8 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
id "org.jetbrains.kotlin.plugin.jpa"
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "kotlin-jpa"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
@@ -20,7 +11,3 @@ repositories {
|
||||
sourceSets {
|
||||
main.kotlin.srcDir 'src'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
+3
-16
@@ -1,17 +1,8 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-noarg:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
id "org.jetbrains.kotlin.plugin.noarg"
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "kotlin-noarg"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
@@ -24,7 +15,3 @@ noArg {
|
||||
sourceSets {
|
||||
main.kotlin.srcDir 'src'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
+3
-16
@@ -1,17 +1,8 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
classpath "org.jetbrains.kotlin:kotlin-sam-with-receiver:$kotlin_version"
|
||||
}
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
id "org.jetbrains.kotlin.plugin.sam.with.receiver"
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "kotlin-sam-with-receiver"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
@@ -24,7 +15,3 @@ sourceSets {
|
||||
samWithReceiver {
|
||||
annotation("lib.SamWithReceiver")
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
apply plugin: 'kotlin'
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':script-template')
|
||||
|
||||
-10
@@ -1,13 +1,3 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
apply plugin: 'kotlin'
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
apply plugin: 'kotlin'
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation project(':script-template')
|
||||
|
||||
-10
@@ -1,13 +1,3 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
apply plugin: 'kotlin'
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
|
||||
Reference in New Issue
Block a user