java
java copied to clipboard
Gradle config for non-android project
I'm using gradle for the first time in my Java project (not android) and I'd like to use static code gen. I've taken a look at the example gradle file for android (https://github.com/json-iterator/java/blob/master/android-demo/build.gradle) but I'm unsure how to adapt this for a standard Java project. Is such an example available somewhere?
For reference if someone needs non-andorid gradle setup:
apply plugin: 'java'
apply plugin: 'application'
task jsoniterStaticCodgen(type: JavaExec) {
doFirst {
//CAREFULL with this line, it can wipe src folder if slash won't match win \\ linux / backup before testing
//delete sourceSets.main.java.srcDirs[0].toString() + '\\jsoniter_codegen\\'
}
classpath configurations.getByName(sourceSets.main.compileClasspathConfigurationName)
classpath project.buildDir.toString() + '/classes/java/main/'
main = 'com.jsoniter.static_codegen.StaticCodegen'
args 'org.<package to your config>.CodegenConfig'
workingDir = sourceSets.main.java.srcDirs[0]
}
compileJava.finalizedBy(jsoniterStaticCodgen)