maven plugin should not use staged runtime
Metadata
Current evaluation
No evaluation has been recorded for this issue yet.
Issue body
### Bug Description
Maven plugin tries to use staged Java runtime instead of the one installed as the build package.
This causes a subsequent build failure due to runtime missing necessary modules to compile Java files.
### To Reproduce
1. rockcraft pack
Build succeeds
3. rockcraft pack
Build fails
### part yaml
```shell
name: maven-sample-chisel
version: 0.0.1
summary: Sample Maven-based chiselled rock
description: |
This image is a sample maven application
using openjdk-21-jre-headless slices
base: bare
build-base: ubuntu@24.04
run-user: _daemon_
platforms:
amd64:
services:
test:
override: replace
summary: Service summary
command: /usr/bin/java -jar /jars/sample-0.0.1-SNAPSHOT.jar
startup: enabled
parts:
application:
plugin: maven
source: ./sample
source-type: local
build-packages:
- maven
- openjdk-21-jdk-headless
runtime:
plugin: nil
source: https://github.com/vpa1977/chisel-releases
source-type: git
source-branch: 24.04-openjdk-21-jre-headless
build-packages:
- ca-certificates-java
override-build: |
chisel cut --release ./ --root ${CRAFT_PART_INSTALL} \
base-files_base openjdk-21-jre-headless_security \
openjdk-21-jre-headless_management \
openjdk-21-jre-headless_jfr
mkdir -p ${CRAFT_PART_INSTALL}/etc/ssl/certs/java/
cp /etc/ssl/certs/java/cacerts ${CRAFT_PART_INSTALL}/etc/ssl/certs/java/cacerts
java_bin=$(find ${CRAFT_PART_INSTALL} -name java -type f -executable)
ln -s --relative $java_bin ${CRAFT_PART_INSTALL}/usr/bin/java
```
### Relevant log output
```shell
2024-08-16 15:15:30.892 :: ## Plugin environment
2024-08-16 15:15:30.892 :: ## User environment
2024-08-16 15:15:30.892 :: 2024-08-16 15:15:29.753 plugin validation command: 'mvn --version'
2024-08-16 15:15:30.892 :: 2024-08-16 15:15:29.861 executed mvn --version with output [1mApache Maven 3.8.7[m
2024-08-16 15:15:30.892 :: Maven home: /usr/share/maven
2024-08-16 15:15:30.892 :: Java version: 21.0.4, vendor: Ubuntu, runtime: /root/stage/usr/lib/jvm/java-21-openjdk-amd64
2024-08-16 15:15:30.892 :: Default locale: en, platform encoding: UTF-8
2024-08-16 15:15:30.892 :: OS name: "linux", version: "6.8.0-40-generic", arch: "amd64", family: "unix"
2024-08-16 15:15:30.892 :: 2024-08-16 15:15:29.861 Executing PosixPath('/root/parts/application/run/build.sh')
```
Evaluation history
No evaluation history available.