The Gradle JPP Plugin is a PrecompileProcessor gradle porting.It allows you to preprocess macros in your java source code.
Please follow the below steps to add the Gradle JPP Plugin to your Gradle build script.
To apply the plugin, please add the following snippets to your build.gradle
file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'org.flakor.jpp:gradle-jpp-plugin:0.1.1'
}
}
apply plugin: 'jpp'
- If you have a multi project build make sure to apply the plugin and the plugin configuration to every project which its source code you wish to preprocess.
Add the below "jpp" closure with some properties.
jpp {
destDir = 'dest'
defines {
sdk_debugable = false
}
sourceSets {
main {
java {
srcDirs = ['src/main/java']
}
}
}'
...
}
- destDir --- destination directory your code files locate
- sourceSets --- same as java plugin's sourceSets
- defines --- macros you defined
- defineFile --- a file holded macros
- encode --- source file encoding (default utf-8)
- baseDir --- base directory your code files locate
To make your processed files as source files,you must set the final directory which is dest property plus SourceSets srcDirs in jpp closure to Java plugin or Android plugin SourceSets.
sourceSets {
main {
java {
srcDirs = ['dest/src/main/java'] //set dest source dir
}
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
sourceSets {
main {
java.srcDirs = ['dest/src/main/java'] //set dest source dir
}
}
...
}
gradle javaPreprocess
JVM Compatibility: Java 6 and above.
Chinese Doc you can check at this PCP Chinese Doc
This plugin is available under the Apache License, Version 2.0.
(c) All rights reserved Steve Hsu