-
Notifications
You must be signed in to change notification settings - Fork 30
Gradle
Kostiantyn Shchepanovskyi edited this page Jan 9, 2018
·
1 revision
Essentially in your Gradle build file you can specify a configuration like so
configurations {
protoCompile
}
Then add the CLI dependency using that configuration.
dependencies {
protoCompile "io.protostuff:protostuff-cli:0-SNAPSHOT"
}
Then to run it, just create task and do the following.
task generateSource() {
ant.java(classname: 'io.protostuff.compiler.cli.ProtostuffCompilerCli', fork: 'true', failOnError: 'true') {
arg(value: 'MyProto.proto')
arg(value: '-g=java')
arg(value: '-I=' + project.projectDir.path + "/../proto/")
arg(value: '-o=' + project.buildDir.path + "/generated/")
classpath {
pathElement(path: configurations.protoCompile.asPath)
}
}
}
Then on call the task, I have it as part of the build so on "clean" the generated files are deleted and on build they are re-generated.
/gradlew generateSource
Thanks @MonsterOfCookie for instruction.