[Gradle] Don't pass -Xfragment-sources for non-mpp compilations
It is unnecessary and confusing. ^KT-65768 Verification Pending
This commit is contained in:
committed by
Space Team
parent
fabf75f4e2
commit
0a86f03457
+7
-5
@@ -138,7 +138,7 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
||||
args.outputDir = destinationDirectory.get().asFile.normalize().absolutePath
|
||||
args.moduleName = compilerOptions.moduleName.get()
|
||||
|
||||
if (compilerOptions.usesK2.get()) {
|
||||
if (compilerOptions.usesK2.get() && multiPlatformEnabled.get()) {
|
||||
args.fragments = multiplatformStructure.fragmentsCompilerArgs
|
||||
args.fragmentRefines = multiplatformStructure.fragmentRefinesCompilerArgs
|
||||
}
|
||||
@@ -176,10 +176,12 @@ abstract class Kotlin2JsCompile @Inject constructor(
|
||||
args.sourceMapBaseDirs = sourceMapBaseDir.get().asFile.absolutePath
|
||||
}
|
||||
|
||||
if (compilerOptions.usesK2.get()) {
|
||||
args.fragmentSources = multiplatformStructure.fragmentSourcesCompilerArgs(sourceFileFilter)
|
||||
} else {
|
||||
args.commonSources = commonSourceSet.asFileTree.toPathsArray()
|
||||
if (multiPlatformEnabled.get()) {
|
||||
if (compilerOptions.usesK2.get()) {
|
||||
args.fragmentSources = multiplatformStructure.fragmentSourcesCompilerArgs(sourceFileFilter)
|
||||
} else {
|
||||
args.commonSources = commonSourceSet.asFileTree.toPathsArray()
|
||||
}
|
||||
}
|
||||
|
||||
args.freeArgs += sources.asFileTree.files.map { it.absolutePath }
|
||||
|
||||
+6
-4
@@ -263,10 +263,12 @@ abstract class KotlinCompile @Inject constructor(
|
||||
}
|
||||
|
||||
sources { args ->
|
||||
if (compilerOptions.usesK2.get()) {
|
||||
args.fragmentSources = multiplatformStructure.fragmentSourcesCompilerArgs(sourceFileFilter)
|
||||
} else {
|
||||
args.commonSources = commonSourceSet.asFileTree.toPathsArray()
|
||||
if (multiPlatformEnabled.get()) {
|
||||
if (compilerOptions.usesK2.get()) {
|
||||
args.fragmentSources = multiplatformStructure.fragmentSourcesCompilerArgs(sourceFileFilter)
|
||||
} else {
|
||||
args.commonSources = commonSourceSet.asFileTree.toPathsArray()
|
||||
}
|
||||
}
|
||||
|
||||
val sourcesFiles = sources.asFileTree.files.toList()
|
||||
|
||||
+15
-4
@@ -21,12 +21,10 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinJsCompilerType.IR
|
||||
import org.jetbrains.kotlin.gradle.tasks.*
|
||||
import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure.Fragment
|
||||
import org.jetbrains.kotlin.gradle.tasks.K2MultiplatformStructure.RefinesEdge
|
||||
import org.jetbrains.kotlin.gradle.util.applyMultiplatformPlugin
|
||||
import org.jetbrains.kotlin.gradle.util.buildProject
|
||||
import org.jetbrains.kotlin.gradle.util.enableDefaultStdlibDependency
|
||||
import org.jetbrains.kotlin.gradle.util.main
|
||||
import org.jetbrains.kotlin.gradle.util.*
|
||||
import kotlin.test.Test
|
||||
import kotlin.test.assertEquals
|
||||
import kotlin.test.assertNull
|
||||
import kotlin.test.fail
|
||||
|
||||
class K2MultiplatformStructureTest {
|
||||
@@ -87,6 +85,19 @@ class K2MultiplatformStructureTest {
|
||||
`test compilations multiplatformStructure configuration`(kotlin.js(IR).compilations.main)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `KT-65768 - no fragment sources in pure jvm project`() {
|
||||
val project = buildProject {
|
||||
applyKotlinJvmPlugin()
|
||||
}
|
||||
project.evaluate()
|
||||
|
||||
project.tasks.withType<KotlinCompile>().forEach { task ->
|
||||
val arguments = task.buildCompilerArguments()
|
||||
assertNull(arguments.fragmentSources, "Task $task has -Xframent-sources but it shouldn't.")
|
||||
}
|
||||
}
|
||||
|
||||
private fun `test compilations multiplatformStructure configuration`(compilation: KotlinCompilation<*>) {
|
||||
val defaultSourceSet = compilation.defaultSourceSet
|
||||
/* Create an additional intermediate source set for testing */
|
||||
|
||||
Reference in New Issue
Block a user