Provide preset-like factory functions for creating targets in new MPP
* Pull the `targets` and `presets` properties of the `kotlin` extension
up to an interface in `kotlin-gradle-plugin-api`
* Generate the code: we need type-safe statically-typed functions for
different target type, which seems to be only possible to achieve by
providing a function per preset.
* Place these functions in the top-level `kotlin` Gradle extension,
rather than extension functions for `kotlin.targets`:
- `kotlin.jvm { ... }` will work, while `kotlin.targets.jvm { ... }`
won't, the extension function needs to be somehow brought into scope
- reducing the nesting level by one seems to be a good move here
Issue #KT-26389 Fixed
This commit is contained in:
+2
@@ -45,5 +45,7 @@ interface KotlinTarget: Named, HasAttributes {
|
||||
fun mavenPublication(action: Closure<Unit>)
|
||||
fun mavenPublication(action: Action<MavenPublication>)
|
||||
|
||||
val preset: KotlinTargetPreset<out KotlinTarget>?
|
||||
|
||||
override fun getName(): String = targetName
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
/*
|
||||
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.gradle.plugin
|
||||
|
||||
import org.gradle.api.NamedDomainObjectCollection
|
||||
|
||||
interface KotlinTargetsContainer {
|
||||
val targets: NamedDomainObjectCollection<KotlinTarget>
|
||||
}
|
||||
|
||||
interface KotlinTargetsContainerWithPresets : KotlinTargetsContainer {
|
||||
val presets: NamedDomainObjectCollection<KotlinTargetPreset<*>>
|
||||
}
|
||||
Reference in New Issue
Block a user