[Gradle] Fixed warnings in KotlinNativeTasks.kt
^KT-56904
This commit is contained in:
committed by
Space Team
parent
d88249bda7
commit
5dcc853df3
+2
-1
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.daemon.common.configureDaemonJVMOptions
|
||||
import org.jetbrains.kotlin.daemon.common.filterExtractProps
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinJsProjectExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
|
||||
import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
|
||||
import org.jetbrains.kotlin.gradle.dsl.multiplatformExtensionOrNull
|
||||
import org.jetbrains.kotlin.gradle.internal.ClassLoadersCachingBuildService
|
||||
import org.jetbrains.kotlin.gradle.logging.kotlinDebug
|
||||
@@ -235,7 +236,7 @@ internal open class GradleCompilerRunner(
|
||||
errorsFiles = errorsFiles,
|
||||
kotlinPluginVersion = getKotlinPluginVersion(loggerProvider),
|
||||
//no need to log warnings in MessageCollector hear it will be logged by compiler
|
||||
kotlinLanguageVersion = parseLanguageVersion(compilerArgs.languageVersion, compilerArgs.useK2),
|
||||
kotlinLanguageVersion = compilerArgs.languageVersion?.let { v -> KotlinVersion.fromVersion(v) } ?: KotlinVersion.DEFAULT,
|
||||
compilerArgumentsLogLevel = environment.compilerArgumentsLogLevel,
|
||||
)
|
||||
TaskLoggers.put(pathProvider, loggerProvider)
|
||||
|
||||
-15
@@ -249,21 +249,6 @@ internal fun exitCodeFromProcessExitCode(log: KotlinLogger, code: Int): ExitCode
|
||||
return if (code == 0) ExitCode.OK else ExitCode.COMPILATION_ERROR
|
||||
}
|
||||
|
||||
//Copy of CommonCompilerArguments.parseOrConfigureLanguageVersion to avoid direct dependency
|
||||
internal fun parseLanguageVersion(languageVersion: String?, useK2: Boolean): KotlinVersion {
|
||||
val explicitVersion = languageVersion?.let { KotlinVersion.fromVersion(languageVersion) } ?: KotlinVersion.DEFAULT
|
||||
return if (useK2 && (explicitVersion < KotlinVersion.KOTLIN_2_0)) KotlinVersion.KOTLIN_2_0 else explicitVersion
|
||||
}
|
||||
|
||||
internal fun parseLanguageVersion(args: List<String>): KotlinVersion {
|
||||
val languageVersionIndex = args.indexOf("-language-version")
|
||||
val languageVersion = if (languageVersionIndex >= 0) {
|
||||
args[languageVersionIndex + 1]
|
||||
} else null
|
||||
val useK2 = args.indexOf("-Xuse-k2") >= 0
|
||||
return parseLanguageVersion(languageVersion, useK2)
|
||||
}
|
||||
|
||||
internal fun UsesBuildMetricsService.addBuildMetricsForTaskAction(
|
||||
metricsReporter: BuildMetricsReporter<GradleBuildTime, GradleBuildPerformanceMetric>,
|
||||
languageVersion: KotlinVersion?,
|
||||
|
||||
+5
-2
@@ -515,7 +515,7 @@ internal constructor(
|
||||
val buildMetrics = metrics.get()
|
||||
addBuildMetricsForTaskAction(
|
||||
metricsReporter = buildMetrics,
|
||||
languageVersion = parseLanguageVersion(compilerOptions.languageVersion.orNull?.version, compilerOptions.useK2.get())
|
||||
languageVersion = resolveLanguageVersion()
|
||||
) {
|
||||
val arguments = createCompilerArguments()
|
||||
val buildArguments = buildMetrics.measure(GradleBuildTime.OUT_OF_WORKER_TASK_ACTION) {
|
||||
@@ -535,6 +535,9 @@ internal constructor(
|
||||
|
||||
}
|
||||
|
||||
private fun resolveLanguageVersion() =
|
||||
compilerOptions.languageVersion.orNull?.version?.let { v -> KotlinVersion.fromVersion(v) }
|
||||
|
||||
private fun collectCommonCompilerStats() {
|
||||
buildFusService.orNull?.reportFusMetrics {
|
||||
it.report(BooleanMetrics.KOTLIN_PROGRESSIVE_MODE, compilerOptions.progressiveMode.get())
|
||||
@@ -554,7 +557,7 @@ internal class ExternalDependenciesBuilder(
|
||||
intermediateLibraryName: String?,
|
||||
) {
|
||||
constructor(project: Project, compilation: KotlinNativeCompilation) : this(
|
||||
project, compilation, compilation.compileKotlinTask.moduleName
|
||||
project, compilation, compilation.compileTaskProvider.get().compilerOptions.moduleName.get()
|
||||
)
|
||||
|
||||
private val compileDependencyConfiguration: Configuration
|
||||
|
||||
Reference in New Issue
Block a user