Dependency downloaded but module not found
Description
To simply put, Maven have downloaded dependencies, but failed at compiling, saying that it can not find module.
I'm using GSON on my project, it runs well locally, but on GitHub action, Maven keeps reporting the error.
Error: COMPILATION ERROR :
Error: /home/runner/work/gson-ci/gson-ci/src/main/java/module-info.java:[3,24] module not found: com.google.gson
Although accroding to the log, it have downloaded dependencies successfully.
Reproduce
I've abstracted away irrelevant things, left this small repo: LingkKang/gson-ci, and the action still failed to run:
- Java CI with Maven · LingkKang/gson-ci@c3f0f74
-
Java CI with Maven · LingkKang/gson-ci@7272b1d (with Maven
-Xand-eflags)
Expected behavior:
Pass the CI.
Actual behavior:
CI failed at Maven compiling.
Task version
uses: actions/setup-java@v4
with:
java-version: '21'
distribution: 'zulu'
cache: maven
java-package: jdk+fx
Never tried other distributions because I'm going to use JavaFX.
Platform
- [x] Ubuntu
- [ ] macOS (not tested
- [x] Windows
Runner type
- [x] Hosted
- [ ] Self-hosted
I'm not sure is this really a bug of setup-java, it might due to different Maven version or GSON, but as it can build on local machine, I suspect it was caused by setup-java. 😢
Hi, @LingkKang 👋 Thanks for the bug report, we will investigate the issue and get back to you with updates.
This is probably because of too old Maven version.
I tried to set up JDK and Maven (using 3.9.6, the latest stable version) manually, and the workflow successed.
A naive demo can be found here:
- new CI config ci.yml at main
- the running result Run Maven compile · LingkKang/gson-ci@108f116.
Additionally, answer of this StackOverflow question 👇 suggested that newer version of Maven compiler plugin can fix it. I suspect they are somehow related.
java - Maven dependency module not found - Stack Overflow
Hope this can help :D