dongyilai4214
2019-03-31 08:00
浏览 270
已采纳

如何使用Maven构建GO可执行文件

I have my Go source code, after go build, an executable is generated, which accepts some parameters to produce the output. Is there any way build the executable from maven build with any plugins?

图片转代码服务由CSDN问答提供 功能建议

我有了Go源代码,在 go build 之后,生成了一个可执行文件,该文件 接受一些参数来产生输出。 是否可以通过任何插件通过maven build构建可执行文件?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • dongzha3058 2019-04-01 12:59
    已采纳

    You can just put your go build command into a shell script and run it with this plugin:

    <plugin>
      <artifactId>exec-maven-plugin</artifactId>
      <groupId>org.codehaus.mojo</groupId>
      <executions>
        <execution>
          <id>Build Go binary</id>
          <phase>generate-sources</phase>
          <goals>
            <goal>exec</goal>
          </goals>
          <configuration>
            <executable>${basedir}/build-golang-app.sh</executable>
          </configuration>
        </execution>
      </executions>
    </plugin>
    

    Other option is this Golang plugin which is more feature-rich and specific to this problem. However for simple use cases I would still go with Shell script.

    评论
    解决 无用
    打赏 举报
查看更多回答(1条)

相关推荐 更多相似问题