[Commonizer] Prevent from running commonizer from Gradle more then once
This commit is contained in:
+4
-1
@@ -16,6 +16,7 @@ import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
|
||||
import org.jetbrains.kotlin.gradle.targets.native.DisabledNativeTargetsReporter
|
||||
import org.jetbrains.kotlin.gradle.targets.native.internal.setUpKotlinNativePlatformDependencies
|
||||
import org.jetbrains.kotlin.gradle.utils.NativeCompilerDownloader
|
||||
import org.jetbrains.kotlin.gradle.utils.SingleActionPerProject
|
||||
import org.jetbrains.kotlin.konan.target.HostManager
|
||||
import org.jetbrains.kotlin.konan.target.KonanTarget
|
||||
|
||||
@@ -69,7 +70,9 @@ abstract class AbstractKotlinNativeTargetPreset<T : KotlinNativeTarget>(
|
||||
createTargetConfigurator().configureTarget(result)
|
||||
|
||||
project.gradle.taskGraph.whenReady {
|
||||
project.rootProject.setUpKotlinNativePlatformDependencies()
|
||||
SingleActionPerProject.run(project, "setUpKotlinNativePlatformDependencies") {
|
||||
project.setUpKotlinNativePlatformDependencies()
|
||||
}
|
||||
}
|
||||
|
||||
if (!konanTarget.enabledOnCurrentHost) {
|
||||
|
||||
-20
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.utils
|
||||
|
||||
import org.gradle.api.Project
|
||||
import java.util.*
|
||||
|
||||
internal object SingleWarningPerBuild {
|
||||
private val rootModuleReceivedWarning = WeakHashMap<Project, MutableSet<String>>()
|
||||
|
||||
fun show(project: Project, warningText: String) {
|
||||
val receivedWarnings = rootModuleReceivedWarning.computeIfAbsent(project.rootProject) { mutableSetOf() }
|
||||
if (receivedWarnings.add(warningText)) {
|
||||
project.logger.warn(warningText)
|
||||
}
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.utils
|
||||
|
||||
import org.gradle.api.Project
|
||||
import java.util.WeakHashMap
|
||||
|
||||
internal abstract class SingleAction {
|
||||
private val performedActions = WeakHashMap<Project, MutableSet<String>>()
|
||||
|
||||
protected abstract fun selectKey(project: Project): Project
|
||||
|
||||
fun run(project: Project, actionId: String, action: () -> Unit) {
|
||||
val performedActions = performedActions.computeIfAbsent(selectKey(project)) { mutableSetOf() }
|
||||
if (performedActions.add(actionId)) {
|
||||
action()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal object SingleActionPerBuild : SingleAction() {
|
||||
override fun selectKey(project: Project): Project = project.rootProject
|
||||
}
|
||||
|
||||
internal object SingleActionPerProject : SingleAction() {
|
||||
override fun selectKey(project: Project) = project
|
||||
}
|
||||
|
||||
internal object SingleWarningPerBuild {
|
||||
private const val ACTION_ID_SHOW_WARNING = "show-warning:"
|
||||
|
||||
fun show(project: Project, warningText: String) = SingleActionPerBuild.run(project, ACTION_ID_SHOW_WARNING + warningText) {
|
||||
project.logger.warn(warningText)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user