Gradle plugin for configure kotlin multiplatform project for Simple Kotlin Project
- How to add plugin to your Gradle project
- Configuration
- URL
- Common Kotlin Multiplatform Configuration
- Git Configuration
- GitHub Configuration
- Spotless Configuration
- Dokka Configuration
- Kover Configuration
- JGitVer Configuration
- License Configuration
- Organizations Configuration
- Developers Configuration
- Publishing Configuration
- Test Environments Variables Configuration
Using the plugins DSL:
Kotlin DSL
plugins {
id("io.github.edmondantes.simple.kmm.gradle.plugin") version "${simple_plugin_version}"
}
Groovy
plugins {
id "io.github.edmondantes.simple.kmm.gradle.plugin" version "${simple_plugin_version}"
}
Or using legacy plugin application:
Kotlin DSL
buildscript {
repositories {
maven {
url = uri("https://plugins.gradle.org/m2/")
}
}
dependencies {
classpath("io.github.edmondantes:simple-kotlin-multiplatform-gradle-plugin:${simple_plugin_version}")
}
}
apply(plugin = "io.github.edmondantes.simple.kmm.gradle.plugin")
Groovy
buildscript {
repositories {
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath "io.github.edmondantes:simple-kotlin-multiplatform-gradle-plugin:${simple_plugin_version}"
}
}
apply plugin: "io.github.edmondantes.simple.kmm.gradle.plugin"
Plugin has two type of configuration: extensions and properties. The first is defined in build.gradle script, the second is gradle properties
In plugin's fields that receive url you can use special format for getting organization url:
#orgizationName::arg1::arg2
If UrlFactory
for organizationName
was defined, it will try to create url for arguments
Example:
#github::user::project::branch
-> https://www.github.com/user/project/tree/branch
Property name | Description | Default value |
---|---|---|
simple.kmm.kotlin.configuration.enabled |
Enables setting up Kotlin configuration by the plugin | true |
simple.kmm.kotlin.serialization.plugin.enabled |
Enables applying Kotlin Serialization Plugin | false |
simple.kmm.kotlin.compile.target.jvm.enabled |
Enables compile for JVM target | true |
simple.kmm.kotlin.compile.target.js.enabled |
Enables compile for NodeJS target | true |
simple.kmm.kotlin.compile.target.browser.js.enabled |
Enables compile for Browser JS target | false |
simple.kmm.kotlin.compile.target.native.enabled |
Enables compile for Native target (For current system) | false |
simple.kmm.kotlin.compile.target.native.arm.enabled |
Enables compile for ARM Native target (For current system) (Enabled only if native target is enabled) | false |
simple.kmm.kotlin.explicit.api.enabled |
Enables explicit api and etc. | false |
simple.kmm.kotlin.sdk.java.version |
Sets SDK java version for JVM target | 11 |
Property name | Description | Default value |
---|---|---|
simple.kmm.git.default.branch |
Sets default branch for git repository | master |
Property name | Description | Default value |
---|---|---|
simple.kmm.github.configuration.enabled |
Enables setting up GitHub configuration by the plugin | true if found git repository, else false |
simple.kmm.github.java.distribution |
Sets java distribution for github's workflows. All supported distributions you can find here | corretto |
simple.kmm.github.java.version |
Sets java distributions version for github's workflows. | 11 |
simple.kmm.github.check.workflow.name |
Sets a file's name for github's workflow for build and check project | check |
simple.kmm.github.sonatype.publish.enabled |
Configure github's workflow for publish artifacts for sonatype publishing, else configure for maven publishing | false |
simple.kmm.github.sonatype.publish.workflow.name |
Sets a file's name for github's workflow for sonatype publishing | sonatypePublish |
simple.kmm.github.maven.publish.workflow.name |
Sets a file's name for github's workflow for maven publishing | mavenPublish |
Property name | Description | Default value |
---|---|---|
simple.kmm.spotless.configuration.enabled |
Enables setting up Spotless configuration by the plugin | true |
simple.kmm.spotless.ktlint.version |
Sets Ktlint version | 0.50.0 |
simple.kmm.spotless.license.file.header.path |
Sets path to a license file header for Spotless | LICENSE_FILE_HEADER |
simple.kmm.spotless.ratchet.git.branch |
Sets git branch for ratchetFrom for spotless | value from simple.kmm.git.default.branch |
Property name | Description | Default value |
---|---|---|
simple.kmm.dokka.configuration.enabled |
Enables setting up Dokka configuration by the plugin | true |
Property name | Description | Default value |
---|---|---|
simple.kmm.kover.configuration.enabled |
Enables setting up Kover configuration by the plugin | true |
Property name | Description | Default value |
---|---|---|
simple.kmm.jgitver.configuration.enabled |
Enables setting up JGitVer configuration by the plugin | true |
Property name | Description | Default value |
---|---|---|
simple.kmm.license.configuration.enabled |
Enables setting up License configuration by the plugin | true |
simple.kmm.license.file.path |
Sets path to license file | ./LICENSE |
If License Configuration is enabled, you will configure type of license:
Groovy
licenses {
license = SimpleLicense.APACHE2
}
Kotlin DSL
licenses {
license.set(SimpleLicense.APACHE2)
}
You can define organizations for use in publishing, etc. GitHub is already defined. You can use it by name github
Before create organization you should create UrlFactory
which generate your organization's url.
If you don't use created organization in publish
module, you can create EmptyUrlFactory
Kotlin DSL
val urlFactory = PatternUrlFactory()
... configuration urlFactory ...
organizations {
organization("orgName", urlFactory)
}
You can define project's developers for use in publishing, etc.
Kotlin DSL
developers {
developer {
id = "developerId"
name = "developer"
email = "developer@dev.com"
url = "developer-site.com"
organizationName("developerOrganization")
timezone = "UTC"
roles.add("Developer")
role("Team Lead")
properties.put("key", "value")
}
developer {
id = "developerSecond"
name = "second developer"
}
}
You can configure publishing to maven repository and POM for publishing
Property name | Description | Default value |
---|---|---|
simple.kmm.publish.configuration.enabled |
Enables setting up Publishing configuration by the plugin | true |
simple.kmm.publish.repository.url |
Url to maven repository | ./build/repo |
simple.kmm.publish.repository.id |
Id of repository in nexus repository (will be added to end of repository url) | |
simple.kmm.publish.username |
Username for publishing in maven repository | |
simple.kmm.publish.password |
Password for publishing in maven repository | |
simple.kmm.sign.key.id |
Key id for signing publishing artefacts | |
simple.kmm.sign.private.key |
Private key for signing publishing artefacts | |
simple.kmm.sign.password |
Keystore password for signing publishing artefacts |
You can configure POM for publishing by extension:
Kotlin DSL
simplePom {
create("publishingName") {
title = "Application"
description = "Application description"
url = "application-site.com"
license = SimpleLicense.APACHE2
scm {
url = "scm-site-url"
connection = "scm-connection-url"
developerConnection = "scm-developer-connection-url"
}
}
any {
title = "Application name"
}
}
This plugin add possibility to set environments variables for kotlin multiplatform projects.
Plugin will generate special kotlin object
which will contains variables which you can use in
kotlin multiplatform tests and configure by gradle extension
Plugin has default variables properties.
Property name | Type | Description |
---|---|---|
isEnableLogging |
Boolean |
Enables logging in tests. This variable will change before and after tests if test logging disabled in properties |
Property name | Description | Default value |
---|---|---|
simple.kmm.test.environment.configuration.enabled |
Enables setting up Test Environments Variables by the plugin | true |
simple.kmm.test.environment.variables.file.directory |
Path to directory which environment variables file's packages | ./build/generated/testEnvironmentKmm/src/commonTest/kotlin |
simple.kmm.test.environment.variables.class.path |
Path to file with environments variables | env/Env.kt |
simple.kmm.test.environment.variables.file.should.init.before.build |
If true, start initTestEnvFile task before build task |
true |
simple.kmm.test.environment.variables.default.included |
If true default variables will be added to file | true |
simple.kmm.test.environment.set.propertyName |
Sets value to environment variable with name propertyName |
You can configure variables by extension, but variables can be only Boolean
and String
type.
Kotlin DSL
simpleTestEnv {
put("variableName", "value")
put("isVariableName", true)
}