All Projects → google → secrets-gradle-plugin

google / secrets-gradle-plugin

Licence: Apache-2.0 license
A Gradle plugin for providing your secrets to your Android project.

Programming Languages

kotlin
9241 projects

Projects that are alternatives of or similar to secrets-gradle-plugin

licenser
A simple license header manager for Gradle
Stars: ✭ 32 (-93.26%)
Mutual labels:  gradle-plugin
corda-gradle-plugins
Gradle plugins used by Corda and Cordapps
Stars: ✭ 21 (-95.58%)
Mutual labels:  gradle-plugin
xjc-generation-gradle-plugin
A Gradle Plugin for generating JAXB Java sources using the XJC compiler
Stars: ✭ 20 (-95.79%)
Mutual labels:  gradle-plugin
gradle-versioner
Gradle Version Plugin. Generates semantic versions with git meta data per branch.
Stars: ✭ 25 (-94.74%)
Mutual labels:  gradle-plugin
dockerPreparePlugin
Gradle plugin to generate docker layer-friendly directory for spring boot applications
Stars: ✭ 44 (-90.74%)
Mutual labels:  gradle-plugin
allure-gradle
Allure Gradle Plugin
Stars: ✭ 62 (-86.95%)
Mutual labels:  gradle-plugin
gradle-release-plugin
Gradle plugin providing very minimal release version numbering (Git-specific)
Stars: ✭ 43 (-90.95%)
Mutual labels:  gradle-plugin
gradle-versioneye-plugin
Plugin for Gradle to update your project's dependencies status on www.versioneye.com
Stars: ✭ 31 (-93.47%)
Mutual labels:  gradle-plugin
kobby
Kobby is a codegen plugin of Kotlin DSL Client by GraphQL schema. The generated DSL supports execution of complex GraphQL queries, mutation and subscriptions in Kotlin with syntax similar to native GraphQL syntax.
Stars: ✭ 52 (-89.05%)
Mutual labels:  gradle-plugin
gradle-plugin-bootstrap
All you need to create a custom Gradle plugin
Stars: ✭ 24 (-94.95%)
Mutual labels:  gradle-plugin
bye-bye-jetifier
Gradle Plugin to verify if you can keep Android Jetifier disabled
Stars: ✭ 173 (-63.58%)
Mutual labels:  gradle-plugin
StaticBus
🚌 A static bus use in modules.
Stars: ✭ 15 (-96.84%)
Mutual labels:  gradle-plugin
android-gradle-plugins
Gradle Plugins for Android builds
Stars: ✭ 12 (-97.47%)
Mutual labels:  gradle-plugin
aotc-gradle-plugin
Ahead-of-Time Compilation in Gradle projects.
Stars: ✭ 17 (-96.42%)
Mutual labels:  gradle-plugin
metalava-gradle
A Gradle plugin for Metalava, AOSP's tool for API metadata extraction and compatibility tracking.
Stars: ✭ 29 (-93.89%)
Mutual labels:  gradle-plugin
gradle-marytts-voicebuilding-plugin
A replacement for the legacy VoiceImportTools in MaryTTS
Stars: ✭ 14 (-97.05%)
Mutual labels:  gradle-plugin
StringFuck
Yet Another String Obfuscator for Android
Stars: ✭ 50 (-89.47%)
Mutual labels:  gradle-plugin
android-buddy
Transform Android project classes with Byte Buddy at compile time
Stars: ✭ 42 (-91.16%)
Mutual labels:  gradle-plugin
Robfuscate
Obfuscate the int index of R.id/R.string/R.layout… in the classes.dex of Android project
Stars: ✭ 56 (-88.21%)
Mutual labels:  gradle-plugin
gradle-android-emulator
Gradle plugin for starting the Android Emulator when running instrumentation tests
Stars: ✭ 30 (-93.68%)
Mutual labels:  gradle-plugin

Secrets Gradle Plugin for Android

Tests Apache-2.0

