在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):google/secrets-gradle-plugin开源软件地址(OpenSource Url):https://github.com/google/secrets-gradle-plugin开源编程语言(OpenSource Language):Kotlin 100.0%开源软件介绍(OpenSource Introduction):Secrets Gradle Plugin for AndroidA 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 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
InstallationNOTE: 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.
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")
}
}
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 ( Snapshot ReleasesSnapshot 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 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 UsageExample contents of
After applying the plugin and building your project, the API key then becomes accessible in two ways.
val apiKey = BuildConfig.apiKey
<meta-data android:value="${apiKey}" /> CI/CD SystemsFor 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 secrets {
defaultPropertiesFileName = 'local.defaults.properties'
} Configuration OptionsThe 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 PropertiesTo 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 ContributingContributions 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. LicenseApache 2.0. See LICENSE for more information. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论