[Gradle] Declare IDEA-related system properties reads
#KT-44611 In Progress
This commit is contained in:
+7
-4
@@ -5,18 +5,21 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.internal
|
||||
|
||||
internal val isInIdeaSync: Boolean
|
||||
import org.gradle.api.Project
|
||||
import org.jetbrains.kotlin.gradle.utils.getSystemProperty
|
||||
|
||||
internal val Project.isInIdeaSync: Boolean
|
||||
get() {
|
||||
// "idea.sync.active" was introduced in 2019.1
|
||||
if (System.getProperty("idea.sync.active")?.toBoolean() == true) return true
|
||||
if (getSystemProperty("idea.sync.active")?.toBoolean() == true) return true
|
||||
|
||||
// before 2019.1 there is "idea.active" that was true only on sync,
|
||||
// but since 2019.1 "idea.active" present in task execution too.
|
||||
// So let's check Idea version
|
||||
val majorIdeaVersion = System.getProperty("idea.version")
|
||||
val majorIdeaVersion = getSystemProperty("idea.version")
|
||||
?.split(".")
|
||||
?.getOrNull(0)
|
||||
val isBeforeIdea2019 = majorIdeaVersion == null || majorIdeaVersion.toInt() < 2019
|
||||
|
||||
return isBeforeIdea2019 && System.getProperty("idea.active")?.toBoolean() == true
|
||||
return isBeforeIdea2019 && getSystemProperty("idea.active")?.toBoolean() == true
|
||||
}
|
||||
+3
-2
@@ -81,8 +81,9 @@ import java.io.File
|
||||
* Note that in this case resolution process will be performed outside of task execution.
|
||||
*/
|
||||
class KotlinNpmResolutionManager(private val nodeJsSettings: NodeJsRootExtension) {
|
||||
private val forceFullResolve: Boolean
|
||||
get() = isInIdeaSync
|
||||
private val forceFullResolve: Boolean by lazy {
|
||||
nodeJsSettings.rootProject.isInIdeaSync
|
||||
}
|
||||
|
||||
internal val resolver = KotlinRootNpmResolver(nodeJsSettings, forceFullResolve)
|
||||
|
||||
|
||||
+2
-5
@@ -14,6 +14,7 @@ import org.gradle.language.base.plugins.LifecycleBasePlugin
|
||||
import org.jetbrains.kotlin.gradle.tasks.dependsOn
|
||||
import org.jetbrains.kotlin.gradle.tasks.registerTask
|
||||
import org.jetbrains.kotlin.gradle.tasks.locateTask
|
||||
import org.jetbrains.kotlin.gradle.utils.getSystemProperty
|
||||
import org.jetbrains.kotlin.gradle.utils.isConfigurationCacheAvailable
|
||||
|
||||
/**
|
||||
@@ -72,11 +73,7 @@ class KotlinTestsRegistry(val project: Project, val allTestsTaskName: String = "
|
||||
|
||||
aggregate.destinationDir = project.testReportsDir.resolve(reportName)
|
||||
|
||||
val isIdeaActive = if (isConfigurationCacheAvailable(project.gradle)) {
|
||||
project.providers.systemProperty("idea.active").forUseAtConfigurationTime().isPresent
|
||||
} else {
|
||||
System.getProperty("idea.active") != null
|
||||
}
|
||||
val isIdeaActive = project.getSystemProperty("idea.active") != null
|
||||
|
||||
if (isIdeaActive) {
|
||||
aggregate.extensions.extraProperties.set("idea.internal.test", true)
|
||||
|
||||
+10
-1
@@ -5,6 +5,7 @@
|
||||
|
||||
package org.jetbrains.kotlin.gradle.utils
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.invocation.Gradle
|
||||
|
||||
internal fun isConfigurationCacheAvailable(gradle: Gradle) =
|
||||
@@ -13,4 +14,12 @@ internal fun isConfigurationCacheAvailable(gradle: Gradle) =
|
||||
startParameters.javaClass.getMethod("isConfigurationCache").invoke(startParameters) as? Boolean
|
||||
} catch (_: Exception) {
|
||||
null
|
||||
} ?: false
|
||||
} ?: false
|
||||
|
||||
internal fun Project.getSystemProperty(key: String): String? {
|
||||
return if (isConfigurationCacheAvailable(gradle)) {
|
||||
providers.systemProperty(key).forUseAtConfigurationTime().orNull
|
||||
} else {
|
||||
System.getProperty(key)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user