Skip to content

feat: detect project's openjdk version#169

Merged
vpa1977 merged 28 commits intorockcrafters:mainfrom
vpa1977:toolchain
Dec 2, 2025
Merged

feat: detect project's openjdk version#169
vpa1977 merged 28 commits intorockcrafters:mainfrom
vpa1977:toolchain

Conversation

@vpa1977
Copy link
Collaborator

@vpa1977 vpa1977 commented Dec 1, 2025

Changes:

  • update maven project to use build JDK 21 and use --release 8

  • Add Toolchain helpers to read Maven and Gradle toolchain settings. If not configured, use current Java. Default to OpenJDK 21 if OpenJDK supported by chisel is not found (8,11,17 and 21).

  • Add unit and integration tests.

  • Have you signed the CLA?


@vpa1977 vpa1977 self-assigned this Dec 1, 2025
@vpa1977 vpa1977 requested a review from Copilot December 1, 2025 02:28
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds automatic detection of the project's OpenJDK version from the configured Java toolchain. Instead of defaulting to openjdk-21-jdk, the build tools now inspect the Maven/Gradle toolchain configuration to determine the appropriate JDK package.

Key changes:

  • Introduced ToolchainHelper utility to parse javac -version output and map versions to OpenJDK packages
  • Added toolchain detection in both Maven and Gradle plugins via new Toolchain classes
  • Modified default buildPackage from hardcoded openjdk-21-jdk to empty string, triggering automatic detection
  • Added comprehensive test coverage for toolchain version detection (Java 8, 11, 17)

Reviewed changes

Copilot reviewed 22 out of 22 changed files in this pull request and generated 10 comments.

Show a summary per file
File Description
ToolchainHelper.java Core utility for detecting JDK version from javac executable
Toolchain.java (maven) Maven-specific toolchain detection using ToolchainManager
Toolchain.java (gradle) Gradle-specific toolchain detection using JavaToolchainService
CommonRockcraftOptions.java Changed default buildPackage from "openjdk-21-jdk" to ""
BuildRockcraftOptions.java Removed hardcoded openjdk-21-jdk-headless default
CreateBuildRockMojo.java Added toolchain detection when buildPackage is empty
AbstractRockMojo.java Added toolchain detection when buildPackage is empty
CreateRockcraftTask.java Added toolchain detection when buildPackage is empty
CreateBuildRockcraftTask.java Added toolchain detection and JavaToolchainService injection
AbstractRockcraftTask.java Changed to abstract class with JavaToolchainService injection
BuildRockcraftTask.java Changed to abstract class for toolchain service injection
PushRockcraftTask.java Changed to abstract class for toolchain service injection
ToolchainTest.java Unit tests for Maven toolchain detection logic
CreateBuildRockTest.java Integration test for Gradle toolchain detection
RawRunimePartTest.java Updated test to set buildPackage explicitly
pom.xml Updated Mockito version and added mockito-core/junit-jupiter dependencies
toolchain-test/* Integration test resources for Maven toolchain verification
toolchain-options.in Test fixture for Gradle toolchain configuration

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

vpa1977 and others added 8 commits December 1, 2025 15:36
Mockito 5.x requires 11+.
Use --release 8 in the pom.xml to produce Java 8 compatible
classes.
Use Java 21 for building.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
Toolchain unit tests try to run Java 8 and Java 11
javac.
@vpa1977 vpa1977 requested a review from Copilot December 1, 2025 03:10
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 25 out of 25 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

vpa1977 and others added 6 commits December 1, 2025 16:12
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Vladimir Petko <vladimir.petko@canonical.com>
Pulled toolchain service down since only Create(Build)Rock tasks need it.
- specify openjdk discovery configuration
- require openjdk range
@vpa1977 vpa1977 requested a review from pushkarnk December 1, 2025 08:49
@vpa1977 vpa1977 added this pull request to the merge queue Dec 2, 2025
Merged via the queue into rockcrafters:main with commit d7a1e5c Dec 2, 2025
6 of 10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants