[readme] Add multiplatform support description into readme.
This commit is contained in:
+61
-1
@@ -218,6 +218,41 @@ and set dependencies between building tasks.
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Multiplatform build
|
||||||
|
|
||||||
|
Kotlin/Native, as well as Kotlin/JVM and Kotlin/JS, supports multiplatform projects. Such a support is included in the
|
||||||
|
Kotlin/Native Gradle plugin by default and there is no need to apply additional plugins to use it. By default
|
||||||
|
multiplatform support is turned off, and could be enabled with the `enableMultiplatform` DSL method:
|
||||||
|
|
||||||
|
apply 'konan'
|
||||||
|
|
||||||
|
konanArtifacts {
|
||||||
|
program('foo') {
|
||||||
|
enableMultiplatform true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
The Gradle plugin adds an `expectedBy` dependency configuration that is used to specify a dependency from Kotlin/Native
|
||||||
|
project to a common project:
|
||||||
|
|
||||||
|
apply 'konan'
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
expectedBy project('commonProject')
|
||||||
|
}
|
||||||
|
|
||||||
|
When a common project is added as an `expectedBy` dependency, all the artifacts with the multiplatform support enabled
|
||||||
|
will use it's `main` source set as a common module. One may specify a custom source set for each artifact using the
|
||||||
|
`commonSourceSet` DSL method. In this case the multiplatform support will be also enabled for this artifact.
|
||||||
|
|
||||||
|
konanArtifacts {
|
||||||
|
program('foo') {
|
||||||
|
commonSourceSet 'customSourceSet'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
See more about multiplatform projects [here](https://kotlinlang.org/docs/reference/multiplatform.html).
|
||||||
|
|
||||||
## Tasks
|
## Tasks
|
||||||
|
|
||||||
The Kotlin/Native plugin creates the following tasks:
|
The Kotlin/Native plugin creates the following tasks:
|
||||||
@@ -243,6 +278,8 @@ for each an artifact defined in a `konanArtifacts` block. Such a task may have d
|
|||||||
|`enableOptimizations`|`boolean` |Are the optimizations enabled |
|
|`enableOptimizations`|`boolean` |Are the optimizations enabled |
|
||||||
|`enableAssertions `|`boolean` |Is the assertion support enabled |
|
|`enableAssertions `|`boolean` |Is the assertion support enabled |
|
||||||
|`measureTime `|`boolean` |Does the compiler print phase time |
|
|`measureTime `|`boolean` |Does the compiler print phase time |
|
||||||
|
|`enableMultiplatform`|`boolean` |Is multiplatform support enabled for this artifact |
|
||||||
|
|`commonSourceSet` |`String` |Name of a source set used as a common module |
|
||||||
|
|
||||||
##### Properties available for a cinterop task (task building an interoperability library):
|
##### Properties available for a cinterop task (task building an interoperability library):
|
||||||
|
|
||||||
@@ -359,7 +396,7 @@ tables below.
|
|||||||
// Language and API version.
|
// Language and API version.
|
||||||
konan.languageVersion = 'version'
|
konan.languageVersion = 'version'
|
||||||
konan.apiVersion = 'version'
|
konan.apiVersion = 'version'
|
||||||
|
|
||||||
konanArtifacts {
|
konanArtifacts {
|
||||||
// Targets to build this artifact for (optional, override the konan.targets list)
|
// Targets to build this artifact for (optional, override the konan.targets list)
|
||||||
program('foo', targets: ['android_arm32', 'android_arm64']) {
|
program('foo', targets: ['android_arm32', 'android_arm64']) {
|
||||||
@@ -532,3 +569,26 @@ tables below.
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
## Multiplatform DSL
|
||||||
|
|
||||||
|
apply plugin: 'konan'
|
||||||
|
|
||||||
|
// In this example common code is located in 'bar' source set of ':common' project.
|
||||||
|
|
||||||
|
konanArtifacts {
|
||||||
|
// All the artifact types except interop libraries may use common modules.
|
||||||
|
program('foo') {
|
||||||
|
// All artifact settings described above are available here.
|
||||||
|
|
||||||
|
// Enable multiplatform support for this artifact.
|
||||||
|
enableMultiplatform true
|
||||||
|
|
||||||
|
// Set a custom name for a source set used as a common module.
|
||||||
|
commonSourceSet 'bar'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
// Use the ':foo' project as a common project for multiplatform build.
|
||||||
|
expectedBy project(':common')
|
||||||
|
}
|
||||||
|
|||||||
@@ -121,7 +121,7 @@ processResources {
|
|||||||
from(file("$rootBuildDirectory/utilities/env_blacklist"))
|
from(file("$rootBuildDirectory/utilities/env_blacklist"))
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Get rid of manual pom generation
|
// TODO: Get rid of manual pom generation.
|
||||||
publishing {
|
publishing {
|
||||||
publications {
|
publications {
|
||||||
gradlePlugin(MavenPublication) {
|
gradlePlugin(MavenPublication) {
|
||||||
|
|||||||
Reference in New Issue
Block a user