Get SDK Maven Plugin integrates the power of SDKMAN! directly into your Maven build process. It allows you to programmatically download, cache, and inject specific SDKs (like OpenJDK, Maven, or Groovy) into your project environment.
- Get any JDK or SDK provided by SDKMan.
- Co-exists with but doesn't require
sdktool (shares cache directory). - Get for any platform, not just host platform.
- Build packages with embedded runtimes.
- Download specific versions of webservers for testing.
- Multi-language builds and continuous integration
- Doesn't support
installorusecommands of SDKMan. It is effectively just thedownloadcommand.
Add the following coordinates to your pom.xml:
<plugin>
<groupId>uk.co.bithatch</groupId>
<artifactId>get-sdk-maven-plugin</artifactId>
<version>0.0.2</version>
</plugin>implementation("uk.co.bithatch:get-sdk-maven-plugin:0.0.1-SNAPSHOT")You can customize the behavior of the plugin using the <configuration> block.
| Parameter | Description | Default Value |
|---|---|---|
candidate |
The SDK identifier (e.g., java, maven, groovy). | java |
version |
The version of the SDK | Latest version |
minVersion |
Minimum version of the SDK (inclusive) | Ignored |
maxVersion |
Maximum version of the SDK (exclusive) | Ignored |
vendor |
The vendor of the SDK | Temurin for java |
output |
Directory where the SDK will be placed. | ${project.build.directory}/sdk |
useCache |
If true, symlinks from the local SDKMAN! cache. If false, downloads directly to output. |
true |
cache |
Local path to the SDKMAN! candidates folder. | ${user.home}/.sdkman/candidates |
altCache |
Local path to the alternative candidates folder, used when platform is not the current platform. This path will be suffixed by the platform code. |
${user.home}/.sdkman/other-candidates |
propertyPrefix |
Prefix for the properties injected into the Maven session. | sdkman. |
platform |
Download SDK for a platform other than the current one. When the platform is not the current one, then altCache will be used instead of cache |
Current platform. Will affect default JDK or SDK depending on version and vendor |
Use as value for platform.
Note, not all of these will be automatically detected
- LINUXX64
- LINUXX32
- LINUXARM64
- LINUXARM32SF
- LINUXARM32HF
- DARWINX64
- DARWINARM64
- WINDOWSX64
- LINUX
- LINUX64
- LINUX32
- DARWIN
- FREEBSD
- SUNOS
- LEGACYWINDOWSPATTERN
- EXOTIC
Once the plugin executes, it injects several properties into your Maven project. These can be referenced elsewhere in your pom.xml using the syntax ${prefix.property} (e.g., ${sdkman.sdkpath}).
| Property | Description |
|---|---|
| sdkpath | The absolute path to the downloaded/linked SDK. |
| candidate | The name of the candidate (e.g., java). |
| version | The specific version number resolved and downloaded. |
| name | The internal name of the SDK. |
| displayName | The human readable name of the SDK |
| platform | The current operating system / platform identifier |
| debianArch | The Debian compatibile architecture ID (e.g. amd64) |
The following example fragment demonstrates how to fetch a specific Zulu JDK and provide its path to the jdeb plugin for packaging.
<build>
<plugins>
<plugin>
<groupId>uk.co.bithatch</groupId>
<artifactId>get-sdk-maven-plugin</artifactId>
<version>0.0.1-SNAPSHOT</version>
<executions>
<execution>
<goals>
<goal>get</goal>
</goals>
<configuration>
<candidate>java</candidate>
<version>17.0.7-zulu</version>
<useCache>true</useCache>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.vafer</groupId>
<artifactId>jdeb</artifactId>
<version>1.10</version>
<executions>
<execution>
<goal>jdeb</goal>
<configuration>
<dataSet>
<data>
<src>${sdkman.sdkpath}</src>
<type>directory</type>
<mapper>
<type>perm</type>
<prefix>/usr/lib/jvm/java-17-zulu</prefix>
</mapper>
</data>
</dataSet>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
| Version | Changes |
|---|---|
| 0.0.2 | Added vendor option, better multi architecture support and version range (minVersion and maxVersion). |