将Makefile转换为Gradle用于golang应用程序的转换

huangapple go评论154阅读模式
英文:

Makefile to gradle conversion for golang application

问题

我有一个使用Go语言编写的应用程序,它公开了一个REST API,并将信息记录到数据库中。我正在尝试将makefile转换为gradle构建。是否有类似于maven2gradle插件的默认方式,或者gradle构建文件应该手动编写?我已经检查了gradle和makefile之间的语法差异,但仍然不清楚如何将运行时参数传递给gradle,类似于以下命令:

run:build
./hello -conf=/apps/content/properties/prop.json -v=0 -logDest="FILE" -log_dir="/var/log/logdir"

其中hello是我的可执行文件,其他是运行时参数。这是我第一次尝试将makefile迁移到gradle,我找不到任何清晰的文档。请帮忙。

英文:

I have a go lang application which exposes a rest API and logs the information to DB. I am trying to convert the make file to gradle build. Is there any default way similar to maven2gradle plugin or the gradle build file should be written manually? I checked the syntactical differences between gradle and make file but still not clear about passing run time arguments to gradle that is similar to

run:build
./hello -conf=/apps/content/properties/prop.json -v=0 -logDest="FILE" -log_dir="/var/log/logdir"

hello is my executable and others are the runtime arguments. This is my first attempt in migrating make to gradle and I couldnt find any clear documentation. Please help.

答案1

得分: 2

根据我的检查,目前没有直接的插件可以完成这个任务。作为一种解决方法,可以将构建执行写成Gradle中的单独任务,并按照顺序进行排序。这些任务将包括设置Go路径、安装依赖项和构建应用程序,并作为命令行进程在Gradle中运行。Gradle提供了运行命令行进程的支持,具体描述可以参考Gradle文档。希望对你有帮助。

英文:

As far as I have checked, there is no direct plugin that could do this task. As a workaround, the build execution could be written as seperate tasks in gradle and ordered accordingly. Tasks here would contain setting Go path, installing dependencies and building the application and would be run as command line process in Gradle. Gradle provides support to run command line processes as described in gradle documentation. Hope it helps.

huangapple
  • 本文由 发表于 2016年4月26日 21:50:53
  • 转载请务必保留本文链接:https://go.coder-hub.com/36866958.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定