mirror of
https://github.com/actions/setup-java.git
synced 2026-06-30 00:52:00 +00:00
Compare commits
3 Commits
222b91ef7e
...
3d7b25620c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3d7b25620c | ||
|
|
2e74cbce18 | ||
|
|
b8162e8075 |
26
.github/workflows/e2e-cache.yml
vendored
26
.github/workflows/e2e-cache.yml
vendored
@ -21,7 +21,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -46,7 +46,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
needs: gradle-save
|
needs: gradle-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -70,7 +70,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -93,7 +93,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
needs: maven-save
|
needs: maven-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -121,7 +121,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
@ -132,17 +132,21 @@ jobs:
|
|||||||
distribution: 'adopt'
|
distribution: 'adopt'
|
||||||
java-version: '11'
|
java-version: '11'
|
||||||
cache: sbt
|
cache: sbt
|
||||||
|
- name: Setup SBT
|
||||||
|
if: matrix.os == 'macos-13'
|
||||||
|
run: |
|
||||||
|
echo ""Installing SBT...""
|
||||||
|
brew install sbt
|
||||||
- name: Create files to cache
|
- name: Create files to cache
|
||||||
run: sbt update
|
run: sbt update
|
||||||
|
|
||||||
- name: Check files to cache on macos-latest
|
- name: Check files to cache on macos-latest
|
||||||
if: matrix.os == 'macos-latest'
|
if: matrix.os == 'macos-13'
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d ~/Library/Caches/Coursier ]; then
|
if [ ! -d ~/Library/Caches/Coursier ]; then
|
||||||
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Check files to cache on windows-latest
|
- name: Check files to cache on windows-latest
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
run: |
|
||||||
@ -150,7 +154,6 @@ jobs:
|
|||||||
echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly"
|
echo "::error::The ~/AppData/Local/Coursier/Cache directory does not exist unexpectedly"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
- name: Check files to cache on ubuntu-latest
|
- name: Check files to cache on ubuntu-latest
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
run: |
|
run: |
|
||||||
@ -158,7 +161,6 @@ jobs:
|
|||||||
echo "::error::The ~/.cache/coursier directory does not exist unexpectedly"
|
echo "::error::The ~/.cache/coursier directory does not exist unexpectedly"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sbt-restore:
|
sbt-restore:
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
defaults:
|
defaults:
|
||||||
@ -168,7 +170,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
needs: sbt-save
|
needs: sbt-save
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -182,14 +184,13 @@ jobs:
|
|||||||
cache: sbt
|
cache: sbt
|
||||||
|
|
||||||
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
- name: Confirm that ~/Library/Caches/Coursier directory has been made
|
||||||
if: matrix.os == 'macos-latest'
|
if: matrix.os == 'macos-13'
|
||||||
run: |
|
run: |
|
||||||
if [ ! -d ~/Library/Caches/Coursier ]; then
|
if [ ! -d ~/Library/Caches/Coursier ]; then
|
||||||
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
echo "::error::The ~/Library/Caches/Coursier directory does not exist unexpectedly"
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
ls ~/Library/Caches/Coursier
|
ls ~/Library/Caches/Coursier
|
||||||
|
|
||||||
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
|
- name: Confirm that ~/AppData/Local/Coursier/Cache directory has been made
|
||||||
if: matrix.os == 'windows-latest'
|
if: matrix.os == 'windows-latest'
|
||||||
run: |
|
run: |
|
||||||
@ -198,7 +199,6 @@ jobs:
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
ls ~/AppData/Local/Coursier/Cache
|
ls ~/AppData/Local/Coursier/Cache
|
||||||
|
|
||||||
- name: Confirm that ~/.cache/coursier directory has been made
|
- name: Confirm that ~/.cache/coursier directory has been made
|
||||||
if: matrix.os == 'ubuntu-latest'
|
if: matrix.os == 'ubuntu-latest'
|
||||||
run: |
|
run: |
|
||||||
|
|||||||
38
.github/workflows/e2e-versions.yml
vendored
38
.github/workflows/e2e-versions.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
distribution: [
|
distribution: [
|
||||||
'temurin',
|
'temurin',
|
||||||
'adopt',
|
'adopt',
|
||||||
@ -32,15 +32,15 @@ jobs:
|
|||||||
'corretto',
|
'corretto',
|
||||||
'dragonwell'
|
'dragonwell'
|
||||||
] # internally 'adopt-hotspot' is the same as 'adopt'
|
] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||||
version: ['8', '11', '17']
|
version: ['21', '11', '17']
|
||||||
exclude:
|
exclude:
|
||||||
- distribution: microsoft
|
- distribution: microsoft
|
||||||
version: 8
|
version: 8
|
||||||
- distribution: dragonwell
|
- distribution: dragonwell
|
||||||
os: macos-latest
|
os: macos-13
|
||||||
include:
|
include:
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: macos-latest
|
os: macos-13
|
||||||
version: 17
|
version: 17
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
os: windows-latest
|
os: windows-latest
|
||||||
@ -73,7 +73,7 @@ jobs:
|
|||||||
distribution: ['temurin', 'zulu', 'liberica']
|
distribution: ['temurin', 'zulu', 'liberica']
|
||||||
version:
|
version:
|
||||||
- '11.0'
|
- '11.0'
|
||||||
- '8.0.302'
|
- '21.0'
|
||||||
- '17.0.7+7'
|
- '17.0.7+7'
|
||||||
include:
|
include:
|
||||||
- distribution: oracle
|
- distribution: oracle
|
||||||
@ -171,7 +171,7 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
version: ['17-ea', '15.0.0-ea.14']
|
version: ['17-ea', '15.0.0-ea.14']
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
@ -215,22 +215,22 @@ jobs:
|
|||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
os: [macos-latest, windows-latest, ubuntu-latest]
|
os: [macos-13, windows-latest, ubuntu-latest]
|
||||||
distribution: ['temurin', 'zulu', 'liberica', 'semeru']
|
distribution: ['temurin', 'zulu', 'liberica', 'semeru']
|
||||||
java-package: ['jre']
|
java-package: ['jre']
|
||||||
version: ['17.0']
|
version: ['17.0']
|
||||||
include:
|
include:
|
||||||
- distribution: 'zulu'
|
- distribution: 'zulu'
|
||||||
java-package: jre+fx
|
java-package: jre+fx
|
||||||
version: '8'
|
version: '21'
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
- distribution: 'zulu'
|
- distribution: 'zulu'
|
||||||
java-package: jdk+fx
|
java-package: jdk+fx
|
||||||
version: '8.0.242'
|
version: '21.0'
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
- distribution: 'liberica'
|
- distribution: 'liberica'
|
||||||
java-package: jdk+fx
|
java-package: jdk+fx
|
||||||
version: '8'
|
version: '21'
|
||||||
os: ubuntu-latest
|
os: ubuntu-latest
|
||||||
- distribution: 'liberica'
|
- distribution: 'liberica'
|
||||||
java-package: jre+fx
|
java-package: jre+fx
|
||||||
@ -294,10 +294,10 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Create .java-version file
|
- name: Create .java-version file
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "8" > .java-version
|
run: echo "17" > .java-version
|
||||||
- name: Create .tool-versions file
|
- name: Create .tool-versions file
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "java 8" > .tool-versions
|
run: echo "java 17" > .tool-versions
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
@ -351,10 +351,10 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Create .java-version file
|
- name: Create .java-version file
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "11.0.2" > .java-version
|
run: echo "17.0.10" > .java-version
|
||||||
- name: Create .tool-versions file
|
- name: Create .tool-versions file
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "java 11.0.2" > .tool-versions
|
run: echo "java 17.0.10" > .tool-versions
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
@ -362,11 +362,11 @@ jobs:
|
|||||||
distribution: ${{ matrix.distribution }}
|
distribution: ${{ matrix.distribution }}
|
||||||
java-version-file: ${{matrix.java-version-file }}
|
java-version-file: ${{matrix.java-version-file }}
|
||||||
- name: Verify Java
|
- name: Verify Java
|
||||||
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
|
run: bash __tests__/verify-java.sh "17.0.10" "${{ steps.setup-java.outputs.path }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|
||||||
setup-java-version-from-file-major-minor-patch-with-dist:
|
setup-java-version-from-file-major-minor-patch-with-dist:
|
||||||
name: ${{ matrix.distribution }} version from file 'openjdk64-11.0.2' - ${{ matrix.os }}
|
name: ${{ matrix.distribution }} version from file 'openjdk64-17.0.10' - ${{ matrix.os }}
|
||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
@ -379,10 +379,10 @@ jobs:
|
|||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
- name: Create .java-version file
|
- name: Create .java-version file
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "openjdk64-11.0.2" > .java-version
|
run: echo "openjdk64-17.0.10" > .java-version
|
||||||
- name: Create .tool-versions file
|
- name: Create .tool-versions file
|
||||||
shell: bash
|
shell: bash
|
||||||
run: echo "java openjdk64-11.0.2" > .tool-versions
|
run: echo "java openjdk64-17.0.10" > .tool-versions
|
||||||
- name: setup-java
|
- name: setup-java
|
||||||
uses: ./
|
uses: ./
|
||||||
id: setup-java
|
id: setup-java
|
||||||
@ -390,5 +390,5 @@ jobs:
|
|||||||
distribution: ${{ matrix.distribution }}
|
distribution: ${{ matrix.distribution }}
|
||||||
java-version-file: ${{matrix.java-version-file }}
|
java-version-file: ${{matrix.java-version-file }}
|
||||||
- name: Verify Java
|
- name: Verify Java
|
||||||
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
|
run: bash __tests__/verify-java.sh "17.0.10" "${{ steps.setup-java.outputs.path }}"
|
||||||
shell: bash
|
shell: bash
|
||||||
|
|||||||
@ -143,7 +143,20 @@ describe('toolchains tests', () => {
|
|||||||
</toolchain>
|
</toolchain>
|
||||||
</toolchains>`;
|
</toolchains>`;
|
||||||
const result = `<?xml version="1.0"?>
|
const result = `<?xml version="1.0"?>
|
||||||
<toolchains>
|
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>17</version>
|
||||||
|
<vendor>Eclipse Temurin</vendor>
|
||||||
|
<id>temurin_17</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
<toolchain>
|
<toolchain>
|
||||||
<type>jdk</type>
|
<type>jdk</type>
|
||||||
<provides>
|
<provides>
|
||||||
@ -155,6 +168,442 @@ describe('toolchains tests', () => {
|
|||||||
<jdkHome>/opt/jdk/sun/1.6</jdkHome>
|
<jdkHome>/opt/jdk/sun/1.6</jdkHome>
|
||||||
</configuration>
|
</configuration>
|
||||||
</toolchain>
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
|
||||||
|
fs.mkdirSync(m2Dir, {recursive: true});
|
||||||
|
fs.writeFileSync(toolchainsFile, originalFile);
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
|
||||||
|
await toolchains.createToolchainsSettings({
|
||||||
|
jdkInfo,
|
||||||
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
expect(fs.readFileSync(toolchainsFile, 'utf-8')).toEqual(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
).toEqual(result);
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
it('does not discard custom elements in existing toolchain definitions', async () => {
|
||||||
|
const jdkInfo = {
|
||||||
|
version: '17',
|
||||||
|
vendor: 'Eclipse Temurin',
|
||||||
|
id: 'temurin_17',
|
||||||
|
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
||||||
|
};
|
||||||
|
|
||||||
|
const originalFile = `<toolchains>
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>1.6</version>
|
||||||
|
<vendor>Sun</vendor>
|
||||||
|
<id>sun_1.6</id>
|
||||||
|
<custom>foo</custom>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/jdk/sun/1.6</jdkHome>
|
||||||
|
<fooHome>/usr/local/bin/bash</fooHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
const result = `<?xml version="1.0"?>
|
||||||
|
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>17</version>
|
||||||
|
<vendor>Eclipse Temurin</vendor>
|
||||||
|
<id>temurin_17</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>1.6</version>
|
||||||
|
<vendor>Sun</vendor>
|
||||||
|
<id>sun_1.6</id>
|
||||||
|
<custom>foo</custom>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/jdk/sun/1.6</jdkHome>
|
||||||
|
<fooHome>/usr/local/bin/bash</fooHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
|
||||||
|
fs.mkdirSync(m2Dir, {recursive: true});
|
||||||
|
fs.writeFileSync(toolchainsFile, originalFile);
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
|
||||||
|
await toolchains.createToolchainsSettings({
|
||||||
|
jdkInfo,
|
||||||
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
expect(fs.readFileSync(toolchainsFile, 'utf-8')).toEqual(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
).toEqual(result);
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
it('does not discard existing, custom toolchain definitions', async () => {
|
||||||
|
const jdkInfo = {
|
||||||
|
version: '17',
|
||||||
|
vendor: 'Eclipse Temurin',
|
||||||
|
id: 'temurin_17',
|
||||||
|
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
||||||
|
};
|
||||||
|
|
||||||
|
const originalFile = `<toolchains>
|
||||||
|
<toolchain>
|
||||||
|
<type>foo</type>
|
||||||
|
<provides>
|
||||||
|
<custom>baz</custom>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<fooHome>/usr/local/bin/foo</fooHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
const result = `<?xml version="1.0"?>
|
||||||
|
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>17</version>
|
||||||
|
<vendor>Eclipse Temurin</vendor>
|
||||||
|
<id>temurin_17</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
<toolchain>
|
||||||
|
<type>foo</type>
|
||||||
|
<provides>
|
||||||
|
<custom>baz</custom>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<fooHome>/usr/local/bin/foo</fooHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
|
||||||
|
fs.mkdirSync(m2Dir, {recursive: true});
|
||||||
|
fs.writeFileSync(toolchainsFile, originalFile);
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
|
||||||
|
await toolchains.createToolchainsSettings({
|
||||||
|
jdkInfo,
|
||||||
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
expect(fs.readFileSync(toolchainsFile, 'utf-8')).toEqual(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
).toEqual(result);
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
it('does not duplicate existing toolchain definitions', async () => {
|
||||||
|
const jdkInfo = {
|
||||||
|
version: '17',
|
||||||
|
vendor: 'Eclipse Temurin',
|
||||||
|
id: 'temurin_17',
|
||||||
|
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
||||||
|
};
|
||||||
|
|
||||||
|
const originalFile = `<toolchains>
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>17</version>
|
||||||
|
<vendor>Eclipse Temurin</vendor>
|
||||||
|
<id>temurin_17</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
const result = `<?xml version="1.0"?>
|
||||||
|
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>17</version>
|
||||||
|
<vendor>Eclipse Temurin</vendor>
|
||||||
|
<id>temurin_17</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
|
||||||
|
fs.mkdirSync(m2Dir, {recursive: true});
|
||||||
|
fs.writeFileSync(toolchainsFile, originalFile);
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
|
||||||
|
await toolchains.createToolchainsSettings({
|
||||||
|
jdkInfo,
|
||||||
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
expect(fs.readFileSync(toolchainsFile, 'utf-8')).toEqual(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
).toEqual(result);
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
it('does not duplicate existing toolchain definitions if multiple exist', async () => {
|
||||||
|
const jdkInfo = {
|
||||||
|
version: '17',
|
||||||
|
vendor: 'Eclipse Temurin',
|
||||||
|
id: 'temurin_17',
|
||||||
|
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
||||||
|
};
|
||||||
|
|
||||||
|
const originalFile = `<toolchains>
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>1.6</version>
|
||||||
|
<vendor>Sun</vendor>
|
||||||
|
<id>sun_1.6</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/jdk/sun/1.6</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>17</version>
|
||||||
|
<vendor>Eclipse Temurin</vendor>
|
||||||
|
<id>temurin_17</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
const result = `<?xml version="1.0"?>
|
||||||
|
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>17</version>
|
||||||
|
<vendor>Eclipse Temurin</vendor>
|
||||||
|
<id>temurin_17</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>1.6</version>
|
||||||
|
<vendor>Sun</vendor>
|
||||||
|
<id>sun_1.6</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/jdk/sun/1.6</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
|
||||||
|
fs.mkdirSync(m2Dir, {recursive: true});
|
||||||
|
fs.writeFileSync(toolchainsFile, originalFile);
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
|
||||||
|
await toolchains.createToolchainsSettings({
|
||||||
|
jdkInfo,
|
||||||
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
expect(fs.readFileSync(toolchainsFile, 'utf-8')).toEqual(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
).toEqual(result);
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
it('handles an empty list of existing toolchains correctly', async () => {
|
||||||
|
const jdkInfo = {
|
||||||
|
version: '17',
|
||||||
|
vendor: 'Eclipse Temurin',
|
||||||
|
id: 'temurin_17',
|
||||||
|
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
||||||
|
};
|
||||||
|
|
||||||
|
const originalFile = `<toolchains>
|
||||||
|
</toolchains>`;
|
||||||
|
const result = `<?xml version="1.0"?>
|
||||||
|
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||||
|
<toolchain>
|
||||||
|
<type>jdk</type>
|
||||||
|
<provides>
|
||||||
|
<version>17</version>
|
||||||
|
<vendor>Eclipse Temurin</vendor>
|
||||||
|
<id>temurin_17</id>
|
||||||
|
</provides>
|
||||||
|
<configuration>
|
||||||
|
<jdkHome>/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64</jdkHome>
|
||||||
|
</configuration>
|
||||||
|
</toolchain>
|
||||||
|
</toolchains>`;
|
||||||
|
|
||||||
|
fs.mkdirSync(m2Dir, {recursive: true});
|
||||||
|
fs.writeFileSync(toolchainsFile, originalFile);
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
|
||||||
|
await toolchains.createToolchainsSettings({
|
||||||
|
jdkInfo,
|
||||||
|
settingsDirectory: m2Dir,
|
||||||
|
overwriteSettings: true
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||||
|
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||||
|
expect(fs.readFileSync(toolchainsFile, 'utf-8')).toEqual(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
);
|
||||||
|
expect(
|
||||||
|
toolchains.generateToolchainDefinition(
|
||||||
|
originalFile,
|
||||||
|
jdkInfo.version,
|
||||||
|
jdkInfo.vendor,
|
||||||
|
jdkInfo.id,
|
||||||
|
jdkInfo.jdkHome
|
||||||
|
)
|
||||||
|
).toEqual(result);
|
||||||
|
}, 100000);
|
||||||
|
|
||||||
|
it('handles an empty existing toolchains.xml correctly', async () => {
|
||||||
|
const jdkInfo = {
|
||||||
|
version: '17',
|
||||||
|
vendor: 'Eclipse Temurin',
|
||||||
|
id: 'temurin_17',
|
||||||
|
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
||||||
|
};
|
||||||
|
|
||||||
|
const originalFile = ``;
|
||||||
|
const result = `<?xml version="1.0"?>
|
||||||
|
<toolchains xmlns="http://maven.apache.org/TOOLCHAINS/1.1.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd">
|
||||||
<toolchain>
|
<toolchain>
|
||||||
<type>jdk</type>
|
<type>jdk</type>
|
||||||
<provides>
|
<provides>
|
||||||
|
|||||||
79
dist/setup/index.js
vendored
79
dist/setup/index.js
vendored
@ -125504,46 +125504,53 @@ function createToolchainsSettings({ jdkInfo, settingsDirectory, overwriteSetting
|
|||||||
exports.createToolchainsSettings = createToolchainsSettings;
|
exports.createToolchainsSettings = createToolchainsSettings;
|
||||||
// only exported for testing purposes
|
// only exported for testing purposes
|
||||||
function generateToolchainDefinition(original, version, vendor, id, jdkHome) {
|
function generateToolchainDefinition(original, version, vendor, id, jdkHome) {
|
||||||
let xmlObj;
|
let jsToolchains = [
|
||||||
|
{
|
||||||
|
type: 'jdk',
|
||||||
|
provides: {
|
||||||
|
version: `${version}`,
|
||||||
|
vendor: `${vendor}`,
|
||||||
|
id: `${id}`
|
||||||
|
},
|
||||||
|
configuration: {
|
||||||
|
jdkHome: `${jdkHome}`
|
||||||
|
}
|
||||||
|
}
|
||||||
|
];
|
||||||
if (original === null || original === void 0 ? void 0 : original.length) {
|
if (original === null || original === void 0 ? void 0 : original.length) {
|
||||||
xmlObj = (0, xmlbuilder2_1.create)(original)
|
// convert existing toolchains into TS native objects for better handling
|
||||||
|
// xmlbuilder2 will convert the document into a `{toolchains: { toolchain: [] | {} }}` structure
|
||||||
|
// instead of the desired `toolchains: [{}]` one or simply `[{}]`
|
||||||
|
const jsObj = (0, xmlbuilder2_1.create)(original)
|
||||||
.root()
|
.root()
|
||||||
.ele({
|
.toObject();
|
||||||
toolchain: {
|
if (jsObj.toolchains && jsObj.toolchains.toolchain) {
|
||||||
type: 'jdk',
|
// in case only a single child exists xmlbuilder2 will not create an array and using verbose = true equally doesn't work here
|
||||||
provides: {
|
// See https://oozcitak.github.io/xmlbuilder2/serialization.html#js-object-and-map-serializers for details
|
||||||
version: `${version}`,
|
if (Array.isArray(jsObj.toolchains.toolchain)) {
|
||||||
vendor: `${vendor}`,
|
jsToolchains.push(...jsObj.toolchains.toolchain);
|
||||||
id: `${id}`
|
|
||||||
},
|
|
||||||
configuration: {
|
|
||||||
jdkHome: `${jdkHome}`
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
else {
|
||||||
|
jsToolchains.push(jsObj.toolchains.toolchain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// remove potential duplicates based on type & id (which should be a unique combination);
|
||||||
|
// self.findIndex will only return the first occurrence, ensuring duplicates are skipped
|
||||||
|
jsToolchains = jsToolchains.filter((value, index, self) =>
|
||||||
|
// ensure non-jdk toolchains are kept in the results, we must not touch them because they belong to the user
|
||||||
|
value.type !== 'jdk' ||
|
||||||
|
index ===
|
||||||
|
self.findIndex(t => t.type === value.type && t.provides.id === value.provides.id));
|
||||||
}
|
}
|
||||||
else
|
// TODO: technically bad because we shouldn't re-create the toolchains root node (with possibly different schema values) if it already exists, however, just overriding the toolchain array with xmlbuilder2 is … uh non-trivial
|
||||||
xmlObj = (0, xmlbuilder2_1.create)({
|
return (0, xmlbuilder2_1.create)({
|
||||||
toolchains: {
|
toolchains: {
|
||||||
'@xmlns': 'http://maven.apache.org/TOOLCHAINS/1.1.0',
|
'@xmlns': 'http://maven.apache.org/TOOLCHAINS/1.1.0',
|
||||||
'@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
'@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
'@xsi:schemaLocation': 'http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd',
|
'@xsi:schemaLocation': 'http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd',
|
||||||
toolchain: [
|
toolchain: jsToolchains
|
||||||
{
|
}
|
||||||
type: 'jdk',
|
}).end({
|
||||||
provides: {
|
|
||||||
version: `${version}`,
|
|
||||||
vendor: `${vendor}`,
|
|
||||||
id: `${id}`
|
|
||||||
},
|
|
||||||
configuration: {
|
|
||||||
jdkHome: `${jdkHome}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return xmlObj.end({
|
|
||||||
format: 'xml',
|
format: 'xml',
|
||||||
wellFormed: false,
|
wellFormed: false,
|
||||||
headless: false,
|
headless: false,
|
||||||
|
|||||||
@ -84,47 +84,59 @@ export function generateToolchainDefinition(
|
|||||||
id: string,
|
id: string,
|
||||||
jdkHome: string
|
jdkHome: string
|
||||||
) {
|
) {
|
||||||
let xmlObj;
|
let jsToolchains: Toolchain[] = [
|
||||||
if (original?.length) {
|
{
|
||||||
xmlObj = xmlCreate(original)
|
type: 'jdk',
|
||||||
.root()
|
provides: {
|
||||||
.ele({
|
version: `${version}`,
|
||||||
toolchain: {
|
vendor: `${vendor}`,
|
||||||
type: 'jdk',
|
id: `${id}`
|
||||||
provides: {
|
},
|
||||||
version: `${version}`,
|
configuration: {
|
||||||
vendor: `${vendor}`,
|
jdkHome: `${jdkHome}`
|
||||||
id: `${id}`
|
|
||||||
},
|
|
||||||
configuration: {
|
|
||||||
jdkHome: `${jdkHome}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else
|
|
||||||
xmlObj = xmlCreate({
|
|
||||||
toolchains: {
|
|
||||||
'@xmlns': 'http://maven.apache.org/TOOLCHAINS/1.1.0',
|
|
||||||
'@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
|
||||||
'@xsi:schemaLocation':
|
|
||||||
'http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd',
|
|
||||||
toolchain: [
|
|
||||||
{
|
|
||||||
type: 'jdk',
|
|
||||||
provides: {
|
|
||||||
version: `${version}`,
|
|
||||||
vendor: `${vendor}`,
|
|
||||||
id: `${id}`
|
|
||||||
},
|
|
||||||
configuration: {
|
|
||||||
jdkHome: `${jdkHome}`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
|
];
|
||||||
|
if (original?.length) {
|
||||||
|
// convert existing toolchains into TS native objects for better handling
|
||||||
|
// xmlbuilder2 will convert the document into a `{toolchains: { toolchain: [] | {} }}` structure
|
||||||
|
// instead of the desired `toolchains: [{}]` one or simply `[{}]`
|
||||||
|
const jsObj = xmlCreate(original)
|
||||||
|
.root()
|
||||||
|
.toObject() as unknown as ExtractedToolchains;
|
||||||
|
if (jsObj.toolchains && jsObj.toolchains.toolchain) {
|
||||||
|
// in case only a single child exists xmlbuilder2 will not create an array and using verbose = true equally doesn't work here
|
||||||
|
// See https://oozcitak.github.io/xmlbuilder2/serialization.html#js-object-and-map-serializers for details
|
||||||
|
if (Array.isArray(jsObj.toolchains.toolchain)) {
|
||||||
|
jsToolchains.push(...jsObj.toolchains.toolchain);
|
||||||
|
} else {
|
||||||
|
jsToolchains.push(jsObj.toolchains.toolchain);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return xmlObj.end({
|
// remove potential duplicates based on type & id (which should be a unique combination);
|
||||||
|
// self.findIndex will only return the first occurrence, ensuring duplicates are skipped
|
||||||
|
jsToolchains = jsToolchains.filter(
|
||||||
|
(value, index, self) =>
|
||||||
|
// ensure non-jdk toolchains are kept in the results, we must not touch them because they belong to the user
|
||||||
|
value.type !== 'jdk' ||
|
||||||
|
index ===
|
||||||
|
self.findIndex(
|
||||||
|
t => t.type === value.type && t.provides.id === value.provides.id
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: technically bad because we shouldn't re-create the toolchains root node (with possibly different schema values) if it already exists, however, just overriding the toolchain array with xmlbuilder2 is … uh non-trivial
|
||||||
|
return xmlCreate({
|
||||||
|
toolchains: {
|
||||||
|
'@xmlns': 'http://maven.apache.org/TOOLCHAINS/1.1.0',
|
||||||
|
'@xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance',
|
||||||
|
'@xsi:schemaLocation':
|
||||||
|
'http://maven.apache.org/TOOLCHAINS/1.1.0 https://maven.apache.org/xsd/toolchains-1.1.0.xsd',
|
||||||
|
toolchain: jsToolchains
|
||||||
|
}
|
||||||
|
}).end({
|
||||||
format: 'xml',
|
format: 'xml',
|
||||||
wellFormed: false,
|
wellFormed: false,
|
||||||
headless: false,
|
headless: false,
|
||||||
@ -167,3 +179,22 @@ async function writeToolchainsFileToDisk(
|
|||||||
flag: 'w'
|
flag: 'w'
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface ExtractedToolchains {
|
||||||
|
toolchains: {
|
||||||
|
toolchain: Toolchain[] | Toolchain;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
// Toolchain type definition according to Maven Toolchains XSD 1.1.0
|
||||||
|
interface Toolchain {
|
||||||
|
type: string;
|
||||||
|
provides:
|
||||||
|
| {
|
||||||
|
version: string;
|
||||||
|
vendor: string;
|
||||||
|
id: string;
|
||||||
|
}
|
||||||
|
| any;
|
||||||
|
configuration: any;
|
||||||
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user