Compare commits

..

4 Commits

Author SHA1 Message Date
copilot-swe-agent[bot] 47340fb2e8 test: update maven cache error test name for extensions.xml 2026-06-22 20:59:43 +00:00
Bruno Borges 9525efcdb4 Merge branch 'main' into copilot/support-caching-maven-plugin-dependencies 2026-06-22 16:44:12 -04:00
copilot-swe-agent[bot] 7cec43d3da feat: add .mvn/extensions.xml to Maven cache key pattern
Closes #990

Maven build extensions declared in `.mvn/extensions.xml` can introduce
additional plugin dependencies (e.g. lifecycle participants, custom
packaging types). Including this file in the cache key hash ensures that
changes to extensions — which affect what plugin JARs Maven downloads —
properly invalidate the cache, preventing stale caches from missing
newly-required plugin dependencies.

Changes:
- src/cache.ts: add `**/.mvn/extensions.xml` to Maven pattern array
- __tests__/cache.test.ts: update pattern expectations; add new test
- README.md: document the new file in the Maven cache key hash list
2026-06-22 19:23:39 +00:00
copilot-swe-agent[bot] c3b0b6b300 Initial plan 2026-06-22 19:16:54 +00:00
18 changed files with 859 additions and 776 deletions
+6
View File
@@ -0,0 +1,6 @@
# Ignore list
/*
# Do not ignore these folders:
!__tests__/
!src/
+51
View File
@@ -0,0 +1,51 @@
// This is a reusable configuration file copied from https://github.com/actions/reusable-workflows/tree/main/reusable-configurations. Please don't make changes to this file as it's the subject of an automatic update.
module.exports = {
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'plugin:eslint-plugin-jest/recommended',
'eslint-config-prettier'
],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'eslint-plugin-node', 'eslint-plugin-jest'],
rules: {
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
'yoda': 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}],
'node/no-extraneous-import': 'error'
},
overrides: [
{
files: ['**/*{test,spec}.ts'],
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'jest/no-standalone-expect': 'off',
'jest/no-conditional-expect': 'off',
'no-console': 'off',
}
}
],
env: {
node: true,
es6: true,
'jest/globals': true
}
};
@@ -1,22 +0,0 @@
---
name: New Java distribution template
about: Suggest a new Java distribution
title: ''
labels: feature request, needs triage
assignees: ''
---
**Description:**
Describe your proposal.
**Justification:**
Justification or a use case for your proposal.
**Download URL:**
Download URL for the new distribution.
**License:**
Link to the license for the new distribution.
**Are you willing to submit a PR?**
<!--- We accept contributions! -->
@@ -1,16 +0,0 @@
**Description:**
Describe your changes.
**Related issue:**
Add link to the related issue.
**Download URL:**
Download URL for the new distribution.
**License:**
Link to the license for the new distribution.
**Check list:**
- [ ] Mark if documentation changes are required.
- [ ] Mark if tests were added or updated to cover the changes.
- [ ] Mark if new distribution is being added.
@@ -24,7 +24,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
@@ -51,7 +51,7 @@ jobs:
needs: gradle1-save
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
@@ -76,7 +76,7 @@ jobs:
needs: gradle1-save
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
+6 -6
View File
@@ -24,7 +24,7 @@ jobs:
os: [macos-15-intel, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
@@ -50,7 +50,7 @@ jobs:
needs: gradle-save
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Run setup-java with the cache for gradle
uses: ./
id: setup-java
@@ -73,7 +73,7 @@ jobs:
os: [macos-15-intel, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Run setup-java with the cache for maven
uses: ./
id: setup-java
@@ -97,7 +97,7 @@ jobs:
needs: maven-save
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Run setup-java with the cache for maven
uses: ./
id: setup-java
@@ -124,7 +124,7 @@ jobs:
os: [macos-15-intel, windows-latest, ubuntu-22.04]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Run setup-java with the cache for sbt
uses: ./
id: setup-java
@@ -174,7 +174,7 @@ jobs:
needs: sbt-save
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Run setup-java with the cache for sbt
uses: ./
id: setup-java
+3 -3
View File
@@ -21,7 +21,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Download Adopt OpenJDK file
run: |
if ($IsLinux) {
@@ -58,7 +58,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Download Zulu OpenJDK file
run: |
if ($IsLinux) {
@@ -95,7 +95,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Download Eclipse Temurin file
run: |
if ($IsLinux) {
+4 -4
View File
@@ -25,7 +25,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -60,7 +60,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Create fake settings.xml
run: |
$xmlDirectory = Join-Path $HOME ".m2"
@@ -96,7 +96,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Create fake settings.xml
run: |
$xmlDirectory = Join-Path $HOME ".m2"
@@ -133,7 +133,7 @@ jobs:
os: [macos-latest, windows-latest, ubuntu-latest]
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
+14 -14
View File
@@ -73,7 +73,7 @@ jobs:
version: '24-ea'
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -99,7 +99,7 @@ jobs:
version: ['21', '17']
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Install bash
run: apk add --no-cache bash
- name: setup-java
@@ -149,7 +149,7 @@ jobs:
version: '17.0.7'
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -184,7 +184,7 @@ jobs:
os: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -220,7 +220,7 @@ jobs:
os: macos-latest
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -259,7 +259,7 @@ jobs:
version: ['17-ea', '15.0.0-ea.14']
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -281,7 +281,7 @@ jobs:
version: ['17-ea']
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -303,7 +303,7 @@ jobs:
version: ['17-ea', '21-ea']
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -390,7 +390,7 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -418,7 +418,7 @@ jobs:
version: ['11']
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: setup-java
uses: ./
id: setup-java
@@ -441,7 +441,7 @@ jobs:
java-version-file: ['.java-version', '.tool-versions']
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Create .java-version file
shell: bash
run: echo "17" > .java-version
@@ -470,7 +470,7 @@ jobs:
java-version-file: ['.java-version', '.tool-versions']
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Create .java-version file
shell: bash
run: echo "11" > .java-version
@@ -498,7 +498,7 @@ jobs:
java-version-file: ['.java-version', '.tool-versions']
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Create .java-version file
shell: bash
run: echo "17.0.10" > .java-version
@@ -526,7 +526,7 @@ jobs:
java-version-file: ['.java-version', '.tool-versions', '.sdkmanrc']
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Create .java-version file
shell: bash
run: echo "openjdk64-17.0.10" > .java-version
@@ -15,7 +15,7 @@ jobs:
steps:
- name: Checking out
uses: actions/checkout@v7
uses: actions/checkout@v6
- name: Publish
id: publish
uses: actions/publish-immutable-action@v0.0.4
+2 -3
View File
@@ -37,7 +37,7 @@ For more details, see the full release notes on the [releases page](https://git
- `architecture`: The target architecture of the package. Possible values: `x86`, `x64`, `armv7`, `aarch64`, `ppc64le`. Default value: Derived from the runner machine.
- `jdkFile`: If a use-case requires a custom distribution setup-java uses the compressed JDK from the location pointed by this input and will take care of the installation and caching on the VM. Note: `distribution` must be set to 'jdkfile' (case-sensitive; all lowercase) when using this option.
- `jdkFile`: If a use-case requires a custom distribution setup-java uses the compressed JDK from the location pointed by this input and will take care of the installation and caching on the VM.
- `check-latest`: Setting this option makes the action to check for the latest available version for the version spec.
@@ -113,7 +113,6 @@ Currently, the following distributions are supported:
| `sapmachine` | [SAP SapMachine JDK/JRE](https://sapmachine.io/) | [`sapmachine` license](https://github.com/SAP/SapMachine/blob/sapmachine/LICENSE)
| `graalvm` | [Oracle GraalVM](https://www.graalvm.org/) | [`graalvm` license](https://www.oracle.com/downloads/licenses/graal-free-license.html)
| `jetbrains` | [JetBrains Runtime](https://github.com/JetBrains/JetBrainsRuntime/) | [`jetbrains` license](https://github.com/JetBrains/JetBrainsRuntime/blob/main/LICENSE)
| `jdkfile` | Custom JDK Installation | |
> [!NOTE]
> - The different distributors can provide discrepant list of available versions / supported configurations. Please refer to the official documentation to see the list of supported versions.
@@ -129,7 +128,7 @@ Currently, the following distributions are supported:
The action has a built-in functionality for caching and restoring dependencies. It uses [toolkit/cache](https://github.com/actions/toolkit/tree/main/packages/cache) under hood for caching dependencies but requires less configuration settings. Supported package managers are gradle, maven and sbt. The format of the used cache key is `setup-java-${{ platform }}-${{ packageManager }}-${{ fileHash }}`, where the hash is based on the following files:
- gradle: `**/*.gradle*`, `**/gradle-wrapper.properties`, `buildSrc/**/Versions.kt`, `buildSrc/**/Dependencies.kt`, `gradle/*.versions.toml`, and `**/versions.properties`
- maven: `**/pom.xml` and `**/.mvn/wrapper/maven-wrapper.properties`
- maven: `**/pom.xml`, `**/.mvn/wrapper/maven-wrapper.properties`, and `**/.mvn/extensions.xml`
- sbt: all sbt build definition files `**/*.sbt`, `**/project/build.properties`, `**/project/**.scala`, `**/project/**.sbt`
When the option `cache-dependency-path` is specified, the hash is based on the matching file. This option supports wildcards and a list of file names, and is especially useful for monorepos.
+22 -4
View File
@@ -96,11 +96,11 @@ describe('dependency cache', () => {
});
describe('for maven', () => {
it('throws error if no pom.xml or maven-wrapper.properties found', async () => {
it('throws error if no pom.xml, maven-wrapper.properties, or extensions.xml found', async () => {
await expect(restore('maven', '')).rejects.toThrow(
`No file in ${projectRoot(
workspace
)} matched to [**/pom.xml,**/.mvn/wrapper/maven-wrapper.properties], make sure you have checked out the target repository`
)} matched to [**/pom.xml,**/.mvn/wrapper/maven-wrapper.properties,**/.mvn/extensions.xml], make sure you have checked out the target repository`
);
});
it('downloads cache based on pom.xml', async () => {
@@ -115,7 +115,7 @@ describe('dependency cache', () => {
expect.any(String)
);
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties'
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties\n**/.mvn/extensions.xml'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
@@ -136,7 +136,25 @@ describe('dependency cache', () => {
expect.any(String)
);
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties'
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties\n**/.mvn/extensions.xml'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
});
it('downloads cache based on extensions.xml', async () => {
createDirectory(join(workspace, '.mvn'));
createFile(join(workspace, '.mvn', 'extensions.xml'));
await restore('maven', '');
expect(spyCacheRestore).toHaveBeenCalledWith(
[
join(os.homedir(), '.m2', 'repository'),
join(os.homedir(), '.m2', 'wrapper', 'dists')
],
expect.any(String)
);
expect(spyGlobHashFiles).toHaveBeenCalledWith(
'**/pom.xml\n**/.mvn/wrapper/maven-wrapper.properties\n**/.mvn/extensions.xml'
);
expect(spyWarning).not.toHaveBeenCalled();
expect(spyInfo).toHaveBeenCalledWith('maven cache is not found');
+5 -1
View File
@@ -51973,7 +51973,11 @@ const supportedPackageManager = [
(0, path_1.join)(os_1.default.homedir(), '.m2', 'wrapper', 'dists')
],
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
pattern: ['**/pom.xml', '**/.mvn/wrapper/maven-wrapper.properties']
pattern: [
'**/pom.xml',
'**/.mvn/wrapper/maven-wrapper.properties',
'**/.mvn/extensions.xml'
]
},
{
id: 'gradle',
+5 -1
View File
@@ -77837,7 +77837,11 @@ const supportedPackageManager = [
(0, path_1.join)(os_1.default.homedir(), '.m2', 'wrapper', 'dists')
],
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
pattern: ['**/pom.xml', '**/.mvn/wrapper/maven-wrapper.properties']
pattern: [
'**/pom.xml',
'**/.mvn/wrapper/maven-wrapper.properties',
'**/.mvn/extensions.xml'
]
},
{
id: 'gradle',
-83
View File
@@ -1,83 +0,0 @@
import js from '@eslint/js';
import tseslint from 'typescript-eslint';
import jestPlugin from 'eslint-plugin-jest';
import nodePlugin from 'eslint-plugin-n';
import eslintConfigPrettier from 'eslint-config-prettier';
import globals from 'globals';
export default tseslint.config(
{
ignores: [
'dist/',
'lib/',
'node_modules/',
'coverage/',
'**/*.js',
'**/*.cjs',
'**/*.mjs',
'**/*.d.ts'
]
},
{
files: ['src/**/*.ts', '__tests__/**/*.ts'],
extends: [
js.configs.recommended,
...tseslint.configs.recommended,
jestPlugin.configs['flat/recommended'],
eslintConfigPrettier
],
plugins: {
n: nodePlugin
},
languageOptions: {
ecmaVersion: 2021,
sourceType: 'module',
globals: {
...globals.node,
...globals.es2021
}
},
rules: {
'@typescript-eslint/no-require-imports': 'error',
'@typescript-eslint/no-non-null-assertion': 'off',
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': [
'error',
{
'ts-ignore': 'allow-with-description'
}
],
'no-console': 'error',
yoda: 'error',
'prefer-const': [
'error',
{
destructuring: 'all'
}
],
'no-control-regex': 'off',
'no-constant-condition': ['error', {checkLoops: false}],
// ESLint 10's recommended set adds `preserve-caught-error`, which the
// previous ESLint 8 recommended config did not enable. Keep it off to
// preserve the prior lint behavior; adopting it would require attaching
// an Error `cause` (ES2022) and is out of scope for this upgrade.
'preserve-caught-error': 'off',
'n/no-extraneous-import': 'error'
}
},
{
files: ['**/*{test,spec}.ts'],
languageOptions: {
globals: {
...globals.jest
}
},
rules: {
'@typescript-eslint/no-unused-vars': 'off',
'jest/no-standalone-expect': 'off',
'jest/no-conditional-expect': 'off',
'no-console': 'off'
}
}
);
+723 -604
View File
File diff suppressed because it is too large Load Diff
+9 -10
View File
@@ -11,8 +11,8 @@
"build": "ncc build -o dist/setup src/setup-java.ts && ncc build -o dist/cleanup src/cleanup-java.ts",
"format": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --write \"**/*.{ts,yml,yaml}\"",
"format-check": "prettier --no-error-on-unmatched-pattern --config ./.prettierrc.js --check \"**/*.{ts,yml,yaml}\"",
"lint": "eslint \"src/**/*.ts\" \"__tests__/**/*.ts\"",
"lint:fix": "eslint \"src/**/*.ts\" \"__tests__/**/*.ts\" --fix",
"lint": "eslint --config ./.eslintrc.js \"**/*.ts\"",
"lint:fix": "eslint --config ./.eslintrc.js \"**/*.ts\" --fix",
"prerelease": "npm run-script build",
"release": "git add -f dist/setup/index.js dist/cleanup/index.js",
"test": "jest"
@@ -40,22 +40,21 @@
"xmlbuilder2": "^4.0.3"
},
"devDependencies": {
"@eslint/js": "^10.0.1",
"@types/jest": "^30.0.0",
"@types/node": "^26.0.0",
"@types/node": "^25.9.3",
"@types/semver": "^7.5.8",
"@typescript-eslint/eslint-plugin": "^8.48.0",
"@typescript-eslint/parser": "^8.61.1",
"@vercel/ncc": "^0.44.0",
"eslint": "^10.5.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-jest": "^29.15.2",
"eslint-plugin-n": "^18.1.0",
"globals": "^17.7.0",
"eslint-plugin-jest": "^29.0.1",
"eslint-plugin-node": "^11.1.0",
"jest": "^30.4.2",
"jest-circus": "^30.4.2",
"prettier": "^3.6.2",
"ts-jest": "^29.4.11",
"typescript": "^5.3.3",
"typescript-eslint": "^8.62.0"
"typescript": "^5.3.3"
},
"bugs": {
"url": "https://github.com/actions/setup-java/issues"
+5 -1
View File
@@ -28,7 +28,11 @@ const supportedPackageManager: PackageManager[] = [
join(os.homedir(), '.m2', 'wrapper', 'dists')
],
// https://github.com/actions/cache/blob/0638051e9af2c23d10bb70fa9beffcad6cff9ce3/examples.md#java---maven
pattern: ['**/pom.xml', '**/.mvn/wrapper/maven-wrapper.properties']
pattern: [
'**/pom.xml',
'**/.mvn/wrapper/maven-wrapper.properties',
'**/.mvn/extensions.xml'
]
},
{
id: 'gradle',