← Back to issue list

maven/ant plugins: `create_usr_bin_java` creates a stray `./java` link; second `rockcraft pack` fails

View original Github issue

Metadata

Project
rockcraft
Number
#1388
Type
issue
State
open
Author
javierdelapuente
Labels
—
Created
Updated
Closed
—

Current evaluation

Maven/Ant plugins fail on re-builds because create_usr_bin_java uses test -f instead of test -e to check for existing java symlink

Suggested action: keep open

Reason: The bug is clear: create_usr_bin_java() uses `test -f` which returns false for symlinks, causing `ln` to fail on re-builds. The fix is a one-character change (f to e) in java_common.py. A contributor (navyabijoy) has volunteered to implement the fix with a test.

Evaluated by: mr-cal-bot

Impact: 40 Quick Win: 31 Complexity: 10 Confidence: 85 Actionability: 85

Issue body

### Check existing issues - [x] I've verified that this bug isn't described by any existing issues. ### Bug description A project that uses the `maven` plugin packs fine the first time. After any change (for example the `version`), the next `rockcraft pack` fails: ln: failed to create symbolic link './java': Already exists Failed to run the build script for part 'app'. `rockcraft clean` makes it work again, once. Also happens with the `spring-boot-framework` extension, where the failing part is `spring-boot-framework.install-app`. ### Steps to reproduce 1. Use the `rockcraft.yaml` below with any minimal `pom.xml` and one Java class. 2. `rockcraft pack` works. 3. Run `rockcraft pack` again without changes: "Already packed". 4. Change `version` and run `rockcraft pack` again: it fails. ### Environment LXD, Ubuntu 26.04 host, Rockcraft 1.21.0 (edge). ### rockcraft.yaml ```yaml name: javaln base: ubuntu@26.04 version: '1' summary: repro description: repro license: Apache-2.0 platforms: amd64: parts: app: plugin: maven source: . build-packages: [default-jdk, maven] ``` ### Log output ```shell Failed to run the build script for part 'app'. Detailed information: :: + test -d /root/parts/app/install/usr/bin :: + test -f /root/parts/app/install/usr/bin/java :: + ln -s --relative /root/parts/app/install/usr/bin/java :: ln: failed to create symbolic link './java': Already exists Recommended resolution: Check the build output and verify the project can work with the 'maven' plugin. For more information, check out: https://documentation.ubuntu.com/rockcraft/latest/reference/plugins/ Failed to run rockcraft in instance Full execution log: '/home/ubuntu/.local/state/rockcraft/log/rockcraft-20261014-172049.508198.log' ```

Evaluation history

Date Model Scores Action Summary
qwen/qwen3.6-35b-a3b
Impact: 40
Quick Win: 31
Complexity: 10
Confidence: 85
Actionability: 85
keep open Maven/Ant plugins fail on re-builds because create_usr_bin_java uses test -f instead of test -e to check for existing java symlink

Update history

Date Change
updated
created

Related work

  • Related To: rockcraft#752 (confidence 80%)

    Related PR that removed /bin/java symlink creation but did not address the /usr/bin/java symlink idempotency issue

Related issues

Issue Project State Summary Similarity
#752 feat: do not create /bin/java symlink rockcraft merged Merged in canonical/rockcraft#752 as b7ea7434, preventing Maven and Ant plugins from creating /bin/java symlinks so those plugins can build rocks.
72%