[Gradle, JS] Manually singleton because Gradle Daemon
^KT-39210 fixed ^KT-31669 fixed
This commit is contained in:
+30
-1
@@ -6,10 +6,12 @@
|
|||||||
package org.jetbrains.kotlin.gradle.targets.js
|
package org.jetbrains.kotlin.gradle.targets.js
|
||||||
|
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
|
import org.gradle.api.invocation.Gradle
|
||||||
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginInMultipleProjectsHolder
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPluginInMultipleProjectsHolder
|
||||||
import org.jetbrains.kotlin.gradle.plugin.MULTIPLE_KOTLIN_PLUGINS_LOADED_WARNING
|
import org.jetbrains.kotlin.gradle.plugin.MULTIPLE_KOTLIN_PLUGINS_LOADED_WARNING
|
||||||
|
|
||||||
internal object MultiplePluginDeclarationDetector {
|
internal class MultiplePluginDeclarationDetector
|
||||||
|
private constructor() {
|
||||||
private val pluginInMultipleProjectsHolder = KotlinPluginInMultipleProjectsHolder(
|
private val pluginInMultipleProjectsHolder = KotlinPluginInMultipleProjectsHolder(
|
||||||
differentVersionsInDifferentProject = false
|
differentVersionsInDifferentProject = false
|
||||||
)
|
)
|
||||||
@@ -22,4 +24,31 @@ internal object MultiplePluginDeclarationDetector {
|
|||||||
error(MULTIPLE_KOTLIN_PLUGINS_LOADED_WARNING)
|
error(MULTIPLE_KOTLIN_PLUGINS_LOADED_WARNING)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We can't use Kotlin object because we need new instance on each Gradle rebuild
|
||||||
|
// But if we inside Gradle daemon, Kotlin object will be shared between builds
|
||||||
|
companion object {
|
||||||
|
@field:Volatile
|
||||||
|
private var instance: MultiplePluginDeclarationDetector? = null
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
@Synchronized
|
||||||
|
private fun getInstance(gradle: Gradle): MultiplePluginDeclarationDetector {
|
||||||
|
if (instance != null) {
|
||||||
|
return instance!!
|
||||||
|
}
|
||||||
|
|
||||||
|
val detector = MultiplePluginDeclarationDetector()
|
||||||
|
instance = detector
|
||||||
|
gradle.buildFinished {
|
||||||
|
instance = null
|
||||||
|
}
|
||||||
|
|
||||||
|
return detector
|
||||||
|
}
|
||||||
|
|
||||||
|
fun detect(project: Project) {
|
||||||
|
getInstance(project.gradle).detect(project)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user