Gradle, js, external declarations: read flags from properties

This commit is contained in:
Sergey Rostov
2019-07-28 10:54:20 +03:00
parent 88db93853f
commit 87e80317a0
2 changed files with 21 additions and 3 deletions
@@ -140,6 +140,18 @@ internal class PropertiesProvider(private val project: Project) {
val nativeJvmArgs: String?
get() = propertyWithDeprecatedVariant("kotlin.native.jvmArgs", "org.jetbrains.kotlin.native.jvmArgs")
/**
* Generate kotlin/js external declarations from all .d.ts files found in npm modules
*/
val jsGenerateExternals: Boolean?
get() = booleanProperty("kotlin.js.experimental.generateKotlinExternals")
/**
* Automaticaly discover external .d.ts declarations
*/
val jsDiscoverTypes: Boolean?
get() = booleanProperty("kotlin.js.experimental.discoverTypes")
private fun propertyWithDeprecatedVariant(propName: String, deprecatedPropName: String): String? {
val deprecatedProperty = property(deprecatedPropName)
if (deprecatedProperty != null) {
@@ -3,6 +3,7 @@ package org.jetbrains.kotlin.gradle.targets.js.nodejs
import org.gradle.api.Project
import org.jetbrains.kotlin.gradle.internal.isInIdeaSync
import org.jetbrains.kotlin.gradle.logging.kotlinInfo
import org.jetbrains.kotlin.gradle.plugin.PropertiesProvider
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinJsCompilation
import org.jetbrains.kotlin.gradle.targets.js.NpmVersions
import org.jetbrains.kotlin.gradle.targets.js.npm.KotlinNpmResolutionManager
@@ -36,9 +37,14 @@ open class NodeJsRootExtension(val rootProject: Project) {
var packageManager: NpmApi = Yarn
class Experimental {
var generateKotlinExternals: Boolean = false
var discoverTypes: Boolean = false
private val projectProperties = PropertiesProvider(rootProject)
inner class Experimental {
val generateKotlinExternals: Boolean
get() = projectProperties.jsGenerateExternals == true
val discoverTypes: Boolean
get() = projectProperties.jsDiscoverTypes == true
}
val experimental = Experimental()