[Gradle] Fix JVM and Android targets moduleName change is not propagated in the multiplatform project
Missed existing logic where 'moduleName' was specifically configured from 'moduleName' task input for MPP projects. ^KT-61303 Fixed
This commit is contained in:
committed by
Space Team
parent
c095b60fe8
commit
4c60dd3f38
+38
@@ -554,4 +554,42 @@ class CompilerOptionsProjectIT : KGPBaseTest() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DisplayName("KT-61303: Multiplatform/Android module name is changed")
|
||||||
|
@AndroidGradlePluginTests
|
||||||
|
@GradleAndroidTest
|
||||||
|
fun mppAndroidModuleNameCompilerOptionsDsl(
|
||||||
|
gradleVersion: GradleVersion,
|
||||||
|
agpVersion: String,
|
||||||
|
jdk: JdkVersions.ProvidedJdk
|
||||||
|
) {
|
||||||
|
project(
|
||||||
|
projectName = "multiplatformAndroidSourceSetLayout2",
|
||||||
|
gradleVersion = gradleVersion,
|
||||||
|
buildOptions = defaultBuildOptions.copy(logLevel = LogLevel.DEBUG , androidVersion = agpVersion),
|
||||||
|
buildJdk = jdk.location
|
||||||
|
) {
|
||||||
|
buildGradleKts.appendText(
|
||||||
|
//language=Groovy
|
||||||
|
"""
|
||||||
|
|
|
||||||
|
|kotlin {
|
||||||
|
| androidTarget {
|
||||||
|
| compilerOptions {
|
||||||
|
| moduleName.set("my-custom-module")
|
||||||
|
| }
|
||||||
|
| }
|
||||||
|
|}
|
||||||
|
|
|
||||||
|
""".trimMargin()
|
||||||
|
)
|
||||||
|
|
||||||
|
build(":compileGermanFreeDebugKotlinAndroid") {
|
||||||
|
assertCompilerArguments(
|
||||||
|
":compileGermanFreeDebugKotlinAndroid",
|
||||||
|
"-module-name my-custom-module_germanFreeDebug"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+1
-6
@@ -110,12 +110,7 @@ internal open class BaseKotlinCompileConfig<TASK : KotlinCompile> : AbstractKotl
|
|||||||
task.parentKotlinOptions.orNull?.moduleName ?: compilationInfo.moduleName
|
task.parentKotlinOptions.orNull?.moduleName ?: compilationInfo.moduleName
|
||||||
})
|
})
|
||||||
|
|
||||||
// In case of 'org.jetbrains.kotlin.jvm' and 'org.jetbrains.kotlin.android' plugins module name will be pre-configured
|
task.nagTaskModuleNameUsage.value(true).disallowChanges()
|
||||||
if (ext !is KotlinJvmProjectExtension && ext !is KotlinAndroidProjectExtension) {
|
|
||||||
task.compilerOptions.moduleName.convention(providers.provider { compilationInfo.moduleName })
|
|
||||||
} else {
|
|
||||||
task.nagTaskModuleNameUsage.set(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+14
@@ -308,6 +308,20 @@ class ProjectCompilerOptionsTests {
|
|||||||
assertEquals("2.0", project.multiplatformExtension.sourceSets.getByName("commonTest").languageSettings.languageVersion)
|
assertEquals("2.0", project.multiplatformExtension.sourceSets.getByName("commonTest").languageSettings.languageVersion)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testJvmModuleNameInMppIsConfigured() {
|
||||||
|
val project = buildProjectWithMPP()
|
||||||
|
project.runLifecycleAwareTest {
|
||||||
|
with(multiplatformExtension) {
|
||||||
|
jvm {
|
||||||
|
compilerOptions.moduleName.set("my-custom-module-name")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals("my-custom-module-name", project.kotlinJvmTask("compileKotlinJvm").compilerOptions.moduleName.orNull)
|
||||||
|
}
|
||||||
|
|
||||||
private fun Project.kotlinNativeTask(name: String): KotlinCompilationTask<KotlinNativeCompilerOptions> = tasks
|
private fun Project.kotlinNativeTask(name: String): KotlinCompilationTask<KotlinNativeCompilerOptions> = tasks
|
||||||
.named<KotlinCompilationTask<KotlinNativeCompilerOptions>>(name)
|
.named<KotlinCompilationTask<KotlinNativeCompilerOptions>>(name)
|
||||||
.get()
|
.get()
|
||||||
|
|||||||
Reference in New Issue
Block a user