在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):raydac/mvn-golang开源软件地址(OpenSource Url):https://github.com/raydac/mvn-golang开源编程语言(OpenSource Language):Java 82.3%开源软件介绍(OpenSource Introduction):Changelog2.3.10 (08-jun-2022)
2.3.9 (04-jul-2021)
GO start!Taste Go in just two commands!
The First command in th snippet above generates a maven project with some test files and the second command builds the project.
Also you can take a look at the example If you want to generate a multi-module project, then you can use such snippet
IntroductionThe Plug-in just wraps Golang tool-chain and allows to use strong maven based infrastructure to build Golang projects. It also can automatically download needed Golang SDK from the main server and tune needed version of packets for their branch, tag or revisions. Because a Golang project in the case is formed as just maven project, it is possible to work with it in any Java IDE which supports Maven. How it worksOn start the plug-in makes below steps:
How to buildBecause it is maven plugin, to build the plugin just use
To save time, examples excluded from the main build process and activated through special profile
Important note about automatic Golang SDK loadIf you have some problems with certificates during Golang SDK load, then just add How to add the plugin into maven project?Below described build section for simple golang project which keeps source in <build>
<!--Changing standard Maven project source structure to make it Go compatible-->
<sourceDirectory>${basedir}${file.separator}src</sourceDirectory>
<directory>${basedir}${file.separator}bin</directory>
<plugins>
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>mvn-golang-wrapper</artifactId>
<version>2.3.10</version>
<extensions>true</extensions>
<executions>
<execution>
<goals>
<goal>run</goal>
</goals>
<configuration>
<packages>
<package>main.go</package>
</packages>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build> Work with dependenciesDependencies from Maven repository (since 2.3.0)Plugin supports work with maven repository and can install and load dependencies from there. Artifacts generated by the plugin saved in maven respository as zip archives and <dependency>
<groupId>com.igormaznitsa</groupId>
<artifactId>mvn-go-test-lib</artifactId>
<version>1.0.0-SNAPSHOT</version>
<type>mvn-golang</type>
</dependency>
Plugin makes some trick in work with Maven Golang dependencies, it downloads Golang artifacts from repository and unpack them into temporary folder, then all unpacked dependencies are added to <env>
<GO111MODULE>off</GO111MODULE>
</env> Keep in mind that it is impossible use links to Github and Bitbucket libraries through Support of Module modeSince 2.3.3 version, plug-in supports Golang module mode and allows to mix modules and work with golang maven dependencies, I have made some sample to show the possibility. By default support of module mode is turned off, but it can be turned on through Wrapped GET commandPlugin provides wrapper for Golang GET command and you can just define some external file contains package info through
system property
This mechanism just makes work with dependencies easier and if you want to provide some specific flags and scripts to process CVS folders you have to define configuration parameters in pom.xml, packages defined in the external file and in the pom.xml will be mixed. The Plug-in doesn't work with standard maven dependencies and they must be defined through task of the plugin, the example of easiest case of dependencies is <execution>
<id>default-get</id>
<configuration>
<packages>
<package>github.com/gizak/termui</package>
<package>github.com/kataras/iris</package>
</packages>
</configuration>
</execution> it will be executed as If you want work with specific branch then use below snipet <execution>
<id>default-get</id>
<configuration>
<buildFlags>
<flag>-u</flag>
</buildFlags>
<packages>
<package>github.com/gizak/termui</package>
</packages>
<branch>v2</branch>
</configuration>
</execution> if you want to have several dependencies with different tag and branch then take a look at the snipet below <execution>
<id>dependency1</id>
<goals>
<goal>get</goal>
</goals>
<configuration>
<packages>
<package>github.com/some/framework</package>
</packages>
<tag>1.0.1</tag>
</configuration>
</execution>
<execution>
<id>dependency2</id>
<goals>
<goal>get</goal>
</goals>
<configuration>
<packages>
<package>github.com/some/another</package>
</packages>
<branch>v2</branch>
</configuration>
</execution> sometime GIT can produce cache errors and in the case you can try to turn on auto-fix of such errors with How to save generated artifact in repository?By default, artifact will be installed into maven repository automatically during <properties>
<maven.install.skip>true</maven.install.skip>
<maven.deploy.skip>true</maven.deploy.skip>
</properties> or disable plugin mojo execution <execution>
<id>default-mvninstall</id>
<phase>none</phase>
</execution> ConfigurationAbout configuration parameters, you can read at the wiki page. TestingThe Wrapper just wraps calls to Go tool and recognize the exit code, if call of <execution>
<id>default-get</id>
<configuration>
<buildFlags>
<flag>-u</flag>
</buildFlags>
<packages>
<package>github.com/smartystreets/goconvey</package>
</packages>
</configuration>
</execution>
<execution>
<id>default-test</id>
<configuration>
<buildFlags>
<flag>-v</flag>
</buildFlags>
</configuration>
</execution> Some Examples
|
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论