mirror of
https://github.com/actions/setup-java.git
synced 2026-11-21 11:53:05 +00:00
Compare commits
5 Commits
eb6157cd13
...
copilot/fi
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2c8eb88e69 | ||
|
|
32a69ae090 | ||
|
|
7a475d86d1 | ||
|
|
92f9362dd0 | ||
|
|
71cfe8e0ed |
33
.github/workflows/e2e-versions.yml
vendored
33
.github/workflows/e2e-versions.yml
vendored
@@ -37,7 +37,8 @@ jobs:
|
||||
'dragonwell',
|
||||
'sapmachine',
|
||||
'jetbrains',
|
||||
'kona'
|
||||
'kona',
|
||||
'liberica-nik'
|
||||
] # internally 'adopt-hotspot' is the same as 'adopt'
|
||||
version: ['21', '11', '17']
|
||||
exclude:
|
||||
@@ -64,6 +65,15 @@ jobs:
|
||||
- distribution: kona
|
||||
os: macos-latest
|
||||
version: 25
|
||||
- distribution: liberica-nik
|
||||
os: windows-latest
|
||||
version: 25
|
||||
- distribution: liberica-nik
|
||||
os: ubuntu-latest
|
||||
version: 25
|
||||
- distribution: liberica-nik
|
||||
os: macos-latest
|
||||
version: 25
|
||||
- distribution: oracle
|
||||
os: macos-15-intel
|
||||
version: 17
|
||||
@@ -450,6 +460,10 @@ jobs:
|
||||
java-package: jre+fx
|
||||
version: '11'
|
||||
os: ubuntu-latest
|
||||
- distribution: 'liberica-nik'
|
||||
java-package: jdk+fx
|
||||
version: '21'
|
||||
os: ubuntu-latest
|
||||
- distribution: 'corretto'
|
||||
java-package: jre
|
||||
version: '8'
|
||||
@@ -708,10 +722,12 @@ jobs:
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- name: Verify JAVA_HOME still points to Java 17
|
||||
env:
|
||||
JAVA_17_PATH: ${{ steps.setup-java-17.outputs.path }}
|
||||
run: |
|
||||
echo "JAVA_HOME=$JAVA_HOME"
|
||||
echo "Java 17 path=${{ steps.setup-java-17.outputs.path }}"
|
||||
if [ "$JAVA_HOME" != "${{ steps.setup-java-17.outputs.path }}" ]; then
|
||||
echo "Java 17 path=$JAVA_17_PATH"
|
||||
if [ "$JAVA_HOME" != "$JAVA_17_PATH" ]; then
|
||||
echo "JAVA_HOME should still point to Java 17"
|
||||
exit 1
|
||||
fi
|
||||
@@ -740,14 +756,17 @@ jobs:
|
||||
Write-Host "$envName=$JavaVersionPath"
|
||||
shell: pwsh
|
||||
- name: Verify Java 21 outputs are set
|
||||
env:
|
||||
JAVA21_PATH: ${{ steps.setup-java-21.outputs.path }}
|
||||
JAVA21_VERSION: ${{ steps.setup-java-21.outputs.version }}
|
||||
run: |
|
||||
echo "Java 21 path=${{ steps.setup-java-21.outputs.path }}"
|
||||
echo "Java 21 version=${{ steps.setup-java-21.outputs.version }}"
|
||||
if [ -z "${{ steps.setup-java-21.outputs.path }}" ]; then
|
||||
echo "Java 21 path=$JAVA21_PATH"
|
||||
echo "Java 21 version=$JAVA21_VERSION"
|
||||
if [ -z "$JAVA21_PATH" ]; then
|
||||
echo "Java 21 path output should be set"
|
||||
exit 1
|
||||
fi
|
||||
if [ -z "${{ steps.setup-java-21.outputs.version }}" ]; then
|
||||
if [ -z "$JAVA21_VERSION" ]; then
|
||||
echo "Java 21 version output should be set"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@@ -124,6 +124,7 @@ Currently, the following distributions are supported:
|
||||
| `adopt` or `adopt-hotspot` | [AdoptOpenJDK Hotspot](https://adoptopenjdk.net/) | [`adopt-hotspot` license](https://adoptopenjdk.net/about.html) |
|
||||
| `adopt-openj9` | [AdoptOpenJDK OpenJ9](https://adoptopenjdk.net/) | [`adopt-openj9` license](https://adoptopenjdk.net/about.html) |
|
||||
| `liberica` | [Liberica JDK](https://bell-sw.com/) | [`liberica` license](https://bell-sw.com/liberica_eula/) |
|
||||
| `liberica-nik` | [Liberica Native Image Kit](https://bell-sw.com/pages/downloads/native-image-kit/) | [`liberica-nik` license](https://bell-sw.com/liberica_nik_eula/) |
|
||||
| `microsoft` | [Microsoft Build of OpenJDK](https://www.microsoft.com/openjdk) | [`microsoft` license](https://docs.microsoft.com/java/openjdk/faq)
|
||||
| `corretto` | [Amazon Corretto Build of OpenJDK](https://aws.amazon.com/corretto/) | [`corretto` license](https://aws.amazon.com/corretto/faqs/)
|
||||
| `semeru` | [IBM Semeru Runtime Open Edition](https://developer.ibm.com/languages/java/semeru-runtimes/downloads/) | [`semeru` license](https://openjdk.java.net/legal/gplv2+ce.html) |
|
||||
@@ -301,6 +302,7 @@ In the example above multiple JDKs are installed for the same job. The result af
|
||||
- [Adopt](docs/advanced-usage.md#Adopt)
|
||||
- [Zulu](docs/advanced-usage.md#Zulu)
|
||||
- [Liberica](docs/advanced-usage.md#Liberica)
|
||||
- [Liberica Native Image Kit](docs/advanced-usage.md#Liberica-Native-Image-Kit)
|
||||
- [Microsoft](docs/advanced-usage.md#Microsoft)
|
||||
- [Amazon Corretto](docs/advanced-usage.md#Amazon-Corretto)
|
||||
- [Oracle](docs/advanced-usage.md#Oracle)
|
||||
|
||||
739
__tests__/data/liberica-nik.json
Normal file
739
__tests__/data/liberica-nik.json
Normal file
@@ -0,0 +1,739 @@
|
||||
[
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.1+3-25.0.1+16/bellsoft-liberica-vm-openjdk25.0.1+16-25.0.1+3-linux-amd64.tar.gz",
|
||||
"version": "25.0.1+3",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.1+16",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.1.0+1-23+38/bellsoft-liberica-vm-openjdk23+38-24.1.0+1-linux-amd64.tar.gz",
|
||||
"version": "24.1.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "23+38",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.2/bellsoft-liberica-vm-openjdk11.0.15.1+2-21.3.2+2-linux-amd64.tar.gz",
|
||||
"version": "21.3.2+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.15.1+2",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.0/bellsoft-liberica-vm-openjdk17.0.5+8-22.3.0+2-linux-amd64.tar.gz",
|
||||
"version": "22.3.0+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.5+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.9+1-17.0.16+13/bellsoft-liberica-vm-openjdk17.0.16+13-23.0.9+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.9+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.16+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.0/bellsoft-liberica-vm-openjdk17.0.7+7-23.0.0+1-src.tar.gz",
|
||||
"version": "23.0.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.7+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.2+1-25.0.2+13/bellsoft-liberica-vm-openjdk25.0.2+13-25.0.2+1-linux-amd64.tar.gz",
|
||||
"version": "25.0.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.2+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.1.1+1-23.0.1+13/bellsoft-liberica-vm-openjdk23.0.1+13-24.1.1+1-linux-amd64.tar.gz",
|
||||
"version": "24.1.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "23.0.1+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.12+1-17.0.19+12/bellsoft-liberica-vm-openjdk17.0.19+12-23.0.12+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.12+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.19+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.3+1-17.0.10+13/bellsoft-liberica-vm-openjdk17.0.10+13-23.0.3+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.10+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.2/bellsoft-liberica-vm-openjdk11-21.3.2-src.tar.gz",
|
||||
"version": "21.3.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.15+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.3/bellsoft-liberica-vm-openjdk11.0.20+8-22.3.3+1-src.tar.gz",
|
||||
"version": "22.3.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.20+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.8+1-17.0.15+10/bellsoft-liberica-vm-openjdk17.0.15+10-23.0.8+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.8+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.15+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3/bellsoft-liberica-vm-openjdk17.0.4-21.3.3-src.tar.gz",
|
||||
"version": "21.3.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.4+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.7+1-21.0.7+9/bellsoft-liberica-vm-openjdk21.0.7+9-23.1.7+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.7+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.7+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.8+1-21.0.8+13/bellsoft-liberica-vm-openjdk21.0.8+13-23.1.8+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.8+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.8+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.0.0.2/bellsoft-liberica-vm-openjdk11-21.0.0.2-src.tar.gz",
|
||||
"version": "21.0.0.2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.10+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.1/bellsoft-liberica-vm-openjdk17.0.8+7-23.0.1+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.8+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.0.0+1-22+37/bellsoft-liberica-vm-openjdk22+37-24.0.0+1-linux-amd64.tar.gz",
|
||||
"version": "24.0.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "22+37",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.1.0/bellsoft-liberica-vm-openjdk17-22.1.0-src.tar.gz",
|
||||
"version": "22.1.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.3+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.0.2+1-22.0.2+11/bellsoft-liberica-vm-openjdk22.0.2+11-24.0.2+1-linux-amd64.tar.gz",
|
||||
"version": "24.0.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "22.0.2+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.1/bellsoft-liberica-vm-openjdk20.0.2+10-23.0.1+1-src.tar.gz",
|
||||
"version": "23.0.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "20.0.2+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.1.0/bellsoft-liberica-vm-openjdk21+37-23.1.0+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21+37",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.4+3-21.0.4+9/bellsoft-liberica-vm-openjdk21.0.4+9-23.1.4+3-linux-amd64.tar.gz",
|
||||
"version": "23.1.4+3",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.4+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.3/bellsoft-liberica-vm-openjdk11.0.20.1+1-22.3.3+2-linux-amd64.tar.gz",
|
||||
"version": "22.3.3+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.20.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.4+1-17.0.11+10/bellsoft-liberica-vm-openjdk17.0.11+10-23.0.4+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.4+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.11+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.1.2+1-23.0.2+9/bellsoft-liberica-vm-openjdk23.0.2+9-24.1.2+1-linux-amd64.tar.gz",
|
||||
"version": "24.1.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "23.0.2+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.10+1-17.0.17+12/bellsoft-liberica-vm-openjdk17.0.17+12-23.0.10+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.10+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.17+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.1/bellsoft-liberica-vm-openjdk11.0.18+10-22.3.1+1-src.tar.gz",
|
||||
"version": "22.3.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.18+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.0.0.2/bellsoft-liberica-vm-openjdk17-22.0.0.2-src.tar.gz",
|
||||
"version": "22.0.0.2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.2+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.0.0.2/bellsoft-liberica-vm-openjdk11-22.0.0.2-linux-amd64.tar.gz",
|
||||
"version": "22.0.0.2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.14.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.1+2-25.0.1+14/bellsoft-liberica-vm-openjdk25.0.1+14-25.0.1+2-linux-amd64.tar.gz",
|
||||
"version": "25.0.1+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.1+14",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3/bellsoft-liberica-vm-openjdk11.0.16-21.3.3-src.tar.gz",
|
||||
"version": "21.3.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.16+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.5+1-21.0.5+11/bellsoft-liberica-vm-openjdk21.0.5+11-23.1.5+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.5+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.5+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.4/bellsoft-liberica-vm-openjdk17.0.9+11-22.3.4+1-linux-amd64.tar.gz",
|
||||
"version": "22.3.4+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.9+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.0+1-25+37/bellsoft-liberica-vm-openjdk25+37-25.0.0+1-linux-amd64.tar.gz",
|
||||
"version": "25.0.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25+37",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.3/bellsoft-liberica-vm-openjdk17.0.8.1+1-22.3.3+2-linux-amd64.tar.gz",
|
||||
"version": "22.3.3+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.8.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.3+1-21.0.3+10/bellsoft-liberica-vm-openjdk21.0.3+10-23.1.3+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.3+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.3+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.2.0+1-24+37/bellsoft-liberica-vm-openjdk24+37-24.2.0+1-linux-amd64.tar.gz",
|
||||
"version": "24.2.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "24+37",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.1.1/bellsoft-liberica-vm-openjdk21.0.1+12-23.1.1+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.1+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3/bellsoft-liberica-vm-openjdk17.0.4.1-21.3.3-src.tar.gz",
|
||||
"version": "21.3.3+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.4.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.11+2-21.0.11+12/bellsoft-liberica-vm-openjdk21.0.11+12-23.1.11+2-linux-amd64.tar.gz",
|
||||
"version": "23.1.11+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.11+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.2/bellsoft-liberica-vm-openjdk11.0.19+7-22.3.2+1-src.tar.gz",
|
||||
"version": "22.3.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.19+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.4/bellsoft-liberica-vm-openjdk11.0.21+10-22.3.4+1-src.tar.gz",
|
||||
"version": "22.3.4+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.21+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.3+2-25.0.3+12/bellsoft-liberica-vm-openjdk25.0.3+12-25.0.3+2-linux-amd64.tar.gz",
|
||||
"version": "25.0.3+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.3+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.2/bellsoft-liberica-vm-openjdk17.0.3.1+2-21.3.2+2-linux-amd64.tar.gz",
|
||||
"version": "21.3.2+2",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.3.1+2",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.2.1+1-24.0.1+11/bellsoft-liberica-vm-openjdk24.0.1+11-24.2.1+1-linux-amd64.tar.gz",
|
||||
"version": "24.2.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "24.0.1+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.2.0/bellsoft-liberica-vm-openjdk11.0.16.1+1-22.2.0+3-linux-amd64.tar.gz",
|
||||
"version": "22.2.0+3",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.16.1+1",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.6+1-17.0.13+12/bellsoft-liberica-vm-openjdk17.0.13+12-23.0.6+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.6+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.13+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/23.0.0/bellsoft-liberica-vm-openjdk20.0.1+10-23.0.0+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.0+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "20.0.1+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.10+1-21.0.10+11/bellsoft-liberica-vm-openjdk21.0.10+11-23.1.10+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.10+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.10+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/22.3.1/bellsoft-liberica-vm-openjdk17.0.6+10-22.3.1+1-src.tar.gz",
|
||||
"version": "22.3.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.6+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.0/bellsoft-liberica-vm-openjdk17-21.3.0-src.tar.gz",
|
||||
"version": "21.3.0",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.1+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.0/bellsoft-liberica-vm-openjdk11-21.3.0-src.tar.gz",
|
||||
"version": "21.3.0",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.13+8",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.0.1+1-22.0.1+10/bellsoft-liberica-vm-openjdk22.0.1+10-24.0.1+1-linux-amd64.tar.gz",
|
||||
"version": "24.0.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "22.0.1+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.7+1-17.0.14+10/bellsoft-liberica-vm-openjdk17.0.14+10-23.0.7+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.7+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.14+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.1.0/bellsoft-liberica-vm-openjdk11-21.1.0-src.tar.gz",
|
||||
"version": "21.1.0",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.11+9",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.6+1-21.0.6+10/bellsoft-liberica-vm-openjdk21.0.6+10-23.1.6+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.6+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.6+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/25.0.1+1-25.0.1+12/bellsoft-liberica-vm-openjdk25.0.1+12-25.0.1+1-linux-amd64.tar.gz",
|
||||
"version": "25.0.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "25.0.1+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.9+1-21.0.9+12/bellsoft-liberica-vm-openjdk21.0.9+12-23.1.9+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.9+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.9+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/22.3.5+1-11.0.22+12/bellsoft-liberica-vm-openjdk11.0.22+12-22.3.5+1-linux-amd64.tar.gz",
|
||||
"version": "22.3.5+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.22+12",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.5+1-17.0.12+10/bellsoft-liberica-vm-openjdk17.0.12+10-23.0.5+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.5+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.12+10",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.3.3.1/bellsoft-liberica-vm-openjdk11.0.17+7-21.3.3.1+1-linux-amd64.tar.gz",
|
||||
"version": "21.3.3.1+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.17+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://download.bell-sw.com/vm/21.2.0/bellsoft-liberica-vm-openjdk11-21.2.0-linux-amd64.tar.gz",
|
||||
"version": "21.2.0",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "11.0.12+7",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.0.11+1-17.0.18+11/bellsoft-liberica-vm-openjdk17.0.18+11-23.0.11+1-linux-amd64.tar.gz",
|
||||
"version": "23.0.11+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "17.0.18+11",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/23.1.2+1-21.0.2+14/bellsoft-liberica-vm-openjdk21.0.2+14-23.1.2+1-linux-amd64.tar.gz",
|
||||
"version": "23.1.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "21.0.2+14",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"downloadUrl": "https://github.com/bell-sw/LibericaNIK/releases/download/24.2.2+1-24.0.2+13/bellsoft-liberica-vm-openjdk24.0.2+13-24.2.2+1-linux-amd64.tar.gz",
|
||||
"version": "24.2.2+1",
|
||||
"components": [
|
||||
{
|
||||
"component": "liberica",
|
||||
"version": "24.0.2+13",
|
||||
"embedded": true
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
219
__tests__/distributors/liberica-nik-installer.test.ts
Normal file
219
__tests__/distributors/liberica-nik-installer.test.ts
Normal file
@@ -0,0 +1,219 @@
|
||||
import {jest, describe, it, expect, beforeEach, afterEach} from '@jest/globals';
|
||||
import type {
|
||||
ArchitectureOptions,
|
||||
NikVersion
|
||||
} from '../../src/distributions/liberica-nik/models.js';
|
||||
import {HttpClient} from '@actions/http-client';
|
||||
|
||||
import manifestData from '../data/liberica-nik.json' with {type: 'json'};
|
||||
|
||||
// Mock @actions/core before importing source modules that depend on it
|
||||
jest.unstable_mockModule('@actions/core', () => ({
|
||||
info: jest.fn(),
|
||||
warning: jest.fn(),
|
||||
debug: jest.fn(),
|
||||
error: jest.fn(),
|
||||
notice: jest.fn(),
|
||||
setFailed: jest.fn(),
|
||||
setOutput: jest.fn(),
|
||||
getInput: jest.fn(),
|
||||
getBooleanInput: jest.fn(),
|
||||
getMultilineInput: jest.fn(),
|
||||
addPath: jest.fn(),
|
||||
exportVariable: jest.fn(),
|
||||
saveState: jest.fn(),
|
||||
getState: jest.fn(),
|
||||
setSecret: jest.fn(),
|
||||
isDebug: jest.fn(() => false),
|
||||
startGroup: jest.fn(),
|
||||
endGroup: jest.fn(),
|
||||
group: jest.fn((_name: string, fn: () => Promise<unknown>) => fn()),
|
||||
toPlatformPath: jest.fn((p: string) => p),
|
||||
toWin32Path: jest.fn((p: string) => p),
|
||||
toPosixPath: jest.fn((p: string) => p)
|
||||
}));
|
||||
|
||||
// Dynamic imports after mocking
|
||||
const {LibericaNikDistributions} =
|
||||
await import('../../src/distributions/liberica-nik/installer.js');
|
||||
|
||||
const ADDITIONAL_PARAMS =
|
||||
'&installation-type=archive&fields=downloadUrl%2Cversion%2Ccomponents%2Ccomponent%2Cembedded';
|
||||
|
||||
describe('getAvailableVersions', () => {
|
||||
let spyHttpClient: any;
|
||||
|
||||
beforeEach(() => {
|
||||
spyHttpClient = jest.spyOn(HttpClient.prototype, 'getJson');
|
||||
spyHttpClient.mockReturnValue({
|
||||
statusCode: 200,
|
||||
headers: {},
|
||||
result: manifestData as NikVersion[]
|
||||
});
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
jest.resetAllMocks();
|
||||
jest.clearAllMocks();
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
|
||||
it.each([
|
||||
[
|
||||
{version: '21', architecture: 'x64', packageType: 'jdk'},
|
||||
'bundle-type=standard&bitness=64&arch=x86&build-type=all'
|
||||
],
|
||||
[
|
||||
{version: '21-ea', architecture: 'x64', packageType: 'jdk'},
|
||||
'bundle-type=standard&bitness=64&arch=x86&build-type=ea'
|
||||
],
|
||||
[
|
||||
{version: '21', architecture: 'aarch64', packageType: 'jdk'},
|
||||
'bundle-type=standard&bitness=64&arch=arm&build-type=all'
|
||||
],
|
||||
[
|
||||
{version: '21', architecture: 'x64', packageType: 'jdk+fx'},
|
||||
'bundle-type=full&bitness=64&arch=x86&build-type=all'
|
||||
]
|
||||
])('build correct url for %s -> %s', async (input, urlParams) => {
|
||||
const distribution = new LibericaNikDistributions({
|
||||
...input,
|
||||
checkLatest: false
|
||||
});
|
||||
distribution['getPlatformOption'] = () => 'linux';
|
||||
const buildUrl = `https://api.bell-sw.com/v1/nik/releases?os=linux&${urlParams}${ADDITIONAL_PARAMS}`;
|
||||
|
||||
await distribution['getAvailableVersions']();
|
||||
|
||||
expect(spyHttpClient.mock.calls).toHaveLength(1);
|
||||
expect(spyHttpClient.mock.calls[0][0]).toBe(buildUrl);
|
||||
});
|
||||
|
||||
it('load available versions', async () => {
|
||||
const distribution = new LibericaNikDistributions({
|
||||
version: '21',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
const availableVersions = await distribution['getAvailableVersions']();
|
||||
expect(availableVersions).toEqual(manifestData);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getArchitectureOptions', () => {
|
||||
it.each([
|
||||
['x64', {bitness: '64', arch: 'x86'}],
|
||||
['aarch64', {bitness: '64', arch: 'arm'}]
|
||||
] as [string, ArchitectureOptions][])(
|
||||
'parse architecture %s -> %s',
|
||||
(input, expected) => {
|
||||
const distributions = new LibericaNikDistributions({
|
||||
architecture: input,
|
||||
checkLatest: false,
|
||||
packageType: 'jdk',
|
||||
version: '21'
|
||||
});
|
||||
|
||||
expect(distributions['getArchitectureOptions']()).toEqual(expected);
|
||||
}
|
||||
);
|
||||
|
||||
it.each(['x86', 'armv7', 's390x'])('not support architecture %s', input => {
|
||||
const distributions = new LibericaNikDistributions({
|
||||
architecture: input,
|
||||
checkLatest: false,
|
||||
packageType: 'jdk',
|
||||
version: '21'
|
||||
});
|
||||
|
||||
expect(() => distributions['getArchitectureOptions']()).toThrow(
|
||||
/Architecture '\w+' is not supported\. Supported architectures: .*/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('findPackageForDownload', () => {
|
||||
let distribution: InstanceType<typeof LibericaNikDistributions>;
|
||||
|
||||
beforeEach(() => {
|
||||
distribution = new LibericaNikDistributions({
|
||||
version: '',
|
||||
architecture: 'x64',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
distribution['getAvailableVersions'] = async () => manifestData;
|
||||
});
|
||||
|
||||
// The user's java-version resolves against the embedded JDK version, not
|
||||
// NIK's own GraalVM version.
|
||||
it.each([
|
||||
['21', '21.0.11+12'],
|
||||
['17', '17.0.19+12'],
|
||||
['25', '25.0.3+12'],
|
||||
['11', '11.0.22+12'],
|
||||
['21.0.2', '21.0.2+14'],
|
||||
['23', '23.0.2+9'],
|
||||
['20.x', '20.0.2+10'],
|
||||
['25.0.1', '25.0.1+16']
|
||||
])('version is %s -> %s', async (input, expected) => {
|
||||
const result = await distribution['findPackageForDownload'](input);
|
||||
expect(result.version).toBe(expected);
|
||||
});
|
||||
|
||||
it('should throw an error', async () => {
|
||||
await expect(distribution['findPackageForDownload']('7')).rejects.toThrow(
|
||||
/No matching version found for SemVer/
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getPlatformOption', () => {
|
||||
const distributions = new LibericaNikDistributions({
|
||||
architecture: 'x64',
|
||||
version: '21',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
it.each([
|
||||
['linux', 'linux'],
|
||||
['darwin', 'macos'],
|
||||
['win32', 'windows'],
|
||||
['cygwin', 'windows']
|
||||
])('os version %s -> %s', (input, expected) => {
|
||||
const actual = distributions['getPlatformOption'](input as NodeJS.Platform);
|
||||
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
|
||||
it.each(['sunos', 'aix', 'android', 'freebsd'])(
|
||||
'not support os version %s',
|
||||
input => {
|
||||
expect(() =>
|
||||
distributions['getPlatformOption'](input as NodeJS.Platform)
|
||||
).toThrow(/Platform '\w+' is not supported\. Supported platforms: .+/);
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
describe('convertVersionToSemver', () => {
|
||||
const distributions = new LibericaNikDistributions({
|
||||
architecture: 'x64',
|
||||
version: '21',
|
||||
packageType: 'jdk',
|
||||
checkLatest: false
|
||||
});
|
||||
|
||||
it.each([
|
||||
['25.0.1+16', '25.0.1+16'],
|
||||
['21+37', '21.0.0+37'],
|
||||
['23+38', '23.0.0+38'],
|
||||
['11.0.15.1+2', '11.0.15+1.2'],
|
||||
['17.0.5', '17.0.5']
|
||||
])('%s -> %s', (input, expected) => {
|
||||
const actual = distributions['convertVersionToSemver'](input);
|
||||
expect(actual).toEqual(expected);
|
||||
});
|
||||
});
|
||||
@@ -86,8 +86,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: altHome,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: altHome
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(false);
|
||||
@@ -135,8 +134,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -217,8 +215,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -303,8 +300,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -381,8 +377,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -452,8 +447,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -545,8 +539,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -605,8 +598,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -664,8 +656,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -748,8 +739,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -828,8 +818,7 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: true
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
@@ -854,7 +843,7 @@ describe('toolchains tests', () => {
|
||||
).toEqual(result);
|
||||
}, 100000);
|
||||
|
||||
it('does not overwrite existing toolchains.xml files', async () => {
|
||||
it('extends existing toolchains.xml files instead of overwriting them', async () => {
|
||||
const jdkInfo = {
|
||||
version: '17',
|
||||
vendor: 'Eclipse Temurin',
|
||||
@@ -883,13 +872,20 @@ describe('toolchains tests', () => {
|
||||
|
||||
await toolchains.createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory: m2Dir,
|
||||
overwriteSettings: false
|
||||
settingsDirectory: m2Dir
|
||||
});
|
||||
|
||||
expect(fs.existsSync(m2Dir)).toBe(true);
|
||||
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||
expect(fs.readFileSync(toolchainsFile, 'utf-8')).toEqual(originalFile);
|
||||
|
||||
const updated = fs.readFileSync(toolchainsFile, 'utf-8');
|
||||
// The pre-existing (Sun 1.6) toolchain must be preserved ...
|
||||
expect(updated).toContain('<id>sun_1.6</id>');
|
||||
expect(updated).toContain('<jdkHome>/opt/jdk/sun/1.6</jdkHome>');
|
||||
// ... and the newly installed JDK must be appended.
|
||||
expect(updated).toContain('<id>temurin_17</id>');
|
||||
expect(updated).toContain('<vendor>Eclipse Temurin</vendor>');
|
||||
expect(updated).toContain(`<jdkHome>${jdkInfo.jdkHome}</jdkHome>`);
|
||||
}, 100000);
|
||||
|
||||
it('generates valid toolchains.xml with minimal configuration', () => {
|
||||
@@ -959,4 +955,55 @@ describe('toolchains tests', () => {
|
||||
)
|
||||
);
|
||||
}, 100000);
|
||||
|
||||
it('preserves toolchains from previous executions across multiple setup-java runs', async () => {
|
||||
// Regression test for https://github.com/actions/setup-java/issues/1099
|
||||
// Running setup-java several times in the same job (e.g. multiple steps / multiple
|
||||
// java-version entries) must accumulate every JDK in toolchains.xml rather
|
||||
// than replacing previously registered entries.
|
||||
(core.getInput as jest.Mock<any>).mockImplementation((name: string) => {
|
||||
if (name === 'settings-path') return m2Dir;
|
||||
return '';
|
||||
});
|
||||
|
||||
const runs = [
|
||||
{
|
||||
version: '8',
|
||||
distributionName: 'temurin',
|
||||
id: 'temurin_8',
|
||||
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/8.0.1-12/x64'
|
||||
},
|
||||
{
|
||||
version: '11',
|
||||
distributionName: 'temurin',
|
||||
id: 'temurin_11',
|
||||
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/11.0.1-12/x64'
|
||||
},
|
||||
{
|
||||
version: '17',
|
||||
distributionName: 'temurin',
|
||||
id: 'temurin_17',
|
||||
jdkHome: '/opt/hostedtoolcache/Java_Temurin-Hotspot_jdk/17.0.1-12/x64'
|
||||
}
|
||||
];
|
||||
|
||||
for (const run of runs) {
|
||||
await toolchains.configureToolchains(
|
||||
run.version,
|
||||
run.distributionName,
|
||||
run.jdkHome,
|
||||
undefined
|
||||
);
|
||||
}
|
||||
|
||||
expect(fs.existsSync(toolchainsFile)).toBe(true);
|
||||
const contents = fs.readFileSync(toolchainsFile, 'utf-8');
|
||||
|
||||
for (const run of runs) {
|
||||
expect(contents).toContain(`<id>${run.id}</id>`);
|
||||
expect(contents).toContain(`<jdkHome>${run.jdkHome}</jdkHome>`);
|
||||
}
|
||||
// Exactly one <toolchain> entry per run – no duplicates, none dropped.
|
||||
expect((contents.match(/<toolchain>/g) || []).length).toBe(runs.length);
|
||||
}, 100000);
|
||||
});
|
||||
|
||||
164
dist/setup/index.js
vendored
164
dist/setup/index.js
vendored
@@ -38608,7 +38608,7 @@ let h2ExperimentalWarned = false
|
||||
/** @type {import('http2')} */
|
||||
let http2
|
||||
try {
|
||||
http2 = __nccwpck_require__(4848)
|
||||
http2 = __nccwpck_require__(2467)
|
||||
} catch {
|
||||
// @ts-ignore
|
||||
http2 = { constants: {} }
|
||||
@@ -64403,7 +64403,7 @@ module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:http");
|
||||
|
||||
/***/ }),
|
||||
|
||||
/***/ 4848:
|
||||
/***/ 2467:
|
||||
/***/ ((module) => {
|
||||
|
||||
module.exports = __WEBPACK_EXTERNAL_createRequire(import.meta.url)("node:http2");
|
||||
@@ -127351,13 +127351,11 @@ async function write(directory, settings, overwriteSettings) {
|
||||
|
||||
|
||||
|
||||
|
||||
async function configureToolchains(version, distributionName, jdkHome, toolchainId) {
|
||||
const vendor = getInput(INPUT_MVN_TOOLCHAIN_VENDOR) || distributionName;
|
||||
const id = toolchainId || `${vendor}_${version}`;
|
||||
const settingsDirectory = getInput(INPUT_SETTINGS_PATH) ||
|
||||
external_path_.join(external_os_.homedir(), M2_DIR);
|
||||
const overwriteSettings = util_getBooleanInput(INPUT_OVERWRITE_SETTINGS, true);
|
||||
await createToolchainsSettings({
|
||||
jdkInfo: {
|
||||
version,
|
||||
@@ -127365,18 +127363,17 @@ async function configureToolchains(version, distributionName, jdkHome, toolchain
|
||||
id,
|
||||
jdkHome
|
||||
},
|
||||
settingsDirectory,
|
||||
overwriteSettings
|
||||
settingsDirectory
|
||||
});
|
||||
}
|
||||
async function createToolchainsSettings({ jdkInfo, settingsDirectory, overwriteSettings }) {
|
||||
async function createToolchainsSettings({ jdkInfo, settingsDirectory }) {
|
||||
info(`Creating ${MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`);
|
||||
// when an alternate m2 location is specified use only that location (no .m2 directory)
|
||||
// otherwise use the home/.m2/ path
|
||||
await mkdirP(settingsDirectory);
|
||||
const originalToolchains = await readExistingToolchainsFile(settingsDirectory);
|
||||
const updatedToolchains = generateToolchainDefinition(originalToolchains, jdkInfo.version, jdkInfo.vendor, jdkInfo.id, jdkInfo.jdkHome);
|
||||
await writeToolchainsFileToDisk(settingsDirectory, updatedToolchains, overwriteSettings);
|
||||
await writeToolchainsFileToDisk(settingsDirectory, updatedToolchains);
|
||||
}
|
||||
// only exported for testing purposes
|
||||
function generateToolchainDefinition(original, version, vendor, id, jdkHome) {
|
||||
@@ -127458,18 +127455,20 @@ async function readExistingToolchainsFile(directory) {
|
||||
}
|
||||
return '';
|
||||
}
|
||||
async function writeToolchainsFileToDisk(directory, settings, overwriteSettings) {
|
||||
async function writeToolchainsFileToDisk(directory, settings) {
|
||||
const location = external_path_.join(directory, MVN_TOOLCHAINS_FILE);
|
||||
const settingsExists = external_fs_namespaceObject.existsSync(location);
|
||||
if (settingsExists && overwriteSettings) {
|
||||
info(`Overwriting existing file ${location}`);
|
||||
}
|
||||
else if (!settingsExists) {
|
||||
info(`Writing to ${location}`);
|
||||
// The toolchains file is produced by a non-destructive merge (existing JDK,
|
||||
// custom, and non-jdk toolchains are preserved – see generateToolchainDefinition),
|
||||
// so it is always safe to write it. Unlike settings.xml, it is therefore not
|
||||
// gated behind the `overwrite-settings` input; that would prevent subsequent
|
||||
// setup-java runs from registering additional JDKs and silently drop the
|
||||
// toolchain entries created by earlier runs.
|
||||
if (settingsExists) {
|
||||
info(`Updating existing file ${location}`);
|
||||
}
|
||||
else {
|
||||
info(`Skipping generation of ${location} because file already exists and overwriting is not enabled`);
|
||||
return;
|
||||
info(`Writing to ${location}`);
|
||||
}
|
||||
return external_fs_namespaceObject.writeFileSync(location, settings, {
|
||||
encoding: 'utf-8',
|
||||
@@ -132094,6 +132093,129 @@ class LibericaDistributions extends JavaBase {
|
||||
}
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./src/distributions/liberica-nik/installer.ts
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const installer_supportedPlatform = `'linux', 'macos', 'windows'`;
|
||||
const installer_supportedArchitectures = `'x64', 'aarch64'`;
|
||||
class LibericaNikDistributions extends JavaBase {
|
||||
constructor(installerOptions) {
|
||||
super('Liberica_NIK', installerOptions);
|
||||
}
|
||||
async downloadTool(javaRelease) {
|
||||
info(`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`);
|
||||
let javaArchivePath = await downloadTool(javaRelease.url);
|
||||
info(`Extracting Java archive...`);
|
||||
const extension = getDownloadArchiveExtension();
|
||||
if (process.platform === 'win32') {
|
||||
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||
}
|
||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||
const archiveName = external_fs_default().readdirSync(extractedJavaPath)[0];
|
||||
const archivePath = external_path_default().join(extractedJavaPath, archiveName);
|
||||
const javaPath = await cacheDir(archivePath, this.toolcacheFolderName, this.getToolcacheVersionName(javaRelease.version), this.architecture);
|
||||
return { version: javaRelease.version, path: javaPath };
|
||||
}
|
||||
async findPackageForDownload(range) {
|
||||
const availableVersionsRaw = await this.getAvailableVersions();
|
||||
const availableVersions = availableVersionsRaw
|
||||
.map(item => {
|
||||
const jdkVersion = this.getJdkVersion(item);
|
||||
return jdkVersion ? { url: item.downloadUrl, version: jdkVersion } : null;
|
||||
})
|
||||
.filter((item) => item !== null);
|
||||
const satisfiedVersion = availableVersions
|
||||
.filter(item => isVersionSatisfies(range, item.version))
|
||||
.sort((a, b) => -semver_default().compareBuild(a.version, b.version))[0];
|
||||
if (!satisfiedVersion) {
|
||||
const availableVersionStrings = availableVersions.map(item => item.version);
|
||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
||||
}
|
||||
return satisfiedVersion;
|
||||
}
|
||||
async getAvailableVersions() {
|
||||
if (isDebug()) {
|
||||
console.time('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
||||
}
|
||||
const url = this.prepareAvailableVersionsUrl();
|
||||
core_debug(`Gathering available versions from '${url}'`);
|
||||
const availableVersions = (await this.http.getJson(url)).result ?? [];
|
||||
if (isDebug()) {
|
||||
startGroup('Print information about available versions');
|
||||
console.timeEnd('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
||||
core_debug(`Available versions: [${availableVersions.length}]`);
|
||||
core_debug(availableVersions.map(item => item.version).join(', '));
|
||||
endGroup();
|
||||
}
|
||||
return availableVersions;
|
||||
}
|
||||
prepareAvailableVersionsUrl() {
|
||||
const urlOptions = {
|
||||
os: this.getPlatformOption(),
|
||||
'bundle-type': this.getBundleType(),
|
||||
...this.getArchitectureOptions(),
|
||||
'build-type': this.stable ? 'all' : 'ea',
|
||||
'installation-type': 'archive',
|
||||
fields: 'downloadUrl,version,components,component,embedded'
|
||||
};
|
||||
const searchParams = new URLSearchParams(urlOptions).toString();
|
||||
return `https://api.bell-sw.com/v1/nik/releases?${searchParams}`;
|
||||
}
|
||||
// NIK's top-level `version` is the GraalVM/NIK version; the JDK version that
|
||||
// users select on lives in the embedded `liberica` component.
|
||||
getJdkVersion(release) {
|
||||
const liberica = release.components?.find(component => component.component === 'liberica');
|
||||
return liberica ? this.convertVersionToSemver(liberica.version) : null;
|
||||
}
|
||||
// The `full` bundle adds JavaFX/Swing GUI support; otherwise use `standard`.
|
||||
getBundleType() {
|
||||
const [, feature] = this.packageType.split('+');
|
||||
return feature?.includes('fx') ? 'full' : 'standard';
|
||||
}
|
||||
getArchitectureOptions() {
|
||||
const arch = this.distributionArchitecture();
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
return { bitness: '64', arch: 'x86' };
|
||||
case 'aarch64':
|
||||
return { bitness: '64', arch: 'arm' };
|
||||
default:
|
||||
throw new Error(`Architecture '${this.architecture}' is not supported. Supported architectures: ${installer_supportedArchitectures}`);
|
||||
}
|
||||
}
|
||||
getPlatformOption(platform = process.platform) {
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return 'macos';
|
||||
case 'win32':
|
||||
case 'cygwin':
|
||||
return 'windows';
|
||||
case 'linux':
|
||||
return 'linux';
|
||||
default:
|
||||
throw new Error(`Platform '${platform}' is not supported. Supported platforms: ${installer_supportedPlatform}`);
|
||||
}
|
||||
}
|
||||
// JDK versions come as strings like '25.0.1+16', '23+38' or '11.0.15.1+2'.
|
||||
// Normalize them to valid SemVer while preserving build metadata so newer
|
||||
// NIK builds of the same JDK sort ahead of older ones.
|
||||
convertVersionToSemver(jdkVersion) {
|
||||
const [main, build] = jdkVersion.split('+');
|
||||
const parts = main.split('.');
|
||||
while (parts.length < 3) {
|
||||
parts.push('0');
|
||||
}
|
||||
const base = parts.slice(0, 3).join('.');
|
||||
const buildMeta = [...parts.slice(3), ...(build ? [build] : [])];
|
||||
return buildMeta.length ? `${base}+${buildMeta.join('.')}` : base;
|
||||
}
|
||||
}
|
||||
|
||||
;// CONCATENATED MODULE: ./src/distributions/microsoft/microsoft-key.ts
|
||||
// Microsoft Build of OpenJDK GPG signing key
|
||||
// Retrieved from: https://download.visualstudio.microsoft.com/download/pr/b90071e2-e0cf-4411-98be-dbeb09d67bf0/8622862bcd54206e158c5abca0582c9b/464279_464280_aoc_20210208.asc
|
||||
@@ -132234,7 +132356,7 @@ class MicrosoftDistributions extends JavaBase {
|
||||
|
||||
|
||||
|
||||
const installer_supportedArchitectures = [
|
||||
const semeru_installer_supportedArchitectures = [
|
||||
'x64',
|
||||
'x86',
|
||||
'ppc64le',
|
||||
@@ -132248,8 +132370,8 @@ class SemeruDistribution extends JavaBase {
|
||||
}
|
||||
async findPackageForDownload(version) {
|
||||
const arch = this.distributionArchitecture();
|
||||
if (!installer_supportedArchitectures.includes(arch)) {
|
||||
throw new Error(`Unsupported architecture for IBM Semeru: ${this.architecture} for your current OS version, the following are supported: ${installer_supportedArchitectures.join(', ')}`);
|
||||
if (!semeru_installer_supportedArchitectures.includes(arch)) {
|
||||
throw new Error(`Unsupported architecture for IBM Semeru: ${this.architecture} for your current OS version, the following are supported: ${semeru_installer_supportedArchitectures.join(', ')}`);
|
||||
}
|
||||
if (!this.stable) {
|
||||
throw new Error('IBM Semeru does not provide builds for early access versions');
|
||||
@@ -133539,6 +133661,7 @@ class KonaDistribution extends JavaBase {
|
||||
|
||||
|
||||
|
||||
|
||||
var JavaDistribution;
|
||||
(function (JavaDistribution) {
|
||||
JavaDistribution["Adopt"] = "adopt";
|
||||
@@ -133547,6 +133670,7 @@ var JavaDistribution;
|
||||
JavaDistribution["Temurin"] = "temurin";
|
||||
JavaDistribution["Zulu"] = "zulu";
|
||||
JavaDistribution["Liberica"] = "liberica";
|
||||
JavaDistribution["LibericaNik"] = "liberica-nik";
|
||||
JavaDistribution["JdkFile"] = "jdkfile";
|
||||
JavaDistribution["Microsoft"] = "microsoft";
|
||||
JavaDistribution["Semeru"] = "semeru";
|
||||
@@ -133574,6 +133698,8 @@ function getJavaDistribution(distributionName, installerOptions, jdkFile) {
|
||||
return new ZuluDistribution(installerOptions);
|
||||
case JavaDistribution.Liberica:
|
||||
return new LibericaDistributions(installerOptions);
|
||||
case JavaDistribution.LibericaNik:
|
||||
return new LibericaNikDistributions(installerOptions);
|
||||
case JavaDistribution.Microsoft:
|
||||
return new MicrosoftDistributions(installerOptions);
|
||||
case JavaDistribution.Semeru:
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
- [Adopt](#Adopt)
|
||||
- [Zulu](#Zulu)
|
||||
- [Liberica](#Liberica)
|
||||
- [Liberica Native Image Kit](#Liberica-Native-Image-Kit)
|
||||
- [Microsoft](#Microsoft)
|
||||
- [Amazon Corretto](#Amazon-Corretto)
|
||||
- [Oracle](#Oracle)
|
||||
@@ -85,6 +86,20 @@ steps:
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Liberica Native Image Kit
|
||||
Liberica Native Image Kit (NIK) is a GraalVM-based distribution. `java-version` selects the underlying JDK version (e.g. `17`, `21`, `25`). Use `java-package: jdk+fx` to get the `full` bundle with JavaFX/Swing support; otherwise the `standard` bundle (with extra languages) is installed. Available on Linux, macOS and Windows for `x64` and `aarch64`.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'liberica-nik'
|
||||
java-version: '25'
|
||||
java-package: jdk # optional (jdk or jdk+fx) - defaults to jdk
|
||||
- run: native-image --version
|
||||
```
|
||||
|
||||
### Microsoft
|
||||
|
||||
```yaml
|
||||
@@ -801,6 +816,8 @@ The `setup-java` action generates a basic [Maven Toolchains declaration](https:/
|
||||
### Installing Multiple JDKs With Toolchains
|
||||
Subsequent calls to `setup-java` with distinct distribution and version parameters will continue to extend the toolchains declaration and make all specified Java versions available.
|
||||
|
||||
Toolchain entries are always merged non-destructively: existing JDK, custom, and user-managed toolchains are preserved, and only an entry with the exact same `type` and `provides.id` is replaced. This behavior is independent of the `overwrite-settings` input, which only controls regeneration of `settings.xml`. As a result, running `setup-java` several times in the same job (for example in multiple steps or with multiple `java-version` values) accumulates every JDK in `toolchains.xml` instead of dropping previously registered entries.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/setup-java@v5
|
||||
|
||||
@@ -8,6 +8,7 @@ import {
|
||||
TemurinImplementation
|
||||
} from './temurin/installer.js';
|
||||
import {LibericaDistributions} from './liberica/installer.js';
|
||||
import {LibericaNikDistributions} from './liberica-nik/installer.js';
|
||||
import {MicrosoftDistributions} from './microsoft/installer.js';
|
||||
import {SemeruDistribution} from './semeru/installer.js';
|
||||
import {CorrettoDistribution} from './corretto/installer.js';
|
||||
@@ -28,6 +29,7 @@ enum JavaDistribution {
|
||||
Temurin = 'temurin',
|
||||
Zulu = 'zulu',
|
||||
Liberica = 'liberica',
|
||||
LibericaNik = 'liberica-nik',
|
||||
JdkFile = 'jdkfile',
|
||||
Microsoft = 'microsoft',
|
||||
Semeru = 'semeru',
|
||||
@@ -69,6 +71,8 @@ export function getJavaDistribution(
|
||||
return new ZuluDistribution(installerOptions);
|
||||
case JavaDistribution.Liberica:
|
||||
return new LibericaDistributions(installerOptions);
|
||||
case JavaDistribution.LibericaNik:
|
||||
return new LibericaNikDistributions(installerOptions);
|
||||
case JavaDistribution.Microsoft:
|
||||
return new MicrosoftDistributions(installerOptions);
|
||||
case JavaDistribution.Semeru:
|
||||
|
||||
180
src/distributions/liberica-nik/installer.ts
Normal file
180
src/distributions/liberica-nik/installer.ts
Normal file
@@ -0,0 +1,180 @@
|
||||
import {JavaBase} from '../base-installer.js';
|
||||
import {
|
||||
JavaDownloadRelease,
|
||||
JavaInstallerOptions,
|
||||
JavaInstallerResults
|
||||
} from '../base-models.js';
|
||||
import semver from 'semver';
|
||||
import {
|
||||
extractJdkFile,
|
||||
getDownloadArchiveExtension,
|
||||
isVersionSatisfies,
|
||||
renameWinArchive
|
||||
} from '../../util.js';
|
||||
import * as core from '@actions/core';
|
||||
import {ArchitectureOptions, NikVersion, OsVersions} from './models.js';
|
||||
import * as tc from '@actions/tool-cache';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const supportedPlatform = `'linux', 'macos', 'windows'`;
|
||||
|
||||
const supportedArchitectures = `'x64', 'aarch64'`;
|
||||
|
||||
export class LibericaNikDistributions extends JavaBase {
|
||||
constructor(installerOptions: JavaInstallerOptions) {
|
||||
super('Liberica_NIK', installerOptions);
|
||||
}
|
||||
|
||||
protected async downloadTool(
|
||||
javaRelease: JavaDownloadRelease
|
||||
): Promise<JavaInstallerResults> {
|
||||
core.info(
|
||||
`Downloading Java ${javaRelease.version} (${this.distribution}) from ${javaRelease.url} ...`
|
||||
);
|
||||
let javaArchivePath = await tc.downloadTool(javaRelease.url);
|
||||
|
||||
core.info(`Extracting Java archive...`);
|
||||
const extension = getDownloadArchiveExtension();
|
||||
if (process.platform === 'win32') {
|
||||
javaArchivePath = renameWinArchive(javaArchivePath);
|
||||
}
|
||||
const extractedJavaPath = await extractJdkFile(javaArchivePath, extension);
|
||||
|
||||
const archiveName = fs.readdirSync(extractedJavaPath)[0];
|
||||
const archivePath = path.join(extractedJavaPath, archiveName);
|
||||
|
||||
const javaPath = await tc.cacheDir(
|
||||
archivePath,
|
||||
this.toolcacheFolderName,
|
||||
this.getToolcacheVersionName(javaRelease.version),
|
||||
this.architecture
|
||||
);
|
||||
|
||||
return {version: javaRelease.version, path: javaPath};
|
||||
}
|
||||
|
||||
protected async findPackageForDownload(
|
||||
range: string
|
||||
): Promise<JavaDownloadRelease> {
|
||||
const availableVersionsRaw = await this.getAvailableVersions();
|
||||
|
||||
const availableVersions = availableVersionsRaw
|
||||
.map(item => {
|
||||
const jdkVersion = this.getJdkVersion(item);
|
||||
return jdkVersion ? {url: item.downloadUrl, version: jdkVersion} : null;
|
||||
})
|
||||
.filter((item): item is {url: string; version: string} => item !== null);
|
||||
|
||||
const satisfiedVersion = availableVersions
|
||||
.filter(item => isVersionSatisfies(range, item.version))
|
||||
.sort((a, b) => -semver.compareBuild(a.version, b.version))[0];
|
||||
|
||||
if (!satisfiedVersion) {
|
||||
const availableVersionStrings = availableVersions.map(
|
||||
item => item.version
|
||||
);
|
||||
throw this.createVersionNotFoundError(range, availableVersionStrings);
|
||||
}
|
||||
|
||||
return satisfiedVersion;
|
||||
}
|
||||
|
||||
private async getAvailableVersions(): Promise<NikVersion[]> {
|
||||
if (core.isDebug()) {
|
||||
console.time('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
||||
}
|
||||
const url = this.prepareAvailableVersionsUrl();
|
||||
|
||||
core.debug(`Gathering available versions from '${url}'`);
|
||||
|
||||
const availableVersions =
|
||||
(await this.http.getJson<NikVersion[]>(url)).result ?? [];
|
||||
|
||||
if (core.isDebug()) {
|
||||
core.startGroup('Print information about available versions');
|
||||
console.timeEnd('Retrieving available versions for Liberica NIK took'); // eslint-disable-line no-console
|
||||
core.debug(`Available versions: [${availableVersions.length}]`);
|
||||
core.debug(availableVersions.map(item => item.version).join(', '));
|
||||
core.endGroup();
|
||||
}
|
||||
|
||||
return availableVersions;
|
||||
}
|
||||
|
||||
private prepareAvailableVersionsUrl() {
|
||||
const urlOptions = {
|
||||
os: this.getPlatformOption(),
|
||||
'bundle-type': this.getBundleType(),
|
||||
...this.getArchitectureOptions(),
|
||||
'build-type': this.stable ? 'all' : 'ea',
|
||||
'installation-type': 'archive',
|
||||
fields: 'downloadUrl,version,components,component,embedded'
|
||||
};
|
||||
|
||||
const searchParams = new URLSearchParams(urlOptions).toString();
|
||||
|
||||
return `https://api.bell-sw.com/v1/nik/releases?${searchParams}`;
|
||||
}
|
||||
|
||||
// NIK's top-level `version` is the GraalVM/NIK version; the JDK version that
|
||||
// users select on lives in the embedded `liberica` component.
|
||||
private getJdkVersion(release: NikVersion): string | null {
|
||||
const liberica = release.components?.find(
|
||||
component => component.component === 'liberica'
|
||||
);
|
||||
return liberica ? this.convertVersionToSemver(liberica.version) : null;
|
||||
}
|
||||
|
||||
// The `full` bundle adds JavaFX/Swing GUI support; otherwise use `standard`.
|
||||
private getBundleType(): string {
|
||||
const [, feature] = this.packageType.split('+');
|
||||
return feature?.includes('fx') ? 'full' : 'standard';
|
||||
}
|
||||
|
||||
private getArchitectureOptions(): ArchitectureOptions {
|
||||
const arch = this.distributionArchitecture();
|
||||
switch (arch) {
|
||||
case 'x64':
|
||||
return {bitness: '64', arch: 'x86'};
|
||||
case 'aarch64':
|
||||
return {bitness: '64', arch: 'arm'};
|
||||
default:
|
||||
throw new Error(
|
||||
`Architecture '${this.architecture}' is not supported. Supported architectures: ${supportedArchitectures}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
private getPlatformOption(
|
||||
platform: NodeJS.Platform = process.platform
|
||||
): OsVersions {
|
||||
switch (platform) {
|
||||
case 'darwin':
|
||||
return 'macos';
|
||||
case 'win32':
|
||||
case 'cygwin':
|
||||
return 'windows';
|
||||
case 'linux':
|
||||
return 'linux';
|
||||
default:
|
||||
throw new Error(
|
||||
`Platform '${platform}' is not supported. Supported platforms: ${supportedPlatform}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// JDK versions come as strings like '25.0.1+16', '23+38' or '11.0.15.1+2'.
|
||||
// Normalize them to valid SemVer while preserving build metadata so newer
|
||||
// NIK builds of the same JDK sort ahead of older ones.
|
||||
private convertVersionToSemver(jdkVersion: string): string {
|
||||
const [main, build] = jdkVersion.split('+');
|
||||
const parts = main.split('.');
|
||||
while (parts.length < 3) {
|
||||
parts.push('0');
|
||||
}
|
||||
const base = parts.slice(0, 3).join('.');
|
||||
const buildMeta = [...parts.slice(3), ...(build ? [build] : [])];
|
||||
return buildMeta.length ? `${base}+${buildMeta.join('.')}` : base;
|
||||
}
|
||||
}
|
||||
26
src/distributions/liberica-nik/models.ts
Normal file
26
src/distributions/liberica-nik/models.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
// Models from https://api.bell-sw.com/api.html (NIK product)
|
||||
|
||||
export type Bitness = '32' | '64';
|
||||
export type ArchType = 'arm' | 'ppc' | 'sparc' | 'x86';
|
||||
|
||||
export type OsVersions = 'linux' | 'linux-musl' | 'macos' | 'windows';
|
||||
|
||||
export interface ArchitectureOptions {
|
||||
bitness: Bitness;
|
||||
arch: ArchType;
|
||||
}
|
||||
|
||||
export interface NikComponent {
|
||||
component: string;
|
||||
version: string;
|
||||
embedded?: boolean;
|
||||
}
|
||||
|
||||
export interface NikVersion {
|
||||
// The main Liberica NIK VM bundle download URL.
|
||||
downloadUrl: string;
|
||||
// NIK/GraalVM version (e.g. '24.1.0+1'), kept for logging only.
|
||||
version: string;
|
||||
// The embedded `liberica` component carries the actual JDK version.
|
||||
components: NikComponent[];
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import * as core from '@actions/core';
|
||||
import * as io from '@actions/io';
|
||||
import * as constants from './constants.js';
|
||||
|
||||
import {getBooleanInput} from './util.js';
|
||||
import {create as xmlCreate} from 'xmlbuilder2';
|
||||
|
||||
interface JdkInfo {
|
||||
@@ -27,10 +26,6 @@ export async function configureToolchains(
|
||||
const settingsDirectory =
|
||||
core.getInput(constants.INPUT_SETTINGS_PATH) ||
|
||||
path.join(os.homedir(), constants.M2_DIR);
|
||||
const overwriteSettings = getBooleanInput(
|
||||
constants.INPUT_OVERWRITE_SETTINGS,
|
||||
true
|
||||
);
|
||||
|
||||
await createToolchainsSettings({
|
||||
jdkInfo: {
|
||||
@@ -39,19 +34,16 @@ export async function configureToolchains(
|
||||
id,
|
||||
jdkHome
|
||||
},
|
||||
settingsDirectory,
|
||||
overwriteSettings
|
||||
settingsDirectory
|
||||
});
|
||||
}
|
||||
|
||||
export async function createToolchainsSettings({
|
||||
jdkInfo,
|
||||
settingsDirectory,
|
||||
overwriteSettings
|
||||
settingsDirectory
|
||||
}: {
|
||||
jdkInfo: JdkInfo;
|
||||
settingsDirectory: string;
|
||||
overwriteSettings: boolean;
|
||||
}) {
|
||||
core.info(
|
||||
`Creating ${constants.MVN_TOOLCHAINS_FILE} for JDK version ${jdkInfo.version} from ${jdkInfo.vendor}`
|
||||
@@ -68,11 +60,7 @@ export async function createToolchainsSettings({
|
||||
jdkInfo.id,
|
||||
jdkInfo.jdkHome
|
||||
);
|
||||
await writeToolchainsFileToDisk(
|
||||
settingsDirectory,
|
||||
updatedToolchains,
|
||||
overwriteSettings
|
||||
);
|
||||
await writeToolchainsFileToDisk(settingsDirectory, updatedToolchains);
|
||||
}
|
||||
|
||||
// only exported for testing purposes
|
||||
@@ -172,22 +160,19 @@ async function readExistingToolchainsFile(directory: string) {
|
||||
return '';
|
||||
}
|
||||
|
||||
async function writeToolchainsFileToDisk(
|
||||
directory: string,
|
||||
settings: string,
|
||||
overwriteSettings: boolean
|
||||
) {
|
||||
async function writeToolchainsFileToDisk(directory: string, settings: string) {
|
||||
const location = path.join(directory, constants.MVN_TOOLCHAINS_FILE);
|
||||
const settingsExists = fs.existsSync(location);
|
||||
if (settingsExists && overwriteSettings) {
|
||||
core.info(`Overwriting existing file ${location}`);
|
||||
} else if (!settingsExists) {
|
||||
core.info(`Writing to ${location}`);
|
||||
// The toolchains file is produced by a non-destructive merge (existing JDK,
|
||||
// custom, and non-jdk toolchains are preserved – see generateToolchainDefinition),
|
||||
// so it is always safe to write it. Unlike settings.xml, it is therefore not
|
||||
// gated behind the `overwrite-settings` input; that would prevent subsequent
|
||||
// setup-java runs from registering additional JDKs and silently drop the
|
||||
// toolchain entries created by earlier runs.
|
||||
if (settingsExists) {
|
||||
core.info(`Updating existing file ${location}`);
|
||||
} else {
|
||||
core.info(
|
||||
`Skipping generation of ${location} because file already exists and overwriting is not enabled`
|
||||
);
|
||||
return;
|
||||
core.info(`Writing to ${location}`);
|
||||
}
|
||||
|
||||
return fs.writeFileSync(location, settings, {
|
||||
|
||||
Reference in New Issue
Block a user