As Workshop ramps up with new features and adopters, it came time to prepare SDKs for the Java ecosystem. Workshop allows users to launch sandboxed development environments that can be composed with pre-built or custom Software Development Kits (SDKs) with a single command.
With help from the Reference SDKs repository, SDKCraft documentation and some minor guidance from the Workshops team, we were able to create and publish full-featured SDKs for the OpenJDK runtime, Maven and Gradle build tools. Overall this process was effortless, as SDKCraft leverages the parts mechanism from the upstream Craft Application project, making the design-approach familiar to creating tools with Snapcraft and Charmcraft.
Available Tooling
The following SDKs have been made available for the Java ecosystem:
| SDK Name | Versions | Description |
|---|---|---|
openjdk |
17, 21 and 25 | Open-source Java Development Kit (JDK) |
maven |
3.9 | Apache Maven build tool |
gradle |
8 and 9 | Gradle build tool |
Example Usage
To get started using these SDKs, let’s take a look at creating a Workshop for the petclinic sample application. Before starting, make sure to install Workshop and its prerequisites, to ensure it runs. This can be done with the following commands:
sudo snap install --channel=6/stable lxd
sudo snap install --classic workshop
For the project directory, we clone the target repository as normal:
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
Before initializing a workshop, we can search the SDK Store to confirm whether they exist and also get information about the publisher and versions available.
sdk find openjdk # To confirm/search for available SDKs
sdk info openjdk # Inspect an SDKs release information
Note: Since openjdk does not yet have a latest/stable channel, using sdk find will not find any matching SDKs. The command sdk info will still work and will show all the available channels.
From here we can initialize a workshop definition with the workshop init command and our choice of SDKs:
workshop init dev --sdks openjdk/21/stable,maven/3.9/stable --base ubuntu@24.04
The choice of dev as the name of the workshop here is arbitrary, however it could reflect the expected environment context. For example, a project could have development, production and testing workshop definitions to sandbox all potential release environments.
This command writes the definition to the .workshop/dev.yaml file with SDKs pinned to their respective channels. We can then further extend this configuration to also include a slot and plug pair to expose the eventual application over the localhost:8080 endpoint, and some actions to manage the application:
name: dev
base: ubuntu@24.04
sdks:
- name: openjdk
channel: 21/stable
- name: maven
channel: 3.9/stable
slots:
petclinic:
interface: tunnel
endpoint: localhost:8080
- name: system
plugs:
petclinic:
interface: tunnel
endpoint: localhost:8080
actions:
build: mvn clean package # Note: We use `mvn` over the `./mvnw` wrapper
start: mvn spring-boot:run # to use our custom defined channel version
The plug and slot pair that we defined above are the interfaces that define how to communicate and share resources. This allows each workshop to operate in its own isolated environment, whilst still allowing controlled interactions between the SDKs and the host. In our example, we first define a slot for Maven which provides the capability to expose a desired network endpoint through the tunnel interface. Secondly our example defines a tunnel plug that consumes the capability provided by the Maven slot. Since the plug defined is for the system SDK, this then routes the Maven endpoint to the host endpoint and allows us to access the application from the host. This can be seen in the diagram below, where our interface pairing allows the client access to the application in the workshop.
After adding the changes above, we can launch the workshop, confirm the runtime information matches above and start the application. In launching the workshop with workshop launch or refreshing with workshop refresh, SDKs are automatically pulled and installed into the corresponding development environment.
workshop launch # Prepare workshop after initialization
workshop info # View information about the workshop
workshop run dev -- start # And start the application using Maven
# Alternatively, commands can be execute directly inside the environment
workshop exec dev -- mvn clean package
workshop exec dev -- ls -l target/*.jar
Since we have exposed the application through the configured slot/plug interfaces, we can then see the application in any browser on the host machine at the http://localhost:8080 endpoint.
If you instead want to use the Gradle SDK, we can modify the workshop definition by replacing the maven definition with gradle, and updating the actions to work with Gradle instead.
name: dev
base: ubuntu@24.04
sdks:
- name: openjdk
channel: 17/stable
- name: gradle
channel: 8/stable
slots:
petclinic:
interface: tunnel
endpoint: localhost:8080
- name: system
plugs:
petclinic:
interface: tunnel
endpoint: localhost:8080
actions:
build: gradle build # Note: We use 'gradle' over the './gradlew' wrapper
start: gradle bootRun # since we want to use our defined channel version
After updating the workshop definition, we can refresh the workshop to replace the Maven SDK with our new definition of Gradle and use the commands to start the application.
workshop refresh # Refreshes environment with Gradle
workshop info # Confirm that information has changed
workshop run dev -- start # And start the application using Gradle
Note: For the petclinic project, make sure that the combination of openjdk and the chosen build tool versions are compatible.