golang plugin for Maven?

polaris · · 2010 次点击    
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
<p>Am looking for a maven plugin that can orchestrate the build of a golang sub project - comparable to, say, the maven cmake plugin.</p> <hr/>**评论:**<br/><br/>The_Sly_Marbo: <pre><p>I&#39;m unaware of such a plugin, but to be honest one shouldn&#39;t be necessary. Dependency management and compiling are much simpler in Go than languages like Java, so normally <code>go build</code> is all that&#39;s needed.</p> <p>One way to fetch all the dependencies of a project you&#39;ve already got is <code>go test -i</code>. There&#39;s probably a better way, but I don&#39;t need it often enough to look for one.</p></pre>RogerV: <pre><p>i need to have the build artifacts stored in an Artifactory repository from where our automated deployment systems finds artifacts that are to be deployed. Maven is the easiest way to get deployment to happen, and the vast majority of the code going into this repository is Java. Using a Maven cmake plugin I was able to get to where a C++ program is being managed in this fashion - was just hoping to do the same for a Golang program.</p></pre>The_Sly_Marbo: <pre><p>Ah, fair enough. In that case I&#39;d suggest using <a href="http://stackoverflow.com/questions/3491937/i-want-to-execute-shell-commands-from-mavens-pom-xml">this</a> to run a tiny script that runs <code>go build</code> and deploys the resulting binary. If necessary, use <code>-o</code> to ensure there binary has a fixed name.</p></pre>RogerV: <pre><p>I found a viable solution. Look at my comment to the OP - I was able to fashion a Maven pom file that accomplishes my intent.</p></pre>RogerV: <pre><p>I found a viable solution for my specific goal - I was able to cobble together a maven pom file that just builds my golang program, packages it and related files into a zip archive, and then deploys that to an Artifactory code repository. The key was to go and set phase of never on various plugins in order to disable them and then use the ant plugin to run <code>go build</code>. Here is my pom file:</p> <pre><code>&lt;project xmlns=&#34;http://maven.apache.org/POM/4.0.0&#34; xmlns:xsi=&#34;http://www.w3.org/2001/XMLSchema-instance&#34; xsi:schemaLocation=&#34;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd&#34;&gt; &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt; &lt;groupId&gt;com.acme.change-data-capture&lt;/groupId&gt; &lt;artifactId&gt;file-mover&lt;/artifactId&gt; &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt; &lt;name&gt;FileMover&lt;/name&gt; &lt;url&gt;http://maven.apache.org&lt;/url&gt; &lt;properties&gt; &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt; &lt;/properties&gt; &lt;!-- If a deploy goal is executed, define the repositories here --&gt; &lt;distributionManagement&gt; &lt;repository&gt; &lt;id&gt;lwartifactory-releases&lt;/id&gt; &lt;name&gt;acme Artifactory Repository&lt;/name&gt; &lt;url&gt;http://lwartifactory.acme.com/artifactory/releases/&lt;/url&gt; &lt;/repository&gt; &lt;snapshotRepository&gt; &lt;id&gt;lwartifactory-snapshots&lt;/id&gt; &lt;uniqueVersion&gt;false&lt;/uniqueVersion&gt; &lt;name&gt;SNAPSHOT Artifactory Repository&lt;/name&gt; &lt;url&gt;http://lwartifactory.acme.com/artifactory/libs-snapshot-local/&lt;/url&gt; &lt;/snapshotRepository&gt; &lt;/distributionManagement&gt; &lt;build&gt; &lt;defaultGoal&gt;package&lt;/defaultGoal&gt; &lt;plugins&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-compiler-plugin&lt;/artifactId&gt; &lt;version&gt;3.0&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-compile&lt;/id&gt; &lt;phase&gt;never&lt;/phase&gt; &lt;/execution&gt; &lt;execution&gt; &lt;id&gt;default-testCompile&lt;/id&gt; &lt;phase&gt;never&lt;/phase&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-resources-plugin&lt;/artifactId&gt; &lt;version&gt;2.6&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-testResources&lt;/id&gt; &lt;phase&gt;never&lt;/phase&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-surefire-plugin&lt;/artifactId&gt; &lt;version&gt;2.12.4&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-test&lt;/id&gt; &lt;phase&gt;never&lt;/phase&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-jar-plugin&lt;/artifactId&gt; &lt;version&gt;2.6&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;default-jar&lt;/id&gt; &lt;phase&gt;never&lt;/phase&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;groupId&gt;org.apache.maven.plugins&lt;/groupId&gt; &lt;artifactId&gt;maven-antrun-plugin&lt;/artifactId&gt; &lt;version&gt;1.7&lt;/version&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;file-mover&lt;/id&gt; &lt;phase&gt;compile&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;run&lt;/goal&gt; &lt;/goals&gt; &lt;configuration&gt; &lt;exportAntProperties&gt;true&lt;/exportAntProperties&gt; &lt;target&gt; &lt;exec executable=&#34;go&#34;&gt; &lt;arg value=&#34;build&#34;/&gt; &lt;/exec&gt; &lt;/target&gt; &lt;/configuration&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;plugin&gt; &lt;artifactId&gt;maven-assembly-plugin&lt;/artifactId&gt; &lt;version&gt;2.6&lt;/version&gt; &lt;configuration&gt; &lt;descriptors&gt; &lt;descriptor&gt;assembly.xml&lt;/descriptor&gt; &lt;/descriptors&gt; &lt;/configuration&gt; &lt;executions&gt; &lt;execution&gt; &lt;id&gt;make-assembly&lt;/id&gt; &lt;phase&gt;package&lt;/phase&gt; &lt;goals&gt; &lt;goal&gt;single&lt;/goal&gt; &lt;/goals&gt; &lt;/execution&gt; &lt;/executions&gt; &lt;/plugin&gt; &lt;/plugins&gt; &lt;/build&gt; &lt;/project&gt; </code></pre></pre>

入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889

2010 次点击  
加入收藏 微博
暂无回复
添加一条新回复 (您需要 登录 后才能回复 没有账号 ?)
  • 请尽量让自己的回复能够对别人有帮助
  • 支持 Markdown 格式, **粗体**、~~删除线~~、`单行代码`
  • 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
  • 图片支持拖拽、截图粘贴等方式上传