A Gradle plugin for providing your secrets securely to your Android project.

This Gradle plugin reads secrets from a properties file not checked into version control, such as local.properties, and expose those properties as variables in the Gradle-generated BuildConfig class and in the Android manifest file.

DISCLAIMER: This plugin is primarily for hiding your keys from version control. Since your key is part of the static binary, your API keys are still recoverable by decompiling an APK. So, securing your key using other measures like adding restrictions (if possible) are recommended.

Requirements

  • Gradle-based Android project
  • Android Gradle plugin 7.0.2

Installation

NOTE: Starting from v1.1.0, the plugin ID was changed to "com.google.android.libraries.mapsplatform.secrets-gradle-plugin" and the plugin is now being distributed via Google Maven (gMaven). You can still download previous versions of the plugin from Gradle's plugin portal, but new versions will now only be distributed through gMaven.

  1. In your project's root build.gradle file:

Groovy:

buildscript {
    dependencies {
        classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1"
    }
}

Kotlin:

buildscript {
    dependencies {
        classpath("com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:2.0.1")
    }
}
  1. In your app-level build.gradle file:

Groovy:

plugins {
    id 'com.google.android.libraries.mapsplatform.secrets-gradle-plugin'
}

Kotlin:

plugins {
    id("com.google.android.libraries.mapsplatform.secrets-gradle-plugin")
}

This plugin also supports library module type (com.android.library). Just install the plugin in your library-level build.gradle file and keys will be visible inside that module as well.

Snapshot Releases

Snapshot releases, which are distributed via GitHub Packages, are also available for latest fixes. To use a snapshot release, add the following repository to your project-level build.gradle file:

Groovy:

buildscript {
    repositories {
        maven {
            url = uri("https://maven.pkg.github.com/google/secrets-gradle-plugin")
            credentials {
                username = project.findProperty("GITHUB_USER") ?: System.getenv("GITHUB_USER")
                password = project.findProperty("GITHUB_TOKEN") ?: System.getenv("GITHUB_TOKEN")
            }
        }
    }
    dependencies {
        classpath "com.google.android.libraries.mapsplatform.secrets-gradle-plugin:secrets-gradle-plugin:<version>-SNAPSHOT"
    }
}

Also, see Authenticating to GitHub Packages.

Example Usage

Example contents of local.properties under your root project:

apiKey=YOUR_API_KEY

After applying the plugin and building your project, the API key then becomes accessible in two ways.

  1. As a BuildConfig value:
val apiKey = BuildConfig.apiKey
  1. As a variable accessible in your AndroidManifest.xml file:
<meta-data android:value="${apiKey}" />

CI/CD Systems

For CI/CD systems, consider creating and checking in version control a default properties file with all the same keys required by your app but with safe default values. To do this, create a properties file and set the defaultPropertiesFileName value to that file name. For example:

secrets {
    defaultPropertiesFileName = 'local.defaults.properties'
}

Configuration Options

The plugin can optionally be configured:

secrets {
    // Change the properties file from the default "local.properties" in your root project
    // to another properties file in your root project.
    propertiesFileName 'secrets.properties'

    // A properties file containing default secret values. This file can be checked in version
    // control.
    defaultPropertiesFileName = 'secrets.defaults.properties'

    // Configure which keys should be ignored by the plugin by providing regular expressions.
    // "sdk.dir" is ignored by default.
    ignoreList.add("keyToIgnore") // Ignore the key "keyToIgnore"
    ignoreList.add("sdk.*")       // Ignore all keys matching the regexp "sdk.*"
}

Build-Variant Specific Properties

To set build-variant specific properties (build type or flavor), create a properties file at the root directory of the project with the same name as the variant. For example, to set keys specific for the release build type, create a new file called release.properties containing release-specific keys.

Contributing

Contributions to this library are always welcome and highly encouraged!

See CONTRIBUTING.md and CODE_OF_CONDUCT.md for more information on how to get started.

License

Apache 2.0. See LICENSE for more information.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].