Skip to content

CI / GitHub workflow: Cache Maven Wrapper artifacts#3329

Open
guusdk wants to merge 1 commit into
igniterealtime:mainfrom
guusdk:CI_GitHub-cache-mvnw
Open

CI / GitHub workflow: Cache Maven Wrapper artifacts#3329
guusdk wants to merge 1 commit into
igniterealtime:mainfrom
guusdk:CI_GitHub-cache-mvnw

Conversation

@guusdk
Copy link
Copy Markdown
Member

@guusdk guusdk commented May 12, 2026

Our GitHub workflow uses the 'maven' cache that's provided by the actions/setup-java action.

I was surprised to see the following build failure earlier today:

Run ./mvnw -B install --file pom.xml
  ./mvnw -B install --file pom.xml
  shell: /usr/bin/bash -e {0}
  env:
    CI: true
    REGISTRY: ghcr.io
    IMAGE_NAME: openfire
    JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/25.0.3-9/x64
    JAVA_HOME_25_X64: /opt/hostedtoolcache/Java_Zulu_jdk/25.0.3-9/x64
Error: Exception in thread "main" java.io.IOException: Server returned HTTP response code: 429 for URL: https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1713)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1305)
	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:223)
	at org.apache.maven.wrapper.DefaultDownloader.downloadInternal(DefaultDownloader.java:100)
	at org.apache.maven.wrapper.DefaultDownloader.download(DefaultDownloader.java:86)
	at org.apache.maven.wrapper.Installer.createDist(Installer.java:84)
	at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:160)
	at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:73)
Error: Process completed with exit code 1.

This shows that Maven is still being downloaded, instead of the wrapped version being cached/used.

Apparently, the 'maven' cache from the actions/setup-java action does not cache these artifacts. With the changes in this commit, they now should.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 12, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: b1eef1bb-23f7-4a72-b042-66c43f8db2e5

📥 Commits

Reviewing files that changed from the base of the PR and between 103431f and 2289e3c.

📒 Files selected for processing (1)
  • .github/workflows/continuous-integration-workflow.yml
🚧 Files skipped from review as they are similar to previous changes (1)
  • .github/workflows/continuous-integration-workflow.yml

📝 Walkthrough

Walkthrough

This PR adds Maven wrapper distribution caching to the continuous-integration-workflow.yml file. The change inserts an actions/cache@v4 step into 13 job definitions across the workflow, caching the ~/.m2/wrapper directory. The cache key is computed from the runner OS and a hash of **/.mvn/wrapper/maven-wrapper.properties, with OS-prefixed restore-keys to enable partial cache restoration when exact matches are unavailable.

Suggested reviewers

  • Fishbowler
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining a real CI failure and the motivation for caching Maven Wrapper artifacts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Comment @coderabbitai help to get the list of available commands and usage tips.

@guusdk
Copy link
Copy Markdown
Member Author

guusdk commented May 12, 2026

At the time of writing, setup-java indeed doesn't seem to cache this. There's an open issue for this here: actions/setup-java#448

Our GitHub workflow uses the 'maven' cache that's provided by the `actions/setup-java` action.

I was surprised to see the following build failure earlier today:

```
Run ./mvnw -B install --file pom.xml
  ./mvnw -B install --file pom.xml
  shell: /usr/bin/bash -e {0}
  env:
    CI: true
    REGISTRY: ghcr.io
    IMAGE_NAME: openfire
    JAVA_HOME: /opt/hostedtoolcache/Java_Zulu_jdk/25.0.3-9/x64
    JAVA_HOME_25_X64: /opt/hostedtoolcache/Java_Zulu_jdk/25.0.3-9/x64
Error: Exception in thread "main" java.io.IOException: Server returned HTTP response code: 429 for URL: https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1713)
	at java.base/sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1305)
	at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:223)
	at org.apache.maven.wrapper.DefaultDownloader.downloadInternal(DefaultDownloader.java:100)
	at org.apache.maven.wrapper.DefaultDownloader.download(DefaultDownloader.java:86)
	at org.apache.maven.wrapper.Installer.createDist(Installer.java:84)
	at org.apache.maven.wrapper.WrapperExecutor.execute(WrapperExecutor.java:160)
	at org.apache.maven.wrapper.MavenWrapperMain.main(MavenWrapperMain.java:73)
Error: Process completed with exit code 1.
```

This shows that Maven is still being downloaded, instead of the wrapped version being cached/used.

Apparently, the 'maven' cache from the `actions/setup-java` action does not cache these artifacts. With the changes in this commit, they now should.
@guusdk guusdk force-pushed the CI_GitHub-cache-mvnw branch from 103431f to 2289e3c Compare May 13, 2026 08:50
Copy link
Copy Markdown
Member

@Fishbowler Fishbowler left a comment

Choose a reason for hiding this comment

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

Seems reasonable.

Nitpick on the version used.

distribution: ${{ matrix.distribution }}
cache: maven
- name: Cache Maven wrapper distribution
uses: actions/cache@v4
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason to avoid vLatest?

Suggested change
uses: actions/cache@v4
uses: actions/cache@v5

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.

2 participants