Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?

Latest commit


Git stats


Failed to load latest commit information.
Latest commit message
Commit time

Travis CI Plugin Portal OpenJDK

Generating Gradle Plugin

Generate Android-like BuildConfig and R class on any JVM projects.

public final class BuildConfig {
    public static final String NAME = "My App";
    public static final String GROUP = "my.package";
    public static final String VERSION = "1.0";
    public static final String DEBUG = true;

public final class R {
    public static final class font {
        public static final String MyriadPro = "/font/MyriadPro.ttf";
        public static final String SegoeUI = "/font/SegoeUI.ttf";

    public static final class layout {
        public static final String main = "/layout/main.fxml";
        public static final String about = "/layout/about.fxml";


Using plugins DSL:

plugins {
    id('com.hendraanggrian.generating') version "$version"

Using legacy plugin application:

buildscript {
    repositories {
    dependencies {

apply plugin: 'com.hendraanggrian.generating'


Once applied, the plugin works out of the box without additional configuration. To configure or even disable this behavior, modify task as instructed below.

This plugin does not have an extension, every configuration is performed within tasks.


Modify BuildConfig class generation with generateBuildConfig task.

group 'com.example' // project group
version '1.0'       // project version

tasks.generateBuildConfig {
    packageName.set('') // package name of which R.class will be generated to, default is project group

    appName.set('My App')     // `BuildConfig.NAME` value, default is project name
    groupId.set('')     // `BuildConfig.GROUP` value, default is project group
    version.set('2.0')        // `BuildConfig.VERSION` value, default is project version
    debug.set(true)           // `BuildConfig.DEBUG` value

    // add custom field specifying its name, type, and value
    addField String.class, 'myString', 'Hello world!'
    addField double.class, 'myDecimal', 12.0


Modify R class generation with generateR task. Some file types (CSS & JSON) requires certain capabilities. This is to ensure that plugin consumer only download artifacts they are using.

group 'com.example' // project group
version '1.0'       // project version

tasks.generateR {
    resourceDirectory.set(new File('my/path/resources'))
    exclusions.addAll('some_file', 'some_other_file')
    properties { ... }  // enables Properties file support

CSS files

Enable CSS file support by reading CSS classes and IDs, powered by ph-css.

tasks.generateR {
    css { ... }

JSON files

Enable CSS file support by reading JSON keys, powered by json-simple.

tasks.generateR {
    json { ... }