All Projects → mb-14 → ConfigDroid

mb-14 / ConfigDroid

Licence: MIT license
Gradle plugin to generate config classes for your Android projects

Programming Languages

groovy
2714 projects
java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to ConfigDroid

Gradle Avro Plugin
A Gradle plugin to allow easily performing Java code generation for Apache Avro. It supports JSON schema declaration files, JSON protocol declaration files, and Avro IDL files.
Stars: ✭ 176 (+467.74%)
Mutual labels:  gradle-plugin
Javafx Gradle Plugin
Gradle plugin that makes it easy to work with JavaFX 11+
Stars: ✭ 214 (+590.32%)
Mutual labels:  gradle-plugin
Avito Android
Infrastructure of Avito android
Stars: ✭ 253 (+716.13%)
Mutual labels:  gradle-plugin
Maven Git Versioning Extension
This extension will virtually set project versions, based on current git branch or tag.
Stars: ✭ 178 (+474.19%)
Mutual labels:  gradle-plugin
Gradle Swagger Generator Plugin
Gradle plugin for OpenAPI YAML validation, code generation and API document publishing
Stars: ✭ 197 (+535.48%)
Mutual labels:  gradle-plugin
Moko Widgets
Multiplatform UI DSL with screen management in common code for mobile (android & ios) Kotlin Multiplatform development
Stars: ✭ 227 (+632.26%)
Mutual labels:  gradle-plugin
Dexguard
Android app防dex2jar的gradle插件
Stars: ✭ 174 (+461.29%)
Mutual labels:  gradle-plugin
editorconfig-gradle-plugin
A Gradle plugin for checking whether project files comply with format rules defined in .editorconfig files and eventually also for fixing the violations
Stars: ✭ 40 (+29.03%)
Mutual labels:  gradle-plugin
Gradle Errorprone Plugin
Gradle plugin to use the error-prone compiler for Java
Stars: ✭ 202 (+551.61%)
Mutual labels:  gradle-plugin
Coveralls Gradle Plugin
👨‍🔧 gradle plugin for coveralls
Stars: ✭ 250 (+706.45%)
Mutual labels:  gradle-plugin
Gradle Testsets Plugin
A plugin for the Gradle build system that allows specifying test sets (like integration or acceptance tests).
Stars: ✭ 182 (+487.1%)
Mutual labels:  gradle-plugin
Gradle Baseline
A set of Gradle plugins that configure default code quality tools for developers.
Stars: ✭ 191 (+516.13%)
Mutual labels:  gradle-plugin
Gradle Android Git Version
A gradle plugin to calculate Android-friendly version names and codes from git tags
Stars: ✭ 227 (+632.26%)
Mutual labels:  gradle-plugin
Gradle Launch4j
A gradle-plugin to create windows executables with launch4j
Stars: ✭ 177 (+470.97%)
Mutual labels:  gradle-plugin
AndroidLintReporter
Gradle Plugin to report Android Lint and Detekt result back to Github Pull Request
Stars: ✭ 22 (-29.03%)
Mutual labels:  gradle-plugin
Click Debounce
Using ASM to handle Android's click debounce, specially a quick double click.
Stars: ✭ 175 (+464.52%)
Mutual labels:  gradle-plugin
Badass Jlink Plugin
Create a custom runtime image of your modular application
Stars: ✭ 216 (+596.77%)
Mutual labels:  gradle-plugin
gradle-natives
Gradle plugin to aid in managing native libraries associated with Java-based projects.
Stars: ✭ 32 (+3.23%)
Mutual labels:  gradle-plugin
gradle-syntastic-plugin
A Gradle plugin for integrating your Java project with Vim and Syntastic.
Stars: ✭ 45 (+45.16%)
Mutual labels:  gradle-plugin
Gradle Cargo Plugin
Gradle plugin that provides deployment capabilities to local and remote containers via Cargo
Stars: ✭ 238 (+667.74%)
Mutual labels:  gradle-plugin

ConfigDroid

Download

Build Status

ConfigDroid is a gradle plugin for Android Projects which lets you access configuration properties defined in your build.gradle file in the form of constants generated in a java class.

Download and setup

Add these dependencies to your build.gradle:

buildscript {
    repositories {
        jcenter()
        maven {
            url  "http://dl.bintray.com/mb-14/ConfigDroid"
        }
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.3.1'
        classpath 'com.mb14:configdroid:1.1.0'
    }
}
apply plugin: 'com.mb14.configdroid'

configdroid {
    // Define properties here
}

Usage

Basic Usage

Global properties can be defined in the configdroid closure. You also need to define the class name, package name and output directory for the generated java class.

configdroid {
    className "ConfigDroid"
    packageName "com.mb14.configdroid"
    access "public" // Options: public, package-private
    
    prop "API_ENDPOINT", "https://api.twitter.com"
    prop "ENABLE_LOGGING", true
    prop "DATABASE_VERSION", 3
    prop "API_KEY", TWITTER_API_KEY //Property defined in gradle.properties
}

This generates the following source code in ConfigDroid.java

package com.mb14.configdroid;

import java.lang.Boolean;
import java.lang.Integer;
import java.lang.String;

public class ConfigDroid {
  public static final String API_ENDPOINT = "https://api.twitter.com";

  public static final Boolean ENABLE_LOGGING = true;
  
  public static final Integer DATABASE_VERSION = 3;

  public static final String API_KEY = "hvtcOOoFM4";
}

Build Variant Specific Config

You can define config properties specific to product flavors and build variants as well. You can use the same key in different variants and ConfigDroid will override the values in the following order: global < product flavor < build type

configdroid {
    className "Constants"
    packageName "com.example.utils"
    access "public"
    prop "DATABASE_VERSION", 3
    
    productFlavors {
        pro {
            prop "ENABLE_FEATURE_X", true
        }
        
        free {
            prop "ENABLE_FEATURE_X", false
        
        }
    }
    
    buildTypes {
        debug {
            prop "API_ENDPOINT", "http://localhost:3000/twitterapi"
            prop "ENABLE_LOGGING", true
        }
        release {
            prop "API_ENDPOINT", "https://api.twitter.com"
            prop "ENABLE_LOGGING", false
        }
    }
}

Embed file contents as String constants

configdroid {
    file "JS_SCRIPT", file('webview_inject.js')
}

Possible property types

configdroid {
    // Primitives
    prop "API_ENDPOINT", "http://api.twitter.com"
    prop "ENABLE_LOGGING", true
    prop "DATABASE_VERSION", 3
    prop "API_TOKEN", TWITTER_API_TOKEN //Property defined in gradle.properties
    prop "FLOAT_CONSTANT", 9.8f
    prop "DOUBLE_CONSTANT", 9.8d
    prop "LONG_CONSTANT", 122424343535l
    prop "CHAR_CONSTANT", 'a' as char
    prop "BYTE_CONSTANT", 0b11 as byte
    prop 'BUILD_UNIXTIME', System.currentTimeMillis()

    // Arrays
    prop "STRING_ARRAY", ["hello", "world"]
    prop "INT_ARRAY", [1,2,3,4]
    prop "DOUBLE_ARRAY", [9.8d, 24.34d, 44.44d]

    // Custom objects and initializations
    prop 'java.util.Date', 'BUILD_DATE', 'new Date(' + System.currentTimeMillis() + 'L)'
    prop 'boolean', "REQUEST_RUNTIME_PERM", 'android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.M'
    prop 'int', 'THEME_COLOR', 'android.graphics.Color.parseColor(\"ff0000\")'
}
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].