Skip to content

Maven Plugin that uses SDKMan to download any supported SDK such as Java rutimes into your project

License

Notifications You must be signed in to change notification settings

bithatch/get-sdk-maven-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Get SDK Maven Plugin

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.

Features

  • Get any JDK or SDK provided by SDKMan.
  • Co-exists with but doesn't require sdk tool (shares cache directory).
  • Get for any platform, not just host platform.

Possible Uses

  • Build packages with embedded runtimes.
  • Download specific versions of webservers for testing.
  • Multi-language builds and continuous integration

Limitations

  • Doesn't support install or use commands of SDKMan. It is effectively just the download command.

Installation

Add the following coordinates to your pom.xml:

Maven

<plugin>
    <groupId>uk.co.bithatch</groupId>
    <artifactId>get-sdk-maven-plugin</artifactId>
    <version>0.0.2</version>
</plugin>

Gradle

implementation("uk.co.bithatch:get-sdk-maven-plugin:0.0.1-SNAPSHOT")

Configuration

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

Platforms

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

Injected Properties

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)

Usage Example

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>

Changes

Version Changes
0.0.2 Added vendor option, better multi architecture support and version range (minVersion and maxVersion).

About

Maven Plugin that uses SDKMan to download any supported SDK such as Java rutimes into your project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages