setup-java icon indicating copy to clipboard operation
setup-java copied to clipboard

Dependency downloaded but module not found

Open LingkKang opened this issue 2 years ago • 2 comments

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:

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. 😢

LingkKang avatar Dec 13 '23 23:12 LingkKang

Hi, @LingkKang 👋 Thanks for the bug report, we will investigate the issue and get back to you with updates.

IvanZosimov avatar Dec 14 '23 10:12 IvanZosimov

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:

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

LingkKang avatar Dec 15 '23 23:12 LingkKang