ProperDroid

Additional

Language
Groovy
Version
v0.1.0 (Mar 13, 2016)
Created
Feb 17, 2016
Updated
Nov 7, 2019 (Retired)
Owner
Jc Miñarro (JcMinarro)
Contributors
Vladislav Bauer (vbauer)
Jc Miñarro (JcMinarro)
Olmo Gallegos (voghDev)
3
Activity
Badge
Generate
Download
Source code

Advertisement

ProperDroid

ProperDroid is a gradle plugin plus an Android library that simplifies the way to config different variants on your project.

How ProperDroid stores

It gets information from your build.gradle file and writes it to a json file inside your assets folder. You can recover this information very easily later, on runtime.

Download and setup

Add these dependencies to your build.gradle:

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:1.5.0'
        classpath 'com.jcminarro:properdroid-plugin:0.1.0'
    }
}
apply plugin: 'com.jcminarro.properdroid'

properdroid {
 properdroidvalues = [
 // ProperDroid Config
 ]
}

dependencies {
    compile 'com.jcminarro:properdroid:0.1.0'
}

Configure ProperDroid

ProperDroid works with the data located inside properdroid closure. properdroidvalues will have a list of different configurations and one by default, called default. You can use flavor name, build type name or variant name for the rest. Inside each configuration you can add as many key-value pairs as you want. Keep in mind that ProperDroid allows you to use the same key on different configurations and it will be overridden in the following order: default < flavor < buildType < variant

Here is an example with a String value to all variants and another that will be overridden only on release variants:

properdroid {
 properdroidvalues = [
  default: [
   projectName: "ProperDRoid",
   endpoint: "http://endpoint.dev"
  ],
  release: [
   endpoint: "http://endpoint.dev"
  ]
 ]
}

There is an example with more options here

Usage

To use ProperDroid inside your app you need to get an instance of ProperDroid and ask it for the desired key.

ProperDroid properdroid = ProperDroid.with(context);
String projectName = properdroid.getString("projectName");
String endpoint = properdroid.getString("endpoint");

If you use git as your vcs, you should ignore every configuration file generated by ProperDroid, adding this line to your .gitignore file

# Ignore all ProperDroid generated file into your vcs
**/properdroid.json

Do you want to contribute?

Feel free to add any useful feature to the library, we will be glad to improve it with your help. I'd love to hear about your use case too, especially if it's not covered perfectly.

License

Copyright 2015 Jc Miñarro

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

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.