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