[Gradle, JS] Back field to delegate
#KT-37582 fixed
This commit is contained in:
+1
-1
@@ -169,7 +169,7 @@ open class KotlinBrowserJsIr @Inject constructor(target: KotlinJsIrTarget) :
|
|||||||
compilation.developmentLinkTask.map { it.outputFile }
|
compilation.developmentLinkTask.map { it.outputFile }
|
||||||
).get()
|
).get()
|
||||||
it.description = "build webpack ${kind.name.toLowerCase()} bundle"
|
it.description = "build webpack ${kind.name.toLowerCase()} bundle"
|
||||||
it._destinationDirectory = distribution.directory
|
it.destinationDirectory = distribution.directory!!
|
||||||
|
|
||||||
commonWebpackConfigurations.forEach { configure ->
|
commonWebpackConfigurations.forEach { configure ->
|
||||||
it.configure()
|
it.configure()
|
||||||
|
|||||||
+1
-1
@@ -195,7 +195,7 @@ open class KotlinBrowserJs @Inject constructor(target: KotlinJsTarget) :
|
|||||||
|
|
||||||
it.compilation = compilation
|
it.compilation = compilation
|
||||||
it.description = "build webpack ${kind.name.toLowerCase()} bundle"
|
it.description = "build webpack ${kind.name.toLowerCase()} bundle"
|
||||||
it._destinationDirectory = distribution.directory
|
it.destinationDirectory = distribution.directory!!
|
||||||
|
|
||||||
when (kind) {
|
when (kind) {
|
||||||
BuildVariantKind.PRODUCTION -> {
|
BuildVariantKind.PRODUCTION -> {
|
||||||
|
|||||||
+4
-11
@@ -24,7 +24,6 @@ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig.Mode
|
|||||||
import org.jetbrains.kotlin.gradle.testing.internal.reportsDir
|
import org.jetbrains.kotlin.gradle.testing.internal.reportsDir
|
||||||
import org.jetbrains.kotlin.gradle.utils.injected
|
import org.jetbrains.kotlin.gradle.utils.injected
|
||||||
import org.jetbrains.kotlin.gradle.utils.property
|
import org.jetbrains.kotlin.gradle.utils.property
|
||||||
import org.jetbrains.kotlin.gradle.utils.provider
|
|
||||||
import java.io.File
|
import java.io.File
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@@ -53,11 +52,9 @@ open class KotlinWebpack : DefaultTask(), RequiresNpmDependencies {
|
|||||||
@Input
|
@Input
|
||||||
var mode: Mode = Mode.DEVELOPMENT
|
var mode: Mode = Mode.DEVELOPMENT
|
||||||
|
|
||||||
private var _entry: File? = null
|
|
||||||
|
|
||||||
@get:PathSensitive(PathSensitivity.ABSOLUTE)
|
@get:PathSensitive(PathSensitivity.ABSOLUTE)
|
||||||
@get:InputFile
|
@get:InputFile
|
||||||
var entry: File by property(::_entry) {
|
var entry: File by property {
|
||||||
compilation.compileKotlinTask.outputFile
|
compilation.compileKotlinTask.outputFile
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,17 +92,13 @@ open class KotlinWebpack : DefaultTask(), RequiresNpmDependencies {
|
|||||||
get() = project.convention.plugins["base"] as BasePluginConvention?
|
get() = project.convention.plugins["base"] as BasePluginConvention?
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
internal var _destinationDirectory: File? = null
|
var destinationDirectory: File by property {
|
||||||
|
|
||||||
@get:Internal
|
|
||||||
val destinationDirectory: File by provider(::_destinationDirectory) {
|
|
||||||
project.buildDir.resolve(baseConventions!!.distsDirName)
|
project.buildDir.resolve(baseConventions!!.distsDirName)
|
||||||
}
|
}
|
||||||
|
internal set
|
||||||
private var _outputFileName: String? = null
|
|
||||||
|
|
||||||
@get:Internal
|
@get:Internal
|
||||||
var outputFileName: String by property(::_outputFileName) {
|
var outputFileName: String by property {
|
||||||
baseConventions?.archivesBaseName + ".js"
|
baseConventions?.archivesBaseName + ".js"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+9
-10
@@ -5,33 +5,32 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.gradle.utils
|
package org.jetbrains.kotlin.gradle.utils
|
||||||
|
|
||||||
import kotlin.reflect.KMutableProperty
|
|
||||||
import kotlin.reflect.KProperty
|
import kotlin.reflect.KProperty
|
||||||
|
|
||||||
open class ProviderDelegate<out T : Any>(
|
open class ProviderDelegate<out T : Any>(
|
||||||
protected open val backing: KProperty<T?>,
|
|
||||||
private val defaultValueProvider: () -> T
|
private val defaultValueProvider: () -> T
|
||||||
) {
|
) {
|
||||||
|
protected open val backing: T? = null
|
||||||
|
|
||||||
operator fun getValue(thisRef: Any?, property: KProperty<*>): T {
|
operator fun getValue(thisRef: Any?, property: KProperty<*>): T {
|
||||||
return backing.getter.call() ?: defaultValueProvider()
|
return backing ?: defaultValueProvider()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class PropertyDelegate<T : Any>(
|
class PropertyDelegate<T : Any>(
|
||||||
override val backing: KMutableProperty<T?>,
|
|
||||||
defaultValueProvider: () -> T
|
defaultValueProvider: () -> T
|
||||||
) : ProviderDelegate<T>(backing, defaultValueProvider) {
|
) : ProviderDelegate<T>(defaultValueProvider) {
|
||||||
|
override var backing: T? = null
|
||||||
|
|
||||||
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
|
operator fun setValue(thisRef: Any?, property: KProperty<*>, value: T) {
|
||||||
backing.setter.call(value)
|
backing = value
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T : Any> provider(
|
fun <T : Any> provider(
|
||||||
backing: KProperty<T?>,
|
|
||||||
defaultValueProvider: () -> T
|
defaultValueProvider: () -> T
|
||||||
): ProviderDelegate<T> = ProviderDelegate(backing, defaultValueProvider)
|
): ProviderDelegate<T> = ProviderDelegate(defaultValueProvider)
|
||||||
|
|
||||||
fun <T : Any> property(
|
fun <T : Any> property(
|
||||||
backing: KMutableProperty<T?>,
|
|
||||||
defaultValueProvider: () -> T
|
defaultValueProvider: () -> T
|
||||||
): PropertyDelegate<T> = PropertyDelegate(backing, defaultValueProvider)
|
): PropertyDelegate<T> = PropertyDelegate(defaultValueProvider)
|
||||||
Reference in New Issue
Block a user