Want to take your software engineering career to the next level? Join the mailing list for career tips & advice Click here


Gradle plugin to add multi-variants yaml settings to Android.

Subscribe to updates I use gradle-config

Statistics on gradle-config

Number of watchers on Github 96
Number of open issues 4
Main language Groovy
Open pull requests 2+
Closed pull requests 0+
Last commit almost 3 years ago
Repo Created over 4 years ago
Repo Last Updated over 2 years ago
Size 113 KB
Organization / Authortmiyamon
Page Updated
Do you use gradle-config? Leave a review!
View open issues (4)
View gradle-config activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Software engineers: It's time to get promoted. Starting NOW! Subscribe to my mailing list and I will equip you with tools, tips and actionable advice to grow in your career.
Evaluating gradle-config for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Gradle Config Plugin

This plugin helps you to easily handle variant specific settings with yaml format.


buildscript {
  repositories {
    maven {
      url "https://plugins.gradle.org/m2/"
  dependencies {
    classpath "gradle.plugin.com.tmiyamon:gradle-config:0.2.1"

apply plugin: 'com.android.application'
apply plugin: "com.tmiyamon.config"

Build script snippet for new, incubating, plugin mechanism introduced in Gradle 2.1:

plugins {
  id "com.tmiyamon.config" version "0.2.1"

Settings class

The entries in config yaml will be available in Settings class as static members:


Nested entries are supported:


Config files

Config entries are generated from:


The lower one overwrites upper one deeply. The purpose of loading settings files with suffix _secret is to avoid to commit the secret files to remote repository. If you want to use this feature, don't forget to include those files to your .gitignore:


Accessing Configuration Settings

Consider the following config files.


size: 1
server: google.com


size: 2
server: google.com
  size: 3
  servers: [ {name: yahoo.com}, {name: amazon.com} ]

Notice that the variant specific config entries overwrite the common entries.

Settings.size   // => 2
Settings.server // => google.com

Notice that object member notation is maintained even in nested entries.

Settings.section.size // => 3

Notice array notation and object member notation is maintained.

Settings.section.servers.get(0).name // => yahoo.com
Settings.section.servers.get(1).name // => amazon.com


Consider this config file:

string_entry: string
int_entry: 1
double_entry: 1.0
date_entry: 2001-11-23 15:03:17
  - 1
  - 2
  - 1
  - 'test'
  entry_a: 1
  entry_b: 2
  - a: 'a1'
    b: 'b1'
  - a: 'a2'
    b: 'b2'

The snakeyaml library this plugin uses provides the following basic type conversions:

Integer i = Settings.int_entry;
String s = Settings.string_entry;
Double d = Settings.double_entry;
Date da = Settings.date_entry;
List<Integer> list = Settings.list_entry;

The list with mixed type elements are not supported and throw an exception.

Error:Execution failed for task ':app:generateDevDebugSettings'.
> Not supported list with mixed type: [class java.lang.Integer, class java.lang.String]

The nested map entries are converted a generated class to achieve dot access.

Settings.ObjectEntry oe = Settings.object_entry;
Integer entryA = object_entry.entry_a;
Integer entryB = object_entry.entry_b;

Also, the list of map are supported.

List<Settings.ListOfMapEntryElement> entries = Settings.list_of_map_entry;

Known issues

Not found Settings class

Sometimes Android Studio does not detect generated Settings class. When you fact to this problem, Refresh all Gradle projects in the right pane of Android Studio may be helpful.


Copyright 2015 Takuya Miyamoto

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


Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
gradle-config open pull requests (View All Pulls)
  • Handle empty config files
  • Make plugin work with Android libraries too
gradle-config questions on Stackoverflow (View All Questions)
  • Android: any buildToolsVersion for Gradle config
  • Gradle config ear classes folder (.class file)
  • Spring boot thin jar gradle config
  • Android Studio / Gradle - Config for Flavor-specific Jni libs
  • Gradle config file for L version and old versions of android
  • Gradle config to run Findbugs only on java but not scala
  • Gradle config for ContentProvider contract
  • Netbeans Gradle config
gradle-config list of languages used
Other projects in Groovy