如何使用gradle和wire编译器生成proto java文件?

时间:2016-06-08 11:05:53

标签: java gradle jar protocol-buffers

我想运行gradle任务,为我生成原始文件中的java文件。这是我的代码:

task runJar(dependsOn: jar) << {
    javaexec {
        main = "-jar";
        args = [
                "wire-compiler-1.8.0-jar-with-dependencies.jar",
                "--proto_path=src/main/proto",
                "--java_out=build/generated/proto/wire test.proto"
        ]
    }
}

通过命令行一切都很好,但在gradle中它不起作用。

java -jar wire-compiler-1.8.0-jar-with-dependencies.jar --proto_path=src/main/proto --java_out=build/generated/proto/wire test.proto

任何帮助表示感谢。

修改

我发现了问题。它应该是这样的:

task runJar(dependsOn: jar) << {
    javaexec {
        main = "-jar";
        args = [
                "wire-compiler-1.8.0-jar-with-dependencies.jar",
                "--proto_path=src/main/proto",
                "--java_out=build/generated/proto/wire",
                "test.proto"
        ]
    }
}

0 个答案:

没有答案