This is a collection of gradle plugin that contain the common configuration for all Kodein Open-Source Initiative components.
This project is NOT by itself a Kodein Open-Source Initiative component, it is a build tool intended to be used ONLY by Kodein components.
This plugins must be applied in settings.gradle.kts
.
You therefore need to add both the repository and the plugin:
buildscript {
repositories {
mavenLocal()
maven(url = "https://raw.githubusercontent.com/kosi-libs/kodein-internal-gradle-plugin/mvn-repo")
}
dependencies {
classpath("org.kodein.internal.gradle:kodein-internal-gradle-settings:VERSION")
}
}
apply { plugin("org.kodein.settings") }
rootProject.name = "PRJECT-NAME"
include(
":moduleA",
":moduleB"
)
-
Allows modules segmentation (for target exclusion).
-
Adds all necessary repositories to project’s gradle classpath.
-
Configures standard dependencies repositories (maven local, jCenter, Google, Kotlin EAP).
-
Synchronizes all versions of kodein plugins.
-
Imports the
kodeinGlobal
version catalog.
You can exclude modules from being configured / compiled. For example: you can exclude an Android modules if you don’t have an Android SDK installation.
Excluded targets are configured via the excludeTargets
kodein local property.
You can exclude multiple targets with a coma separated list:
excludeTargets = android, ktor
For a module to relate to a target, you need to include it in a special way in settings.gradle.kts:
android.include(":framework:android")
framework("ktor").include(":framework:ktor")
-
Read Nexus Sonatype’s configuration values once and cache them in root module.
-
Configures sonatype (releases or snapshots) with
maven-publish
plugin (recommended way with KMP). -
Configures GPG signing for publication.
-
Adds standard information to POM.
-
Disables publications on cross and excluded targets (see MP module plugin).
-
Creates the
hostOnlyPublish
task which publishes only locally built native targets.
MavenCentral publishing and configuration is automatically disabled if the configuration values are not set.
You can set the bintray configuration values:
-
In your global
~/.gradle/gradle.properties
:org.kodein.sonatype.username = bintray-username org.kodein.sonatype.password = bintray-api-key
-
In environment variables
SONATYPE_USERNAME
andSONATYPE_PASSWORD
.
If the kodein local property ossrh.dryRun
is true
, the upload emulates the upload without actually uploading the items.
(or even through the org.kodein.sonatype.dryRun
gradle parameter).
Kodein local properties are personal properties that may change your local project configuration.
A Kodein local property key
can be set:
-
In environment variables, named
KODEIN_LOCAL_${key.toUppercase()}
. -
In a git ignored file
kodein.local.properties
at the root of the project repository with the keykey
. -
In the personal
~/.gradle/gradle.properties
file, with the keyorg.kodein.local.${key}
.
-
If the module is published, apply the
org.kodein.library.jvm
plugin. -
If the module is internal to the project, apply the
org.kodein.jvm
plugin.
-
If the module is published, apply the
org.kodein.library.android
plugin. -
If the module is internal to the project, apply the
org.kodein.android
plugin.
-
Global:
-
Same benefits as the JVM plugin.
-
Configures Android compile and min sdk version.
-
Adds Espresso to test dependencies.
-
Configures Android JUnit test runner.
-
Library:
-
Creates AAR maven artifacts (with source jar).
-
Adds
org.kodein.upload.module
plugin and theandroid-maven-publish
plugin.
-
If the module is published:
-
If the module targets Android, apply the
org.kodein.library.mpp-with-android
plugin. -
If the module does not target Android, apply the
org.kodein.library.mpp
plugin. -
If the module is internal to the project:
-
If the module targets Android, apply the
org.kodein.mpp-with-android
plugin. -
If the module does not target Android, apply the
org.kodein.mpp
plugin.
-
Global:
-
Adds multiple shortcut helpers to the Kotlin targets & source sets configuration DSL.
-
Adds multiple intermediate source sets depending on active targets, and ease the creation of new ones.
-
Enables same benefits for the JVM target as the JVM module plugin.
-
Configures test tasks to display in console.
-
Adds default test dependencies.
-
Excludes targets based on local properties (for example if you don’t want to compile Android).
-
Disables native cross compilation (by default).
-
Enables both js compiler by default (legacy and IR).
-
Adds the
hostOnlyTest
gradle task that starts only host native tests. -
Library:
-
Adds
org.kodein.upload.module
plugin. -
Sets the explicit API Kotlin option.
kotlin.kodein {
common { // Helper to access the common sourcesets
mainDependencies {}
testDependencies {}
}
all() // Adds all supported target
allNative {
compilation.main
.cinterops
.create("libleveldb") {}
sources.MainDependencies {}
sources.TestDependencies {}
}
}
Note that you should NOT use kotlin.*
to add a new target.
kodeinAndroid.android {
/* standard android configuration */
}
if (kodeinAndroid.isIncluded) {
/* Whatever gradle conf only enabled if Android is enabled */
}
The kodeinAndroid
helper is needed to disable Android configuration if Android is an excluded target.
You can exclude targets from being configured / compiled. For example: you can exclude the Android target if you don’t have an Android SDK installation.
Excluded targets are configured via the excludeTargets
kodein local property.
You can exclude:
-
Regular targets (such as
android
,iosArm32
,js
). -
A list of targets. Available are:
all-native
,all-jvm
,all-js
,nativeNonHost
.
You can exclude multiple targets with a coma separated list:
excludeTargets = nativeNonHost, android
Apply the org.kodein.gradle-plugin
plugin.
You also should apply the kotlin-dsl
plugin as it does not come bundled.