1.0.4 (29-mar-2025)
sdkArtifactId
1.0.3 (19-mar-2025)
mayAddInternalGOPATH
)echo
and echoWarn
for all mojospath
into execute
mojoA simple Maven plugin that automates working with GoSDK in Maven projects. It handles downloading GoSDK, caching it in a specified directory, and invoking its tools.
Originally, there was a project called mvn-golang that provided similar functionality. However, since then, the Go ecosystem has changed significantly. I decided to create a simpler plugin focused solely on downloading and executing GoSDK, removing features related to package installation, repository management, and processing. Now, this is just a Maven plugin dedicated to fetching and running Go tools.
Just clone the project and use Maven. Go into the project folder and execute maven command
mvn clean install
if you want to build examples, use
mvn clean install -Pexamples
The generated Maven mojo site.
The plugin doesn't provide any packaging so you should use one of regular packaging like pom
(if you use jar
then
maven injects a lot of default calls for Java specific plugins). Just add into the maven
pom.xml build section
<plugin>
<groupId>com.igormaznitsa</groupId>
<artifactId>gosdk-wrapper-maven-plugin</artifactId>
<version>1.0.4</version>
<configuration>
<goVersion>1.24.1</goVersion>
</configuration>
<executions>
<execution>
<id>go-help</id>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<args>
<arg>help</arg>
</args>
</configuration>
</execution>
</executions>
</plugin>
It will automatically download GoSDK and cache it but keep in mind that the plugin makes minimalistic business and it doesn't provide any extra options and environment variables just out of the box, also it doesn't make any installation and deploy of projects.
If you use something else than pom
packaging then during build you can see a lot of notifications from standard
plugins provided by packaging, they know nothing about Go,
so you can just move their execution into none
phase by execution id.
For instance
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>default-clean</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>default-jar</id>
<phase>none</phase>
</execution>
</executions>
</plugin>
</plugins>