[Gradle] Rename -Xdepends-on to -Xfragment-refines and use ':' for -Xfragment-sources instead of ';'

^KT-56210 Verification Pending
This commit is contained in:
Sebastian Sellmair
2023-02-27 12:23:24 +01:00
committed by Space Team
parent a692de871b
commit b90207edb9
24 changed files with 96 additions and 90 deletions
@@ -15,10 +15,10 @@ internal object KotlinCompilationK2MultiplatformConfigurator : KotlinCompilation
if (compileTask.name != compilation.compileKotlinTaskName) return@configureEach
if (compileTask !is K2CompileTask) return@configureEach
compileTask.multiplatformStructure.dependsOnEdges.set(compilation.project.provider {
compileTask.multiplatformStructure.refinesEdges.set(compilation.project.provider {
compilation.allKotlinSourceSets.flatMap { sourceSet ->
sourceSet.dependsOn.map { dependsOn ->
K2MultiplatformStructure.DependsOnEdge(sourceSet.name, dependsOn.name)
K2MultiplatformStructure.RefinesEdge(sourceSet.name, dependsOn.name)
}
}
})
@@ -88,7 +88,7 @@ internal fun buildKotlinNativeKlibCompilerArgs(
if (sharedCompilationData == null) {
add("-Xfragments=${k2MultiplatformCompilationData.fragmentsCompilerArgs.joinToString(",")}")
add("-Xfragment-sources=${k2MultiplatformCompilationData.fragmentSourcesCompilerArgs.joinToString(",")}")
add("-Xdepends-on=${k2MultiplatformCompilationData.dependsOnCompilerArgs.joinToString(",")}")
add("-Xfragment-refines=${k2MultiplatformCompilationData.fragmentRefinesCompilerArgs.joinToString(",")}")
}
}
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.gradle.dsl.usesK2
abstract class K2MultiplatformStructure {
@InternalKotlinGradlePluginApi
data class DependsOnEdge(
data class RefinesEdge(
@Input
val fromFragmentName: String,
@Input
@@ -41,7 +41,7 @@ abstract class K2MultiplatformStructure {
)
@get:Nested
abstract val dependsOnEdges: SetProperty<DependsOnEdge>
abstract val refinesEdges: SetProperty<RefinesEdge>
@get:Nested
abstract val fragments: ListProperty<Fragment>
@@ -52,18 +52,18 @@ internal val K2MultiplatformStructure.fragmentsCompilerArgs: Array<String>
internal val K2MultiplatformStructure.fragmentSourcesCompilerArgs: Array<String>
get() = fragments.get().flatMap { sourceSet ->
sourceSet.sources.files.map { sourceFile -> "${sourceSet.fragmentName};${sourceFile.absolutePath}" }
sourceSet.sources.files.map { sourceFile -> "${sourceSet.fragmentName}:${sourceFile.absolutePath}" }
}.toTypedArray()
internal val K2MultiplatformStructure.dependsOnCompilerArgs: Array<String>
get() = dependsOnEdges.get().map { edge ->
internal val K2MultiplatformStructure.fragmentRefinesCompilerArgs: Array<String>
get() = refinesEdges.get().map { edge ->
"${edge.fromFragmentName}:${edge.toFragmentName}"
}.toTypedArray()
internal fun CommonCompilerArguments.configureK2Multiplatform(multiplatformStructure: K2MultiplatformStructure) {
fragments = multiplatformStructure.fragmentsCompilerArgs
fragmentSources = multiplatformStructure.fragmentSourcesCompilerArgs
dependsOnDependencies = multiplatformStructure.dependsOnCompilerArgs
fragmentRefines = multiplatformStructure.fragmentRefinesCompilerArgs
}
internal fun CommonCompilerArguments.configureMultiplatform(
@@ -20,7 +20,7 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation
import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR
import org.jetbrains.kotlin.gradle.tasks.K2CompileTask
import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure
import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure.DependsOnEdge
import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure.RefinesEdge
import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure.Fragment
import org.jetbrains.kotlin.gradle.tasks.KotlinNativeCompile
import org.jetbrains.kotlin.gradle.tasks.configureK2Multiplatform
@@ -43,7 +43,7 @@ class K2MultiplatformStructureTest {
@Test
fun `test - configureK2Multiplatform - then parse arguments`() {
val structure = project.objects.newInstance<K2MultiplatformStructure>()
structure.dependsOnEdges.set(listOf(DependsOnEdge("a", "b"), DependsOnEdge("b", "c")))
structure.refinesEdges.set(listOf(RefinesEdge("a", "b"), RefinesEdge("b", "c")))
structure.fragments.set(
listOf(
Fragment("a", project.files("a.kt")),
@@ -65,13 +65,13 @@ class K2MultiplatformStructureTest {
val fragmentSources = parsedArguments.fragmentSources ?: fail("Missing ${CommonCompilerArguments::fragmentSources.name}")
assertEquals(
listOf(
"a;${project.file("a.kt").absolutePath}",
"b;${project.file("b.kt").absolutePath}"
"a:${project.file("a.kt").absolutePath}",
"b:${project.file("b.kt").absolutePath}"
),
fragmentSources.toList()
)
val dependsOn = parsedArguments.dependsOnDependencies ?: fail("Missing ${CommonCompilerArguments::dependsOnDependencies.name}")
val dependsOn = parsedArguments.fragmentRefines ?: fail("Missing ${CommonCompilerArguments::fragmentRefines.name}")
assertEquals(listOf("a:b", "b:c"), dependsOn.toList())
}
@@ -116,11 +116,11 @@ class K2MultiplatformStructureTest {
/* check dependsOnEdges */
assertEquals(
setOf(
DependsOnEdge(defaultSourceSet.name, "commonMain"),
DependsOnEdge(defaultSourceSet.name, "intermediateMain"),
DependsOnEdge("intermediateMain", "commonMain")
RefinesEdge(defaultSourceSet.name, "commonMain"),
RefinesEdge(defaultSourceSet.name, "intermediateMain"),
RefinesEdge("intermediateMain", "commonMain")
),
compileTask.multiplatformStructure.dependsOnEdges.get().toSet()
compileTask.multiplatformStructure.refinesEdges.get().toSet()
)
/* check source files */
@@ -149,8 +149,8 @@ class K2MultiplatformStructureTest {
fail("Missing ${CommonCompilerArguments::fragmentSources.name} in K2 compilation")
}
if (args.dependsOnDependencies == null) {
fail("Missing ${CommonCompilerArguments::dependsOnDependencies.name} in K2 compilation")
if (args.fragmentRefines == null) {
fail("Missing ${CommonCompilerArguments::fragmentRefines.name} in K2 compilation")
}
}
}