h0tk3y
12/13/2018, 12:50 PMkotlin-multiplatform
plugin, along with some DSL improvements, such as simpler targets declaration.
You're welcome to try it and share your feedback!
See the details in the thread.h0tk3y
12/13/2018, 12:50 PMpluginManagement { ... }
section of the settings.gradle
file:
pluginManagement {
repositories {
maven { setUrl("<https://kotlin.bintray.com/kotlin-eap>") }
gradlePluginPortal()
}
}
Add this repository to the build script as well and apply the plugin within the plugins { ... }
block as you normally would, but specify the EAP version:
plugins {
kotlin("multiplatform") version "1.3.20-eap-25"
}
repositories {
maven { setUrl("<https://kotlin.bintray.com/kotlin-eap>") }
}
h0tk3y
12/13/2018, 12:50 PMfromPreset(presets.<...>, '...')
, you can now use functions: for example, jvm { ... }
or jvm('jvm6') { ... }
or even jvm()
, and similarly for the other platforms. This works in the whole kotlin { ... }
scope, not only in the targets { ... }
block. If such a target already exists, these functions return it, which can be used to access or configure an existing target: jvm().compilations.<...>
.
* an equivalent for targets { fromPreset(...) }
in case you need to dynamically create multiple targets from several presets: `targetFromPreset(...)`;
* defaultSourceSet
and defaultSourceSet { ... }
as a less error-prone way to configure a default source set of a compilation: `jvm().compilations["main"].defaultSourceSet { ... }`;
* statically typed kotlinOptions
, kotlinOptions { ... }
, and compileKotlinTask
for a `KotlinCompilation`;
* shorthands for Kotlin dependencies, like kotlin('stdlib')
instead of 'org.jetbrains.kotlin:kotlin-stdlib'
.addamsson
12/13/2018, 12:51 PMthevery
12/13/2018, 1:46 PMserebit
12/13/2018, 6:14 PMfun KotlinDependencyHandler.implementation(group: String, name: String, version: String)
h0tk3y
12/13/2018, 10:21 PMmsink
12/14/2018, 12:18 AMgildor
12/14/2018, 7:40 AMmaven { setUrl("<https://kotlin.bintray.com/kotlin-eap>") }
Can be replaced with just
maven("<https://kotlin.bintray.com/kotlin-eap>")
gildor
12/14/2018, 8:23 AMfun KotlinOnlyTarget<*>.dependenciesMain(block: KotlinDependencyHandler.() -> Unit) {
compilations["main"].defaultSourceSet {
dependencies {
block()
}
}
}
gildor
12/14/2018, 8:24 AMcompilations["main"].defaultSourceSet {
is pretty wordy and you need a lot of such codeh0tk3y
12/17/2018, 1:36 PMmain
compilation, so this kind of extension won't be available for Android targets. I've created an issue for this: https://youtrack.jetbrains.com/issue/KT-28866pajatopmr
12/27/2018, 10:47 PMpajatopmr
12/27/2018, 10:47 PMpajatopmr
12/27/2018, 10:49 PMserebit
12/27/2018, 10:49 PMget(“nativeMain”)
serebit
12/27/2018, 10:49 PMpajatopmr
12/27/2018, 10:56 PMpajatopmr
12/27/2018, 10:56 PMserebit
12/28/2018, 2:26 AMget(“${targetName}Main”)
or get(“${targetName}Test”
, like windowsMain
and linuxMain
. I wasn’t clear in my other message, sorry.serebit
12/28/2018, 2:27 AM[linuxMain, windowsMain, macMain]
with mutableListOf(get(“linuxMain”), get(“macMain”), get(“windowsMain”))
.serebit
12/28/2018, 2:28 AMpajatopmr
12/28/2018, 5:27 AMpajatopmr
12/28/2018, 5:27 AMgildor
12/28/2018, 5:36 AMpajatopmr
12/28/2018, 6:11 AMgildor
12/28/2018, 6:15 AMpajatopmr
12/28/2018, 6:30 AMgetByName("nativeMain")...
is defining the source set, associating it with the three native targets. Feel free to correct my understanding.gildor
12/28/2018, 6:59 AMprintln(asMap.values)
pajatopmr
12/28/2018, 8:03 AMValues: [source set commonMain, source set commonTest, source set jvmMain, source set jvmTest, source set linuxMain, source set linuxTest, source set macMain, source set macTest, source set windowsMain, source set windowsTest]!
gildor
12/28/2018, 8:05 AMgildor
12/28/2018, 8:05 AMasMap.keys
, sorrygildor
12/28/2018, 8:06 AMpajatopmr
12/28/2018, 8:07 AMsourceSets
block is to associate the native source sets with the directory src/nativeMain
but how that association is supposed to be made is not clear to me.pajatopmr
12/28/2018, 8:09 AMpajatopmr
12/28/2018, 8:11 AMpajatopmr
12/28/2018, 8:18 AMk-new-mpp-samples/lib-and-app/sample-lib
to build and report errors (link errors at that). That will be confirmation that I have the Groovy -> Kotlin transformation correct.msink
12/28/2018, 8:40 AMkotlin {
sourceSets["commonMain"].apply {
dependencies {
....
}
}
sourceSets.create("nativeMain").apply {
dependencies {
.....
}
}
.....
h0tk3y
12/28/2018, 12:16 PMgetOrCreate("...")
. In the Kotlin DSL, you should either call those functions (get("...")
for an existing item, create("...")
for a new one, or getOrCreate("...")
if in doubt) or use delegation (https://docs.gradle.org/5.0/userguide/kotlin_dsl.html#using_kotlin_delegated_properties).h0tk3y
12/28/2018, 12:18 PMkotlin {
sourceSets {
// ...
val nativeMain by creating {
// ...
}
configure(listOf(mingw, linux, mac)) {
compilations["main"].defaultSourceSet.dependsOn(nativeMain)
}
}
}
pajatopmr
12/28/2018, 2:35 PM