[Gradle, native] Allow disabling warning about incorrect dependencies
Issue #KT-32476
This commit is contained in:
+20
@@ -56,5 +56,25 @@ class GeneralNativeIT : BaseGradleIT() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testIncorrectDependenciesWarning() = with(Project("sample-lib", directoryPrefix = "new-mpp-lib-and-app")) {
|
||||||
|
setupWorkingDir()
|
||||||
|
gradleBuildScript().modify {
|
||||||
|
it.replace(
|
||||||
|
"api 'org.jetbrains.kotlin:kotlin-stdlib-common'",
|
||||||
|
"compileOnly 'org.jetbrains.kotlin:kotlin-stdlib-common'"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
build {
|
||||||
|
assertSuccessful()
|
||||||
|
assertContains("A compileOnly dependency is used in the Kotlin/Native target")
|
||||||
|
}
|
||||||
|
build("-Pkotlin.native.ignoreIncorrectDependencies=true") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertNotContains("A compileOnly dependency is used in the Kotlin/Native target")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO: Move native specific tests from NewMultiplatformIT here.
|
// TODO: Move native specific tests from NewMultiplatformIT here.
|
||||||
}
|
}
|
||||||
+4
@@ -95,6 +95,9 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
val ignoreDisabledNativeTargets: Boolean?
|
val ignoreDisabledNativeTargets: Boolean?
|
||||||
get() = booleanProperty(DisabledNativeTargetsReporter.DISABLE_WARNING_PROPERTY_NAME)
|
get() = booleanProperty(DisabledNativeTargetsReporter.DISABLE_WARNING_PROPERTY_NAME)
|
||||||
|
|
||||||
|
val ignoreIncorrectNativeDependencies: Boolean?
|
||||||
|
get() = booleanProperty(KOTLIN_NATIVE_IGNORE_INCORRECT_DEPENDENCIES)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enables parallel tasks execution within a project with Workers API.
|
* Enables parallel tasks execution within a project with Workers API.
|
||||||
* Does not enable using actual worker proccesses
|
* Does not enable using actual worker proccesses
|
||||||
@@ -227,6 +230,7 @@ internal class PropertiesProvider private constructor(private val project: Proje
|
|||||||
private const val CACHED_PROVIDER_EXT_NAME = "kotlin.properties.provider"
|
private const val CACHED_PROVIDER_EXT_NAME = "kotlin.properties.provider"
|
||||||
|
|
||||||
internal const val KOTLIN_NATIVE_DISABLE_COMPILER_DAEMON = "kotlin.native.disableCompilerDaemon"
|
internal const val KOTLIN_NATIVE_DISABLE_COMPILER_DAEMON = "kotlin.native.disableCompilerDaemon"
|
||||||
|
internal const val KOTLIN_NATIVE_IGNORE_INCORRECT_DEPENDENCIES = "kotlin.native.ignoreIncorrectDependencies"
|
||||||
|
|
||||||
// TODO: Remove once KT-37550 is fixed
|
// TODO: Remove once KT-37550 is fixed
|
||||||
internal const val KOTLIN_NATIVE_ENABLE_PARALLEL_EXECUTION_CHECK = "kotlin.native.enableParallelExecutionCheck"
|
internal const val KOTLIN_NATIVE_ENABLE_PARALLEL_EXECUTION_CHECK = "kotlin.native.enableParallelExecutionCheck"
|
||||||
|
|||||||
+12
-3
@@ -21,6 +21,7 @@ import org.gradle.api.tasks.TaskProvider
|
|||||||
import org.gradle.language.base.plugins.LifecycleBasePlugin
|
import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.MAIN_COMPILATION_NAME
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME
|
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilation.Companion.TEST_COMPILATION_NAME
|
||||||
|
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider.Companion.KOTLIN_NATIVE_IGNORE_INCORRECT_DEPENDENCIES
|
||||||
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
import org.jetbrains.kotlin.gradle.plugin.mpp.*
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.*
|
import org.jetbrains.kotlin.gradle.targets.native.*
|
||||||
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeHostTest
|
import org.jetbrains.kotlin.gradle.targets.native.tasks.KotlinNativeHostTest
|
||||||
@@ -225,7 +226,10 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget>(
|
|||||||
configureBinaries(target)
|
configureBinaries(target)
|
||||||
configureFrameworkExport(target)
|
configureFrameworkExport(target)
|
||||||
configureCInterops(target)
|
configureCInterops(target)
|
||||||
warnAboutIncorrectDependencies(target)
|
|
||||||
|
if (PropertiesProvider(target.project).ignoreIncorrectNativeDependencies != true) {
|
||||||
|
warnAboutIncorrectDependencies(target)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun configureArchivesAndComponent(target: T): Unit = with(target.project) {
|
override fun configureArchivesAndComponent(target: T): Unit = with(target.project) {
|
||||||
@@ -353,10 +357,15 @@ open class KotlinNativeTargetConfigurator<T : KotlinNativeTarget>(
|
|||||||
Dependencies:
|
Dependencies:
|
||||||
${it.second.joinToString(separator = "\n") { it.stringCoordinates() }}
|
${it.second.joinToString(separator = "\n") { it.stringCoordinates() }}
|
||||||
|
|
||||||
""".trimIndent()
|
""".trimIndent()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
warn("Such dependencies are not applicable for Kotlin/Native, consider changing the dependency type to 'implementation' or 'api'.")
|
warn(
|
||||||
|
"""
|
||||||
|
Such dependencies are not applicable for Kotlin/Native, consider changing the dependency type to 'implementation' or 'api'.
|
||||||
|
To disable this warning, set the $KOTLIN_NATIVE_IGNORE_INCORRECT_DEPENDENCIES=true project property
|
||||||
|
""".trimIndent()
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user