[Gradle] Fix test data using deprecated conventions
^KT-63369 Fixed
This commit is contained in:
committed by
Space Team
parent
c847d427d8
commit
cb64234192
+1
-1
@@ -1067,7 +1067,7 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
buildJdk = jdk.location
|
||||
) {
|
||||
buildGradle.append(
|
||||
"\nsourceCompatibility = '8'"
|
||||
"\njava.sourceCompatibility = JavaVersion.VERSION_1_8"
|
||||
)
|
||||
|
||||
// because Java sourceCompatibility is fixed JVM target will different with JDK 11 on Gradle 8
|
||||
|
||||
+8
-8
@@ -336,7 +336,7 @@ class KotlinGradleIT : KGPBaseTest() {
|
||||
fun testArchiveBaseNameForModuleName(gradleVersion: GradleVersion) {
|
||||
project("simpleProject", gradleVersion) {
|
||||
val archivesBaseName = "myArchivesBaseName"
|
||||
buildGradle.appendText("\narchivesBaseName = '$archivesBaseName'")
|
||||
addArchivesBaseNameCompat(archivesBaseName)
|
||||
|
||||
// Add top-level members to force generation of the *.kotlin_module files for the two source sets
|
||||
val mainHelloWorldKt = kotlinSourcesDir().resolve("helloWorld.kt")
|
||||
@@ -439,15 +439,15 @@ class KotlinGradleIT : KGPBaseTest() {
|
||||
@GradleTest
|
||||
fun testModuleNameFiltering(gradleVersion: GradleVersion) {
|
||||
project("typeAlias", gradleVersion) { // Use a Project with a top-level typealias
|
||||
addArchivesBaseNameCompat("""a/really\\trick\n\rmodule\tname""")
|
||||
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|
||||
archivesBaseName = 'a/really\\trick\n\rmodule\tname'
|
||||
|
||||
tasks.withType(Jar.class).configureEach {
|
||||
archiveBaseName.set('typeAlias')
|
||||
}
|
||||
""".trimIndent()
|
||||
|
|
||||
|tasks.withType(Jar.class).configureEach {
|
||||
| archiveBaseName.set('typeAlias')
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
|
||||
build("classes") {
|
||||
|
||||
+3
-1
@@ -421,7 +421,9 @@ open class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
mainClassName = 'com.example.lib.CommonKt'
|
||||
application {
|
||||
mainClass = 'com.example.lib.CommonKt'
|
||||
}
|
||||
|
||||
dependencies {
|
||||
jvm6MainImplementation("com.google.dagger:dagger:2.24")
|
||||
|
||||
+22
-1
@@ -51,7 +51,7 @@ class UpToDateIT : KGPBaseTest() {
|
||||
emptyMutation,
|
||||
OptionMutation("compileKotlin.kotlinOptions.jvmTarget", "'1.8'", "'11'"),
|
||||
OptionMutation("compileKotlin.kotlinOptions.freeCompilerArgs", "[]", "['-Xallow-kotlin-package']"),
|
||||
OptionMutation("archivesBaseName", "'someName'", "'otherName'"),
|
||||
archivesBaseNameOutputMutation("someName", "otherName"),
|
||||
subpluginOptionMutation,
|
||||
subpluginOptionMutationWithKapt,
|
||||
externalOutputMutation,
|
||||
@@ -223,6 +223,27 @@ class UpToDateIT : KGPBaseTest() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun archivesBaseNameOutputMutation(
|
||||
oldName: String,
|
||||
newName: String,
|
||||
) = object : ProjectMutation {
|
||||
override fun initProject(project: TestProject) {
|
||||
project.addArchivesBaseNameCompat(oldName)
|
||||
}
|
||||
|
||||
override fun mutateProject(project: TestProject) {
|
||||
project.buildGradle.modify {
|
||||
it.replace("archivesBaseName = '$oldName'", "archivesBaseName = '$newName'")
|
||||
}
|
||||
}
|
||||
|
||||
override fun checkAfterRebuild(buildResult: BuildResult) {
|
||||
buildResult.assertTasksExecuted(":compileKotlin")
|
||||
}
|
||||
|
||||
override val name: String = "archiveBaseNameOutputMutation"
|
||||
}
|
||||
|
||||
private interface ProjectMutation {
|
||||
fun initProject(project: TestProject)
|
||||
fun mutateProject(project: TestProject)
|
||||
|
||||
+27
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.testbase
|
||||
|
||||
import org.gradle.util.GradleVersion
|
||||
import java.nio.file.Paths
|
||||
import java.nio.file.attribute.PosixFilePermission
|
||||
import kotlin.io.path.*
|
||||
@@ -164,4 +165,30 @@ fun GradleProject.addPropertyToGradleProperties(
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures 'archivesBaseName' in Gradle older and newer versions compatible way avoiding
|
||||
* deprecation warnings.
|
||||
*/
|
||||
internal fun TestProject.addArchivesBaseNameCompat(
|
||||
archivesBaseName: String
|
||||
) {
|
||||
if (gradleVersion < GradleVersion.version(TestVersions.Gradle.G_7_1)) {
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|
|
||||
|archivesBaseName = '$archivesBaseName'
|
||||
""".trimMargin()
|
||||
)
|
||||
} else {
|
||||
buildGradle.appendText(
|
||||
"""
|
||||
|
|
||||
|base {
|
||||
| archivesBaseName = '$archivesBaseName'
|
||||
|}
|
||||
""".trimMargin()
|
||||
)
|
||||
}
|
||||
}
|
||||
-2
@@ -3,8 +3,6 @@ plugins {
|
||||
id 'org.jetbrains.kotlin.jvm'
|
||||
}
|
||||
|
||||
sourceCompatibility = 1.8
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
|
||||
+4
-1
@@ -21,4 +21,7 @@ kotlin {
|
||||
|
||||
// While this plugin seems not to do anything in this setup, IT IS needed to reproduce KT-29971
|
||||
plugins.apply("application")
|
||||
mainClassName = "foo"
|
||||
|
||||
application {
|
||||
mainClass = "foo"
|
||||
}
|
||||
+3
-1
@@ -12,4 +12,6 @@ dependencies {
|
||||
implementation 'com.example:sample-lib:1.0'
|
||||
}
|
||||
|
||||
mainClassName = 'A'
|
||||
application {
|
||||
mainClass = 'A'
|
||||
}
|
||||
+3
-1
@@ -5,4 +5,6 @@ dependencies {
|
||||
implementation 'com.example:sample-lib:1.0'
|
||||
}
|
||||
|
||||
mainClassName = 'com.example.app.JvmAppKt'
|
||||
application {
|
||||
mainClass = 'com.example.app.JvmAppKt'
|
||||
}
|
||||
Reference in New Issue
Block a user