Skip to content

NordicSemiconductor/Android-Gradle-Plugins

Repository files navigation

Nordic Gradle Plugins for Android

The repo contains plugins which are shared between Nordic's Android applications. Now in Android app from Google has been an inspiration for writing Nordic's dedicated plugins.

Plugins

Gradle Plugin Portal Version

List of plugins currently available in the repository.

Dokka plugin

  1. no.nordicsemi.dokka.plugin

    This plugin applies org.jetbrains.dokka and applies Nordic styles to Dokka documentation.

Android plugins

  1. no.nordicsemi.android.plugin.application

    This plugin does the following:

    • applies com.android.application,
    • defines compileSdk, minSdk and targetSdk to values set in AppConsts,
    • 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

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

  3. no.nordicsemi.android.plugin.library

    This plugin does the following:

    • applies com.android.library,
    • defines compileSdk and minSdk to values set in AppConsts,
    • sets buildConfig,
    • configures debug and release build types.
  4. no.nordicsemi.android.plugin.library.compose

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

  5. no.nordicsemi.android.plugin.kotlin

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

  6. no.nordicsemi.android.plugin.hilt

    This plugin applies no.nordicsemi.android.plugin.kotlin and com.google.devtools.ksp and configures Hilt for the module.

  7. no.nordicsemi.android.plugin.feature

    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.

  8. no.nordicsemi.android.plugin.nexus

Creates publish and releaseStagingRepositories tasks using maven-publish.

Since 2.6 Dokka V2 is enabled.

Add

org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled

to gradle.properties file.

JVM plugins

  1. no.nordicsemi.jvm.plugin.kotlin (since 2.1)

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

  2. no.nordicsemi.jvm.plugin.nexus (since 2.0)

    Creates publish and releaseStagingRepositories tasks using maven-publish.

Plugins are released to Gradle Plugins repository and are available by their ids and version number.

Note

Version 2.1 altered ids of the plugins by replacing gradle with plugin.

Since 2.6 Dokka V2 is enabled.

Add

org.jetbrains.dokka.experimental.gradle.pluginMode=V2Enabled

to gradle.properties file.

Version catalog

Maven Central Version

The repository also contains Gradle Version Catalog with toml file. The file is automatically used by gradle to create libs reference in build.gradle.kts files.

Set up

Include the following code in your settings.gradle.kts file:

pluginManagement {
    repositories {
        mavenLocal()
        google()
        mavenCentral()
        gradlePluginPortal()
    }
}

dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        mavenLocal()
        google()
        mavenCentral()
    }
    versionCatalogs {
        create("libs") {
            from("no.nordicsemi.android.gradle:version-catalog:<version>")
        }
    }
}

Dependencies can be later set using libs reference in build.gradle.kts files:

plugins {
    alias(libs.plugins.android.application) apply false
}

dependencies {
    // Example dependency:
    implementation(libs.nordic.dfu)
    implementation(libs.androidx.compose.material.iconsExtended)
}