Skip to content

Commit

Permalink
Merge pull request #238 from NordicSemiconductor/kotlin2
Browse files Browse the repository at this point in the history
Migration to Kotlin 2.0.0
  • Loading branch information
philips77 authored Jun 20, 2024
2 parents ce83ed0 + 3c50b39 commit fb3bdb0
Show file tree
Hide file tree
Showing 25 changed files with 269 additions and 464 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ out/
.gradle/
build/

# Kotlin
.kotlin

# Signing files
.signing/

Expand Down
91 changes: 77 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,25 +1,88 @@
# Nordic Gradle Plugins for Android

The repo contains plugins which are shared between Nordic's Android applications.
[Now in Android app](https://github.com/android/nowinandroid) from Google has been an inspiration for writing Nordic's dedicated plugins.
[Now in Android app](https://github.com/android/nowinandroid) from Google has been an inspiration
for writing Nordic's dedicated plugins.

## Plugins

List of plugins currently available in the repository:
List of plugins currently available in the repository.

1. [no.nordicsemi.android.application](plugins/src/main/kotlin/AndroidApplicationConventionPlugin.kt)
2. [no.nordicsemi.android.application.compose](plugins/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt)
3. [no.nordicsemi.android.library](plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt)
4. [no.nordicsemi.android.library.compose](plugins/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt)
5. [no.nordicsemi.android.feature](plugins/src/main/kotlin/AndroidFeatureConventionPlugin.kt)
6. [no.nordicsemi.android.kotlin](plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt)
7. [no.nordicsemi.android.hilt](plugins/src/main/kotlin/AndroidHiltConventionPlugin.kt)
8. [no.nordicsemi.android.gradle.nexus](plugins/src/main/kotlin/AndroidNexusRepositoryPlugin.kt)
9. [no.nordicsemi.kotlin.gradle.nexus](plugins/src/main/kotlin/KotlinNexusRepositoryPlugin.kt)
### Android plugins

Plugins are released to Nexus repository and are available by their ids and version number.
1. [no.nordicsemi.android.plugin.application](plugins/src/main/kotlin/AndroidApplicationConventionPlugin.kt)

This plugin does the following:
* applies `com.android.application`,
* defines `compileSdk`, `minSdk` and `targetSdk` to values set in
[`AppConsts`](https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/kotlin2/plugins/src/main/kotlin/no/nordicsemi/android/AppConsts.kt),
* sets `buildConfig`,
* configures _debug_ and _release_ build types,
* creates app signing configuration using `../keystore` file which is generated by GitHub actions during build.

2. [no.nordicsemi.android.plugin.application.compose](plugins/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt)

This plugin applies `no.nordicsemi.android.plugin.application` and adds Compose and Material3 dependency.

Since version 2.1 [`enableStrongSkippingMode`](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compiler.html#enablestrongskippingmode) is
[enabled](https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/6ee70d9f2fb2c2c8474067845eac05308740afa8/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/AndroidCompose.kt#L66).

3. [no.nordicsemi.android.plugin.library](plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt)

This plugin does the following:
* applies `com.android.library`,
* defines `compileSdk` and `minSdk` to values set in
[`AppConsts`](https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/kotlin2/plugins/src/main/kotlin/no/nordicsemi/android/AppConsts.kt),
* sets `buildConfig`,
* configures _debug_ and _release_ build types.

4. [no.nordicsemi.android.plugin.library.compose](plugins/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt)

This plugin applies `no.nordicsemi.android.plugin.library` and adds Compose and Material3 dependency.

Since version 2.1 [`enableStrongSkippingMode`](https://www.jetbrains.com/help/kotlin-multiplatform-dev/compose-compiler.html#enablestrongskippingmode) is
[enabled](https://github.com/NordicSemiconductor/Android-Gradle-Plugins/blob/6ee70d9f2fb2c2c8474067845eac05308740afa8/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/AndroidCompose.kt#L66).

5. [no.nordicsemi.android.plugin.kotlin](plugins/src/main/kotlin/AndroidNexusRepositoryPlugin.kt)

This plugin applies `org.jetbrains.kotlin.android` and configures Kotlin compiler.

7. [no.nordicsemi.android.plugin.hilt](plugins/src/main/kotlin/AndroidHiltConventionPlugin.kt)

This plugin applies `no.nordicsemi.android.plugin.kotlin` and `org.jetbrains.kotlin.kapt` and
configures [Hilt](https://dagger.dev/hilt/) for the module.

9. [no.nordicsemi.android.plugin.feature](plugins/src/main/kotlin/AndroidFeatureConventionPlugin.kt)

This plugin applies:
* `no.nordicsemi.android.plugin.library.compose`
* `no.nordicsemi.android.plugin.hilt`
* `no.nordicsemi.android.plugin.kotlin`

and adds dependency to `androidx.hilt.navigation.compose`.

10. [no.nordicsemi.android.plugin.nexus](plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt)

Creates `publish` and `releaseStagingRepositories` tasks using `maven-publish`.

### JVM plugins

1. [no.nordicsemi.jvm.plugin.kotlin](plugins/src/main/kotlin/JvmKotlinConventionPlugin.kt) (since 2.1)

This plugin applies `org.jetbrains.kotlin.jvm` and configures Kotlin compiler.

2. [no.nordicsemi.jvm.plugin.nexus](plugins/src/main/kotlin/JvmNexusRepositoryPlugin.kt) (since 2.0)

Creates `publish` and `releaseStagingRepositories` tasks using `maven-publish`.

Plugins are released to [Gradle Plugins](https://plugins.gradle.org/search?term=no.nordicsemi) repository
and are available by their ids and version number.

> [!Note]
> Version 2.1 altered ids of the plugins by replacing `gradle` with `plugin`.
## Version catalog

The repository also contains Gradle Version Catalog which consumes [toml](gradle/libs.versions.toml) file.
The file is automatically used by gradle to create libs reference in gradle.kts files because it is located in gradle directory.
No additional set up is required.
The file is automatically used by gradle to create libs reference in gradle.kts files because it
is located in gradle directory. No additional set up is required.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id 'org.jetbrains.kotlin.android' version '1.9.20' apply false
id 'org.jetbrains.kotlin.android' version '2.0.0' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
}

Expand Down
48 changes: 0 additions & 48 deletions fastlane/README.md

This file was deleted.

18 changes: 0 additions & 18 deletions fastlane/report.xml

This file was deleted.

36 changes: 16 additions & 20 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ androidxActivity = "1.9.0"
androidxAnnotation = "1.8.0"
androidxAppCompat = "1.7.0"
androidxComposeBom = "2024.06.00" # https://developer.android.com/jetpack/compose/bom/bom-mapping
androidxComposeCompiler = "1.5.14" # https://developer.android.com/jetpack/androidx/releases/compose-kotlin
androidxComposeRuntimeTracing = "1.0.0-beta01"
androidxCore = "1.13.1"
androidxCoreSplashscreen = "1.0.1"
Expand All @@ -32,12 +31,11 @@ coil = "2.6.0"
firebaseBom = "33.1.0"
hilt = "2.51.1"
hiltExt = "1.2.0"
jacoco = "0.8.7"
junit4 = "4.13.2"
kotlin = "1.9.24"
kotlinxCoroutines = "1.8.0"
kotlinxDatetime = "0.5.0"
kotlinxSerializationJson = "1.6.3"
kotlin = "2.0.0"
kotlinxCoroutines = "1.9.0-RC"
kotlinxDatetime = "0.6.0"
kotlinxSerializationJson = "1.7.0"
kotlinCompose = "1.6.11"
ksp = "1.9.24-1.0.20"
lint = "31.5.0"
Expand Down Expand Up @@ -90,19 +88,14 @@ firebaseCrashlyticsPlugins = "2.9.9"
kmmIosPublishPlugin = "2.0.3"

[libraries]
accompanist-flowlayout = { group = "com.google.accompanist", name = "accompanist-flowlayout", version.ref = "accompanist" }
accompanist-swiperefresh = { group = "com.google.accompanist", name = "accompanist-swiperefresh", version.ref = "accompanist" }
accompanist-systemuicontroller = { group = "com.google.accompanist", name = "accompanist-systemuicontroller", version.ref = "accompanist" }
accompanist-pager = { group = "com.google.accompanist", name = "accompanist-pager", version.ref = "accompanist" }
accompanist-pagerindicators = { group = "com.google.accompanist", name = "accompanist-pager-indicators", version.ref = "accompanist" }
accompanist-placeholder = { group = "com.google.accompanist", name = "accompanist-placeholder-material", version.ref = "accompanist" }
accompanist-permissions = { group = "com.google.accompanist", name = "accompanist-permissions", version.ref = "accompanist" }
android-desugarJdkLibs = { group = "com.android.tools", name = "desugar_jdk_libs", version.ref = "androidDesugarJdkLibs" }
androidx-activity-compose = { group = "androidx.activity", name = "activity-compose", version.ref = "androidxActivity" }
androidx-annotation = { group = "androidx.annotation", name = "annotation", version.ref = "androidxAnnotation" }
androidx-appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "androidxAppCompat" }
androidx-benchmark-macro = { group = "androidx.benchmark", name = "benchmark-macro-junit4", version.ref = "androidxMacroBenchmark" }
androidx-compose-compiler = { group = "androidx.compose.compiler", name = "compiler", version.ref = "androidxComposeCompiler" }
androidx-compose-bom = { group = "androidx.compose", name = "compose-bom", version.ref = "androidxComposeBom" }
androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation" }
androidx-compose-foundation-layout = { group = "androidx.compose.foundation", name = "foundation-layout" }
Expand Down Expand Up @@ -249,17 +242,19 @@ nordic-blek-uiscanner = { group = "no.nordicsemi.android.kotlin.ble", name = "ui
# Dependencies of the included build-logic
android-gradlePlugin = { group = "com.android.tools.build", name = "gradle", version.ref = "androidGradlePlugin" }
kotlin-gradlePlugin = { group = "org.jetbrains.kotlin", name = "kotlin-gradle-plugin", version.ref = "kotlin" }
compose-gradlePlugin = { module = "org.jetbrains.kotlin:compose-compiler-gradle-plugin", version.ref = "kotlin" }

[plugins]
nordic-application = { id = "no.nordicsemi.android.gradle.application", version.ref = "nordicPlugins" }
nordic-application-compose = { id = "no.nordicsemi.android.gradle.application.compose", version.ref = "nordicPlugins" }
nordic-library = { id = "no.nordicsemi.android.gradle.library", version.ref = "nordicPlugins" }
nordic-library-compose = { id = "no.nordicsemi.android.gradle.library.compose", version.ref = "nordicPlugins" }
nordic-feature = { id = "no.nordicsemi.android.gradle.feature", version.ref = "nordicPlugins" }
nordic-hilt = { id = "no.nordicsemi.android.gradle.hilt", version.ref = "nordicPlugins" }
nordic-kotlin = { id = "no.nordicsemi.android.gradle.kotlin", version.ref = "nordicPlugins" }
nordic-nexus-android = { id = "no.nordicsemi.android.gradle.nexus", version.ref = "nordicPlugins" }
nordic-nexus-kotlin = { id = "no.nordicsemi.kotlin.gradle.nexus", version.ref = "nordicPlugins" }
nordic-application = { id = "no.nordicsemi.android.plugin.application", version.ref = "nordicPlugins" }
nordic-application-compose = { id = "no.nordicsemi.android.plugin.application.compose", version.ref = "nordicPlugins" }
nordic-library = { id = "no.nordicsemi.android.plugin.library", version.ref = "nordicPlugins" }
nordic-library-compose = { id = "no.nordicsemi.android.plugin.library.compose", version.ref = "nordicPlugins" }
nordic-feature = { id = "no.nordicsemi.android.plugin.feature", version.ref = "nordicPlugins" }
nordic-hilt = { id = "no.nordicsemi.android.plugin.hilt", version.ref = "nordicPlugins" }
nordic-kotlin-android = { id = "no.nordicsemi.android.plugin.kotlin", version.ref = "nordicPlugins" }
nordic-kotlin-jvm = { id = "no.nordicsemi.jvm.plugin.kotlin", version.ref = "nordicPlugins" }
nordic-nexus-android = { id = "no.nordicsemi.android.plugin.nexus", version.ref = "nordicPlugins" }
nordic-nexus-kotlin = { id = "no.nordicsemi.jvm.plugin.nexus", version.ref = "nordicPlugins" }
android-application = { id = "com.android.application", version.ref = "androidGradlePlugin" }
android-library = { id = "com.android.library", version.ref = "androidGradlePlugin" }
android-test = { id = "com.android.test", version.ref = "androidGradlePlugin" }
Expand All @@ -273,6 +268,7 @@ kotlin-serialization = { id = "org.jetbrains.kotlin.plugin.serialization", versi
kotlin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
kotlin-multiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
kotlin-compose = { id = "org.jetbrains.compose", version.ref = "kotlinCompose" }
compose-compiler = { id = "org.jetbrains.kotlin.plugin.compose", version.ref = "kotlin" }
protobuf = { id = "com.google.protobuf", version.ref = "protobufPlugin" }
secrets = { id = "com.google.android.libraries.mapsplatform.secrets-gradle-plugin", version.ref = "secrets" }
publish = { id = "com.gradle.plugin-publish", version.ref = "publishPlugin" }
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.6-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
48 changes: 28 additions & 20 deletions plugins/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ kotlin {
dependencies {
compileOnly(libs.android.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
compileOnly(libs.compose.gradlePlugin)
}

gradlePlugin {
Expand All @@ -67,67 +68,74 @@ gradlePlugin {
gradlePlugin {
plugins {
register("android.application.compose") {
id = "no.nordicsemi.android.gradle.application.compose"
id = "no.nordicsemi.android.plugin.application.compose"
displayName = "Application with Compose"
description = "Application plugin extension with Compose and Material3 dependencies. This plugin includes 'application' plugin."
implementationClass = "AndroidApplicationComposeConventionPlugin"
tags.set(listOf("nordicsemi", "Android", "application", "compose"))
}
register("android.application") {
id = "no.nordicsemi.android.gradle.application"
id = "no.nordicsemi.android.plugin.application"
displayName = "Standalone Application configuration"
description = "Application plugin extension"
description = "Application plugin extension."
implementationClass = "AndroidApplicationConventionPlugin"
tags.set(listOf("nordicsemi", "Android", "application"))
}
register("android.library.compose") {
id = "no.nordicsemi.android.gradle.library.compose"
id = "no.nordicsemi.android.plugin.library.compose"
displayName = "Library with Compose"
description = "Library plugin extension with Compose and Material3 dependencies. This plugin extends 'library' plugin."
implementationClass = "AndroidLibraryComposeConventionPlugin"
tags.set(listOf("nordicsemi", "Android", "library", "compose"))
}
register("android.library") {
id = "no.nordicsemi.android.gradle.library"
id = "no.nordicsemi.android.plugin.library"
displayName = "Standalone library configuration"
description = "Library plugin extension"
description = "Library plugin extension."
implementationClass = "AndroidLibraryConventionPlugin"
tags.set(listOf("nordicsemi", "Android", "library"))
}
register("android.feature") {
id = "no.nordicsemi.android.gradle.feature"
id = "no.nordicsemi.android.plugin.feature"
displayName = "Feature plugin"
description = "UI feature plugin with Hilt & Compose. This plugin extends 'library.compose' and 'hilt' plugins and adds Compose navigation."
implementationClass = "AndroidFeatureConventionPlugin"
tags.set(listOf("nordicsemi", "Android", "feature"))
}
register("android.hilt") {
id = "no.nordicsemi.android.gradle.hilt"
id = "no.nordicsemi.android.plugin.hilt"
displayName = "Hilt plugin"
description = "Plugin enabling Hilt"
implementationClass = "AndroidHiltConventionPlugin"
tags.set(listOf("nordicsemi", "Android", "hilt"))
}
register("android.kotlin") {
id = "no.nordicsemi.android.gradle.kotlin"
displayName = "Kotlin plugin"
description = "Plugin enabling Kotlin"
id = "no.nordicsemi.android.plugin.kotlin"
displayName = "Kotlin plugin for Android modules"
description = "Plugin enabling Kotlin for Android modules."
implementationClass = "AndroidKotlinConventionPlugin"
tags.set(listOf("nordicsemi", "Android", "kotlin"))
}
register("jvm.kotlin") {
id = "no.nordicsemi.jvm.plugin.kotlin"
displayName = "Kotlin plugin for JVM projects"
description = "Plugin enabling Kotlin for JVM modules."
implementationClass = "JvmKotlinConventionPlugin"
tags.set(listOf("nordicsemi", "jvm", "kotlin"))
}
register("android.nexus") {
id = "no.nordicsemi.android.gradle.nexus"
displayName = "Nexus plugin"
description = "Plugin creating a task for publishing to Nexus repository."
id = "no.nordicsemi.android.plugin.nexus"
displayName = "Nexus plugin for Android projects"
description = "Plugin creating a task for publishing Android libraries to Nexus repository."
implementationClass = "AndroidNexusRepositoryPlugin"
tags.set(listOf("nordicsemi", "Android", "nexus", "publish"))
}
register("kotlin.nexus") {
id = "no.nordicsemi.kotlin.gradle.nexus"
displayName = "Nexus plugin"
description = "Plugin creating a task for publishing Kotlin library to Nexus repository."
implementationClass = "KotlinNexusRepositoryPlugin"
tags.set(listOf("nordicsemi", "kotlin", "nexus", "publish"))
register("jvm.nexus") {
id = "no.nordicsemi.jvm.plugin.nexus"
displayName = "Nexus plugin for JVM projects"
description = "Plugin creating a task for publishing JVM libraries to Nexus repository."
implementationClass = "JvmNexusRepositoryPlugin"
tags.set(listOf("nordicsemi", "jvm", "kotlin", "nexus", "publish"))
}
}
}
Expand Down
Loading

0 comments on commit fb3bdb0

Please sign in to comment.