diff --git a/.gitignore b/.gitignore
index 089363e..b8402a4 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,9 @@ out/
.gradle/
build/
+# Kotlin
+.kotlin
+
# Signing files
.signing/
diff --git a/README.md b/README.md
index 03f99fd..a1afda5 100644
--- a/README.md
+++ b/README.md
@@ -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.
\ No newline at end of file
diff --git a/build.gradle b/build.gradle
index 864064c..838d320 100644
--- a/build.gradle
+++ b/build.gradle
@@ -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'
}
diff --git a/fastlane/README.md b/fastlane/README.md
deleted file mode 100644
index 0dbe80b..0000000
--- a/fastlane/README.md
+++ /dev/null
@@ -1,48 +0,0 @@
-fastlane documentation
-----
-
-# Installation
-
-Make sure you have the latest version of the Xcode command line tools installed:
-
-```sh
-xcode-select --install
-```
-
-For _fastlane_ installation instructions, see [Installing _fastlane_](https://docs.fastlane.tools/#installing-fastlane)
-
-# Available Actions
-
-## Android
-
-### android deployPlugins
-
-```sh
-[bundle exec] fastlane android deployPlugins
-```
-
-Deploy plugins to Gradle Portal.
-
-### android deployVersionCatalog
-
-```sh
-[bundle exec] fastlane android deployVersionCatalog
-```
-
-Deploy version catalog to Nexus.
-
-### android deployLocal
-
-```sh
-[bundle exec] fastlane android deployLocal
-```
-
-Deploy libraries to Maven locally on the PC.
-
-----
-
-This README.md is auto-generated and will be re-generated every time [_fastlane_](https://fastlane.tools) is run.
-
-More information about _fastlane_ can be found on [fastlane.tools](https://fastlane.tools).
-
-The documentation of _fastlane_ can be found on [docs.fastlane.tools](https://docs.fastlane.tools).
diff --git a/fastlane/report.xml b/fastlane/report.xml
deleted file mode 100644
index 70f926a..0000000
--- a/fastlane/report.xml
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml
index 7667804..95ec861 100644
--- a/gradle/libs.versions.toml
+++ b/gradle/libs.versions.toml
@@ -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"
@@ -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"
@@ -90,11 +88,7 @@ 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" }
@@ -102,7 +96,6 @@ androidx-activity-compose = { group = "androidx.activity", name = "activity-comp
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" }
@@ -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" }
@@ -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" }
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index a80b22c..a441313 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -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
diff --git a/plugins/build.gradle.kts b/plugins/build.gradle.kts
index bf3b794..21c0127 100644
--- a/plugins/build.gradle.kts
+++ b/plugins/build.gradle.kts
@@ -57,6 +57,7 @@ kotlin {
dependencies {
compileOnly(libs.android.gradlePlugin)
compileOnly(libs.kotlin.gradlePlugin)
+ compileOnly(libs.compose.gradlePlugin)
}
gradlePlugin {
@@ -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"))
}
}
}
diff --git a/plugins/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt b/plugins/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt
index d66357e..0c040cc 100644
--- a/plugins/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt
+++ b/plugins/src/main/kotlin/AndroidApplicationComposeConventionPlugin.kt
@@ -31,9 +31,9 @@
import com.android.build.api.dsl.ApplicationExtension
import no.nordicsemi.android.buildlogic.configureAndroidCompose
+import no.nordicsemi.android.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
-import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType
@@ -41,20 +41,17 @@ class AndroidApplicationComposeConventionPlugin : Plugin {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
- apply("no.nordicsemi.android.gradle.application")
- apply("no.nordicsemi.android.gradle.kotlin")
+ apply("no.nordicsemi.android.plugin.application")
+ apply("no.nordicsemi.android.plugin.kotlin")
+ apply("org.jetbrains.kotlin.plugin.compose")
}
val extension = extensions.getByType()
configureAndroidCompose(extension)
- val libs = extensions.getByType().named("libs")
dependencies {
// Add Material 3 Compose
add("implementation", libs.findLibrary("androidx.compose.material3").get())
- // Add UI Tooling and Previews
- add("debugImplementation", libs.findLibrary("androidx.compose.ui.tooling").get())
- add("implementation", libs.findLibrary("androidx.compose.ui.tooling.preview").get())
}
}
}
diff --git a/plugins/src/main/kotlin/AndroidApplicationConventionPlugin.kt b/plugins/src/main/kotlin/AndroidApplicationConventionPlugin.kt
index 3e6cebd..4e95909 100644
--- a/plugins/src/main/kotlin/AndroidApplicationConventionPlugin.kt
+++ b/plugins/src/main/kotlin/AndroidApplicationConventionPlugin.kt
@@ -30,9 +30,7 @@
*/
import com.android.build.api.dsl.ApplicationExtension
-import com.android.build.api.variant.ApplicationAndroidComponentsExtension
import no.nordicsemi.android.AppConst
-import no.nordicsemi.android.buildlogic.configurePrintApksTask
import no.nordicsemi.android.buildlogic.getVersionCodeFromTags
import no.nordicsemi.android.buildlogic.getVersionNameFromTags
import org.gradle.api.Plugin
@@ -92,9 +90,6 @@ class AndroidApplicationConventionPlugin : Plugin {
}
}
}
- extensions.configure {
- configurePrintApksTask(this)
- }
}
}
}
\ No newline at end of file
diff --git a/plugins/src/main/kotlin/AndroidFeatureConventionPlugin.kt b/plugins/src/main/kotlin/AndroidFeatureConventionPlugin.kt
index 2c66255..469d401 100644
--- a/plugins/src/main/kotlin/AndroidFeatureConventionPlugin.kt
+++ b/plugins/src/main/kotlin/AndroidFeatureConventionPlugin.kt
@@ -29,21 +29,19 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import no.nordicsemi.android.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
-import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
-import org.gradle.kotlin.dsl.getByType
class AndroidFeatureConventionPlugin : Plugin {
override fun apply(target: Project) {
with(target) {
pluginManager.apply {
- apply("no.nordicsemi.android.gradle.library.compose")
- apply("no.nordicsemi.android.gradle.hilt")
+ apply("no.nordicsemi.android.plugin.library.compose")
+ apply("no.nordicsemi.android.plugin.hilt")
}
- val libs = extensions.getByType().named("libs")
dependencies {
add("implementation", libs.findLibrary("androidx.hilt.navigation.compose").get())
// The above library depends on the following libraries, but to keep them in the
diff --git a/plugins/src/main/kotlin/AndroidHiltConventionPlugin.kt b/plugins/src/main/kotlin/AndroidHiltConventionPlugin.kt
index 4e8767c..49b7b86 100644
--- a/plugins/src/main/kotlin/AndroidHiltConventionPlugin.kt
+++ b/plugins/src/main/kotlin/AndroidHiltConventionPlugin.kt
@@ -29,22 +29,20 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+import no.nordicsemi.android.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
-import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
-import org.gradle.kotlin.dsl.getByType
class AndroidHiltConventionPlugin : Plugin {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
- apply("no.nordicsemi.android.gradle.kotlin")
+ apply("no.nordicsemi.android.plugin.kotlin")
apply("org.jetbrains.kotlin.kapt")
apply("dagger.hilt.android.plugin")
}
- val libs = extensions.getByType().named("libs")
dependencies {
add("implementation", libs.findLibrary("hilt.android").get())
add("kapt", libs.findLibrary("hilt.compiler").get())
diff --git a/plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt b/plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt
index bd25253..c1dfb30 100644
--- a/plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt
+++ b/plugins/src/main/kotlin/AndroidKotlinConventionPlugin.kt
@@ -31,14 +31,10 @@
import com.android.build.api.dsl.ApplicationExtension
import com.android.build.gradle.LibraryExtension
-import no.nordicsemi.android.buildlogic.configureAndroidCompose
import no.nordicsemi.android.buildlogic.configureKotlinAndroid
import org.gradle.api.Plugin
import org.gradle.api.Project
-import org.gradle.api.artifacts.VersionCatalogsExtension
-import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.findByType
-import org.gradle.kotlin.dsl.getByType
class AndroidKotlinConventionPlugin : Plugin {
override fun apply(target: Project) {
diff --git a/plugins/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt b/plugins/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt
index 788ee27..042bc39 100644
--- a/plugins/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt
+++ b/plugins/src/main/kotlin/AndroidLibraryComposeConventionPlugin.kt
@@ -31,9 +31,9 @@
import com.android.build.gradle.LibraryExtension
import no.nordicsemi.android.buildlogic.configureAndroidCompose
+import no.nordicsemi.android.buildlogic.libs
import org.gradle.api.Plugin
import org.gradle.api.Project
-import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.dependencies
import org.gradle.kotlin.dsl.getByType
@@ -41,20 +41,17 @@ class AndroidLibraryComposeConventionPlugin : Plugin {
override fun apply(target: Project) {
with(target) {
with(pluginManager) {
- apply("no.nordicsemi.android.gradle.library")
- apply("no.nordicsemi.android.gradle.kotlin")
+ apply("no.nordicsemi.android.plugin.library")
+ apply("no.nordicsemi.android.plugin.kotlin")
+ apply("org.jetbrains.kotlin.plugin.compose")
}
val extension = extensions.getByType()
configureAndroidCompose(extension)
- val libs = extensions.getByType().named("libs")
dependencies {
// Add Material 3 Compose
add("implementation", libs.findLibrary("androidx.compose.material3").get())
- // Add UI Tooling and Previews
- add("debugImplementation", libs.findLibrary("androidx.compose.ui.tooling").get())
- add("implementation", libs.findLibrary("androidx.compose.ui.tooling.preview").get())
}
}
}
diff --git a/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt b/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt
index 8b8edc4..cd1fe0a 100644
--- a/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt
+++ b/plugins/src/main/kotlin/AndroidLibraryConventionPlugin.kt
@@ -29,17 +29,13 @@
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-import com.android.build.api.variant.LibraryAndroidComponentsExtension
import com.android.build.gradle.LibraryExtension
import no.nordicsemi.android.AppConst
-import no.nordicsemi.android.buildlogic.configurePrintApksTask
import no.nordicsemi.android.buildlogic.getVersionCodeFromTags
import no.nordicsemi.android.buildlogic.getVersionNameFromTags
import org.gradle.api.Plugin
import org.gradle.api.Project
-import org.gradle.api.artifacts.VersionCatalogsExtension
import org.gradle.kotlin.dsl.configure
-import org.gradle.kotlin.dsl.getByType
class AndroidLibraryConventionPlugin : Plugin {
override fun apply(target: Project) {
@@ -82,18 +78,6 @@ class AndroidLibraryConventionPlugin : Plugin {
}
}
}
-
- extensions.configure {
- configurePrintApksTask(this)
- }
- val libs = extensions.getByType().named("libs")
- configurations.configureEach {
- resolutionStrategy {
- force(libs.findLibrary("junit4").get())
- // Temporary workaround for https://issuetracker.google.com/174733673
- force("org.objenesis:objenesis:2.6")
- }
- }
}
}
}
\ No newline at end of file
diff --git a/plugins/src/main/kotlin/AndroidNexusRepositoryPlugin.kt b/plugins/src/main/kotlin/AndroidNexusRepositoryPlugin.kt
index 5c63454..93181da 100644
--- a/plugins/src/main/kotlin/AndroidNexusRepositoryPlugin.kt
+++ b/plugins/src/main/kotlin/AndroidNexusRepositoryPlugin.kt
@@ -77,6 +77,7 @@ class AndroidNexusRepositoryPlugin : Plugin {
publishing {
repositories {
maven {
+ name = "sonatype"
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSR_USERNAME")
@@ -85,7 +86,7 @@ class AndroidNexusRepositoryPlugin : Plugin {
}
}
publications {
- val publication = create("mavenPublication", MavenPublication::class.java) {
+ val publication = create("library", MavenPublication::class.java) {
// Set publication properties.
with (nexusPluginExt) {
artifactId = POM_ARTIFACT_ID
diff --git a/plugins/src/main/kotlin/JvmKotlinConventionPlugin.kt b/plugins/src/main/kotlin/JvmKotlinConventionPlugin.kt
new file mode 100644
index 0000000..7fa8f28
--- /dev/null
+++ b/plugins/src/main/kotlin/JvmKotlinConventionPlugin.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2022, Nordic Semiconductor
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
+ *
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+import no.nordicsemi.android.buildlogic.configureKotlinJvm
+import org.gradle.api.Plugin
+import org.gradle.api.Project
+
+class JvmKotlinConventionPlugin : Plugin {
+ override fun apply(target: Project) {
+ with(target) {
+ with(pluginManager) {
+ apply("org.jetbrains.kotlin.jvm")
+ }
+
+ configureKotlinJvm()
+ }
+ }
+}
\ No newline at end of file
diff --git a/plugins/src/main/kotlin/KotlinNexusRepositoryPlugin.kt b/plugins/src/main/kotlin/JvmNexusRepositoryPlugin.kt
similarity index 96%
rename from plugins/src/main/kotlin/KotlinNexusRepositoryPlugin.kt
rename to plugins/src/main/kotlin/JvmNexusRepositoryPlugin.kt
index f741a52..4574ade 100644
--- a/plugins/src/main/kotlin/KotlinNexusRepositoryPlugin.kt
+++ b/plugins/src/main/kotlin/JvmNexusRepositoryPlugin.kt
@@ -43,7 +43,7 @@ import org.gradle.kotlin.dsl.get
import org.gradle.kotlin.dsl.getByType
import org.gradle.plugins.signing.SigningExtension
-class KotlinNexusRepositoryPlugin : Plugin {
+class JvmNexusRepositoryPlugin : Plugin {
override fun apply(target: Project) {
with(target) {
@@ -73,6 +73,7 @@ class KotlinNexusRepositoryPlugin : Plugin {
publishing {
repositories {
maven {
+ name = "sonatype"
setUrl("https://oss.sonatype.org/service/local/staging/deploy/maven2/")
credentials {
username = System.getenv("OSSR_USERNAME")
@@ -81,7 +82,7 @@ class KotlinNexusRepositoryPlugin : Plugin {
}
}
publications {
- val publication = create("mavenPublication", MavenPublication::class.java) {
+ val publication = create("library", MavenPublication::class.java) {
// Set publication properties.
with (nexusPluginExt) {
artifactId = POM_ARTIFACT_ID
diff --git a/plugins/src/main/kotlin/no/nordicsemi/android/AppConsts.kt b/plugins/src/main/kotlin/no/nordicsemi/android/AppConsts.kt
index 3de5703..c27b3e0 100644
--- a/plugins/src/main/kotlin/no/nordicsemi/android/AppConsts.kt
+++ b/plugins/src/main/kotlin/no/nordicsemi/android/AppConsts.kt
@@ -4,4 +4,4 @@ object AppConst {
const val MIN_SDK = 21
const val COMPILE_SDK = 34
const val TARGET_SDK = 34
-}
+}
\ No newline at end of file
diff --git a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/AndroidCompose.kt b/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/AndroidCompose.kt
index 15561dd..e66cacd 100644
--- a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/AndroidCompose.kt
+++ b/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/AndroidCompose.kt
@@ -36,8 +36,8 @@ package no.nordicsemi.android.buildlogic
import com.android.build.api.dsl.CommonExtension
import org.gradle.api.Project
import org.gradle.kotlin.dsl.dependencies
-import org.gradle.kotlin.dsl.withType
-import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
+import org.gradle.kotlin.dsl.configure
+import org.jetbrains.kotlin.compose.compiler.gradle.ComposeCompilerGradlePluginExtension
/**
* Configure Compose-specific options
@@ -50,48 +50,19 @@ internal fun Project.configureAndroidCompose(
compose = true
}
- composeOptions {
- kotlinCompilerExtensionVersion = libs.findVersion("androidxComposeCompiler").get().toString()
- }
-
dependencies {
val bom = libs.findLibrary("androidx-compose-bom").get()
add("implementation", platform(bom))
add("androidTestImplementation", platform(bom))
+ // Add UI Tooling and Previews
+ add("implementation", libs.findLibrary("androidx.compose.ui.tooling.preview").get())
+ add("debugImplementation", libs.findLibrary("androidx.compose.ui.tooling").get())
}
}
- tasks.withType().configureEach {
- kotlinOptions {
- freeCompilerArgs = freeCompilerArgs + buildComposeMetricsParameters()
- }
- }
-}
-
-private fun Project.buildComposeMetricsParameters(): List {
- val metricParameters = mutableListOf()
- val enableMetricsProvider = project.providers.gradleProperty("enableComposeCompilerMetrics")
- val relativePath = projectDir.relativeTo(rootDir)
-
- val enableMetrics = (enableMetricsProvider.orNull == "true")
- if (enableMetrics) {
- val buildDir = rootProject.layout.buildDirectory.asFile.get()
- val metricsFolder = buildDir.resolve("compose-metrics").resolve(relativePath)
- metricParameters.add("-P")
- metricParameters.add(
- "plugin:androidx.compose.compiler.plugins.kotlin:metricsDestination=" + metricsFolder.absolutePath
- )
- }
-
- val enableReportsProvider = project.providers.gradleProperty("enableComposeCompilerReports")
- val enableReports = (enableReportsProvider.orNull == "true")
- if (enableReports) {
- val buildDir = rootProject.layout.buildDirectory.asFile.get()
- val reportsFolder = buildDir.resolve("compose-reports").resolve(relativePath)
- metricParameters.add("-P")
- metricParameters.add(
- "plugin:androidx.compose.compiler.plugins.kotlin:reportsDestination=" + reportsFolder.absolutePath
- )
+ extensions.configure {
+ // Enable strong skipping mode for Compose
+ // https://github.com/JetBrains/kotlin/blob/master/plugins/compose/design/strong-skipping.md
+ enableStrongSkippingMode.set(true)
}
- return metricParameters.toList()
}
diff --git a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/Jacoco.kt b/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/Jacoco.kt
deleted file mode 100644
index 097bc00..0000000
--- a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/Jacoco.kt
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (c) 2022, Nordic Semiconductor
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package no.nordicsemi.android.buildlogic
-
-import com.android.build.api.variant.AndroidComponentsExtension
-import org.gradle.api.Project
-import org.gradle.api.tasks.testing.Test
-import org.gradle.kotlin.dsl.configure
-import org.gradle.kotlin.dsl.register
-import org.gradle.kotlin.dsl.withType
-import org.gradle.testing.jacoco.plugins.JacocoPluginExtension
-import org.gradle.testing.jacoco.plugins.JacocoTaskExtension
-import org.gradle.testing.jacoco.tasks.JacocoReport
-import java.util.Locale
-
-private val coverageExclusions = listOf(
- // Android
- "**/R.class",
- "**/R\$*.class",
- "**/BuildConfig.*",
- "**/Manifest*.*"
-)
-
-private fun String.capitalize() = replaceFirstChar {
- if (it.isLowerCase()) it.titlecase(Locale.getDefault()) else it.toString()
-}
-
-internal fun Project.configureJacoco(
- androidComponentsExtension: AndroidComponentsExtension<*, *, *>,
-) {
- configure {
- toolVersion = libs.findVersion("jacoco").get().toString()
- }
-
- val jacocoTestReport = tasks.create("jacocoTestReport")
-
- androidComponentsExtension.onVariants { variant ->
- val testTaskName = "test${variant.name.capitalize()}UnitTest"
-
- val reportTask = tasks.register("jacoco${testTaskName.capitalize()}Report", JacocoReport::class) {
- dependsOn(testTaskName)
-
- reports {
- xml.required.set(true)
- html.required.set(true)
- }
-
- val buildDir = rootProject.layout.buildDirectory.asFile.get()
- classDirectories.setFrom(
- fileTree("$buildDir/tmp/kotlin-classes/${variant.name}") {
- exclude(coverageExclusions)
- }
- )
-
- sourceDirectories.setFrom(files("$projectDir/src/main/java", "$projectDir/src/main/kotlin"))
- executionData.setFrom(file("$buildDir/jacoco/$testTaskName.exec"))
- }
-
- jacocoTestReport.dependsOn(reportTask)
- }
-
- tasks.withType().configureEach {
- configure {
- // Required for JaCoCo + Robolectric
- // https://github.com/robolectric/robolectric/issues/2230
- // TODO: Consider removing if not we don't add Robolectric
- isIncludeNoLocationClasses = true
-
- // Required for JDK 11 with the above
- // https://github.com/gradle/gradle/issues/5184#issuecomment-391982009
- excludes = listOf("jdk.internal.*")
- }
- }
-}
diff --git a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/KotlinAndroid.kt b/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/KotlinAndroid.kt
index a2d6729..e3d69b5 100644
--- a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/KotlinAndroid.kt
+++ b/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/KotlinAndroid.kt
@@ -34,12 +34,17 @@ package no.nordicsemi.android.buildlogic
import com.android.build.api.dsl.CommonExtension
import org.gradle.api.JavaVersion
import org.gradle.api.Project
-import org.gradle.api.plugins.ExtensionAware
+import org.gradle.api.plugins.JavaPluginExtension
+import org.gradle.kotlin.dsl.configure
import org.gradle.kotlin.dsl.provideDelegate
-import org.jetbrains.kotlin.gradle.dsl.KotlinJvmOptions
+import org.jetbrains.kotlin.gradle.dsl.JvmTarget
+import org.jetbrains.kotlin.gradle.dsl.KotlinAndroidProjectExtension
+import org.jetbrains.kotlin.gradle.dsl.KotlinJvmProjectExtension
+import org.jetbrains.kotlin.gradle.dsl.KotlinTopLevelExtension
+import org.jetbrains.kotlin.gradle.dsl.KotlinVersion
/**
- * Configure base Kotlin with Android options
+ * Configure base Kotlin with Android options.
*/
internal fun Project.configureKotlinAndroid(
commonExtension: CommonExtension<*, *, *, *, *, *>,
@@ -50,26 +55,42 @@ internal fun Project.configureKotlinAndroid(
targetCompatibility = JavaVersion.VERSION_17
}
- kotlinOptions {
- // Treat all Kotlin warnings as errors (disabled by default)
- // Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties
- val warningsAsErrors: String? by project
- allWarningsAsErrors = warningsAsErrors.toBoolean()
-
- freeCompilerArgs = freeCompilerArgs + listOf(
- "-opt-in=kotlin.RequiresOptIn",
- // Enable experimental coroutines APIs, including Flow
- "-opt-in=kotlinx.coroutines.ExperimentalCoroutinesApi",
- "-opt-in=kotlinx.coroutines.FlowPreview",
- "-opt-in=kotlin.Experimental",
- )
+ configureKotlin()
+ }
+}
- // Set JVM target to 1.17
- jvmTarget = JavaVersion.VERSION_17.toString()
- }
+/**
+ * Configure base Kotlin options for JVM (non-Android)
+ */
+internal fun Project.configureKotlinJvm() {
+ extensions.configure {
+ sourceCompatibility = JavaVersion.VERSION_17
+ targetCompatibility = JavaVersion.VERSION_17
}
+
+ configureKotlin()
}
-fun CommonExtension<*, *, *, *, *, *>.kotlinOptions(block: KotlinJvmOptions.() -> Unit) {
- (this as ExtensionAware).extensions.configure("kotlinOptions", block)
+/**
+ * Configure base Kotlin options.
+ */
+private inline fun Project.configureKotlin() = configure {
+ // Treat all Kotlin warnings as errors (disabled by default)
+ // Override by setting warningsAsErrors=true in your ~/.gradle/gradle.properties
+ val warningsAsErrors: String? by project
+
+ when (this) {
+ is KotlinAndroidProjectExtension -> compilerOptions
+ is KotlinJvmProjectExtension -> compilerOptions
+ else -> TODO("Unsupported project extension $this ${T::class}")
+ }.apply {
+ allWarningsAsErrors.set(warningsAsErrors.toBoolean())
+
+ languageVersion.set(KotlinVersion.KOTLIN_2_0)
+ apiVersion.set(KotlinVersion.KOTLIN_2_0)
+ jvmTarget.set(JvmTarget.JVM_17)
+ optIn.add("kotlin.RequiresOptIn")
+ optIn.add("kotlinx.coroutines.ExperimentalCoroutinesApi")
+ optIn.add("kotlinx.coroutines.FlowPreview")
+ }
}
diff --git a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/PrintTestApks.kt b/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/PrintTestApks.kt
deleted file mode 100644
index b6f482f..0000000
--- a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/PrintTestApks.kt
+++ /dev/null
@@ -1,115 +0,0 @@
-/*
- * Copyright (c) 2022, Nordic Semiconductor
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without modification, are
- * permitted provided that the following conditions are met:
- *
- * 1. Redistributions of source code must retain the above copyright notice, this list of
- * conditions and the following disclaimer.
- *
- * 2. Redistributions in binary form must reproduce the above copyright notice, this list
- * of conditions and the following disclaimer in the documentation and/or other materials
- * provided with the distribution.
- *
- * 3. Neither the name of the copyright holder nor the names of its contributors may be
- * used to endorse or promote products derived from this software without specific prior
- * written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
- * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
- * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
- * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
- * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
- * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-@file:Suppress("UnstableApiUsage")
-
-package no.nordicsemi.android.buildlogic
-
-import com.android.build.api.artifact.SingleArtifact
-import com.android.build.api.variant.AndroidComponentsExtension
-import com.android.build.api.variant.BuiltArtifactsLoader
-import com.android.build.api.variant.HasAndroidTest
-import org.gradle.api.DefaultTask
-import org.gradle.api.Project
-import org.gradle.api.file.Directory
-import org.gradle.api.file.DirectoryProperty
-import org.gradle.api.provider.ListProperty
-import org.gradle.api.provider.Property
-import org.gradle.api.tasks.Input
-import org.gradle.api.tasks.InputDirectory
-import org.gradle.api.tasks.InputFiles
-import org.gradle.api.tasks.Internal
-import org.gradle.api.tasks.TaskAction
-import java.io.File
-
-internal fun Project.configurePrintApksTask(extension: AndroidComponentsExtension<*, *, *>) {
- extension.onVariants { variant ->
- if (variant is HasAndroidTest) {
- val loader = variant.artifacts.getBuiltArtifactsLoader()
- val artifact = variant.androidTest?.artifacts?.get(SingleArtifact.APK)
- val javaSources = variant.androidTest?.sources?.java?.all
- val kotlinSources = variant.androidTest?.sources?.kotlin?.all
-
- val testSources = if (javaSources != null && kotlinSources != null) {
- javaSources.zip(kotlinSources) { javaDirs, kotlinDirs ->
- javaDirs + kotlinDirs
- }
- } else javaSources ?: kotlinSources
-
- if (artifact != null && testSources != null) {
- tasks.register(
- "${variant.name}PrintTestApk",
- PrintApkLocationTask::class.java
- ) {
- apkFolder.set(artifact)
- builtArtifactsLoader.set(loader)
- variantName.set(variant.name)
- sources.set(testSources)
- }
- }
- }
- }
-}
-
-internal abstract class PrintApkLocationTask : DefaultTask() {
- @get:InputDirectory
- abstract val apkFolder: DirectoryProperty
-
- @get:InputFiles
- abstract val sources: ListProperty
-
- @get:Internal
- abstract val builtArtifactsLoader: Property
-
- @get:Input
- abstract val variantName: Property
-
- @TaskAction
- fun taskAction() {
- val hasFiles = sources.orNull?.any { directory ->
- directory.asFileTree.files.any {
- it.isFile && it.parentFile.path.contains("build${File.separator}generated").not()
- }
- } ?: throw RuntimeException("Cannot check androidTest sources")
-
- // Don't print APK location if there are no androidTest source files
- if (!hasFiles) {
- return
- }
-
- val builtArtifacts = builtArtifactsLoader.get().load(apkFolder.get())
- ?: throw RuntimeException("Cannot load APKs")
- if (builtArtifacts.elements.size != 1)
- throw RuntimeException("Expected one APK !")
- val apk = File(builtArtifacts.elements.single().outputFile).toPath()
- println(apk)
- }
-}
\ No newline at end of file
diff --git a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/ProjectExtensions.kt b/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/ProjectExtensions.kt
index c74e5b9..c7ba641 100644
--- a/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/ProjectExtensions.kt
+++ b/plugins/src/main/kotlin/no/nordicsemi/android/buildlogic/ProjectExtensions.kt
@@ -1,17 +1,32 @@
/*
- * Copyright 2023 The Android Open Source Project
+ * Copyright (c) 2022, Nordic Semiconductor
+ * All rights reserved.
*
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
+ * Redistribution and use in source and binary forms, with or without modification, are
+ * permitted provided that the following conditions are met:
*
- * https://www.apache.org/licenses/LICENSE-2.0
+ * 1. Redistributions of source code must retain the above copyright notice, this list of
+ * conditions and the following disclaimer.
*
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ * 2. Redistributions in binary form must reproduce the above copyright notice, this list
+ * of conditions and the following disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ *
+ * 3. Neither the name of the copyright holder nor the names of its contributors may be
+ * used to endorse or promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+ * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
+ * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package no.nordicsemi.android.buildlogic
diff --git a/renovate.json b/renovate.json
index 527d26f..9dd1fb0 100644
--- a/renovate.json
+++ b/renovate.json
@@ -10,15 +10,14 @@
"packageRules": [
{
"matchPackagePatterns": [
- "androidx.compose.compiler:compiler",
"com.google.devtools.ksp",
- "org.jetbrains.kotlin.*",
- "^androidx.compose.compiler"
+ "org.jetbrains.kotlin.*"
],
"groupName": "kotlin"
},
{
"matchPackageNames": [
+ "org.slf4j:slf4j-api",
"org.slf4j:slf4j-simple"
],
"enabled": false