<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'm unaware of such a plugin, but to be honest one shouldn'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's needed.</p>
<p>One way to fetch all the dependencies of a project you've already got is <code>go test -i</code>. There's probably a better way, but I don'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'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><project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.acme.change-data-capture</groupId>
<artifactId>file-mover</artifactId>
<version>1.0-SNAPSHOT</version>
<name>FileMover</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<!-- If a deploy goal is executed, define the repositories here -->
<distributionManagement>
<repository>
<id>lwartifactory-releases</id>
<name>acme Artifactory Repository</name>
<url>http://lwartifactory.acme.com/artifactory/releases/</url>
</repository>
<snapshotRepository>
<id>lwartifactory-snapshots</id>
<uniqueVersion>false</uniqueVersion>
<name>SNAPSHOT Artifactory Repository</name>
<url>http://lwartifactory.acme.com/artifactory/libs-snapshot-local/</url>
</snapshotRepository>
</distributionManagement>
<build>
<defaultGoal>package</defaultGoal>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<executions>
<execution>
<id>default-compile</id>
<phase>never</phase>
</execution>
<execution>
<id>default-testCompile</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>default-testResources</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.4</version>
<executions>
<execution>
<id>default-test</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>default-jar</id>
<phase>never</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>file-mover</id>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<exportAntProperties>true</exportAntProperties>
<target>
<exec executable="go">
<arg value="build"/>
</exec>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
</code></pre></pre>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传