mirror of
https://github.com/actions/setup-java.git
synced 2026-06-23 00:09:42 +00:00
Merge branch 'main' into copilot/add-graalvm-community-edition
This commit is contained in:
@@ -76,7 +76,7 @@ steps:
|
||||
with:
|
||||
distribution: 'temurin' # See 'Supported distributions' for available options
|
||||
java-version: '25'
|
||||
- run: java HelloWorldApp.java
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
#### Azul Zulu OpenJDK
|
||||
@@ -87,7 +87,7 @@ steps:
|
||||
with:
|
||||
distribution: 'zulu' # See 'Supported distributions' for available options
|
||||
java-version: '25'
|
||||
- run: java HelloWorldApp.java
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
#### Supported version syntax
|
||||
@@ -223,7 +223,7 @@ steps:
|
||||
distribution: 'temurin'
|
||||
java-version: '25'
|
||||
check-latest: true
|
||||
- run: java HelloWorldApp.java
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Testing against different Java versions
|
||||
@@ -242,7 +242,7 @@ jobs:
|
||||
with:
|
||||
distribution: '<distribution>'
|
||||
java-version: ${{ matrix.java }}
|
||||
- run: java HelloWorldApp.java
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Install multiple JDKs
|
||||
|
||||
+45
-20
@@ -13,6 +13,7 @@
|
||||
- [GraalVM Community](#GraalVM-Community)
|
||||
- [JetBrains](#JetBrains)
|
||||
- [Installing custom Java package type](#Installing-custom-Java-package-type)
|
||||
- [JavaFX Maven project](#JavaFX-Maven-project)
|
||||
- [Installing custom Java architecture](#Installing-custom-Java-architecture)
|
||||
- [Installing custom Java distribution from local file](#Installing-Java-from-local-file)
|
||||
- [Testing against different Java distributions](#Testing-against-different-Java-distributions)
|
||||
@@ -37,7 +38,7 @@ steps:
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: '21'
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Adopt
|
||||
@@ -50,7 +51,7 @@ steps:
|
||||
with:
|
||||
distribution: 'adopt-hotspot'
|
||||
java-version: '11'
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Zulu
|
||||
@@ -63,7 +64,7 @@ steps:
|
||||
distribution: 'zulu'
|
||||
java-version: '21'
|
||||
java-package: jdk # optional (jdk, jre, jdk+fx or jre+fx) - defaults to jdk
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Liberica
|
||||
@@ -76,7 +77,7 @@ steps:
|
||||
distribution: 'liberica'
|
||||
java-version: '21'
|
||||
java-package: jdk # optional (jdk, jre, jdk+fx or jre+fx) - defaults to jdk
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Microsoft
|
||||
@@ -88,7 +89,7 @@ steps:
|
||||
with:
|
||||
distribution: 'microsoft'
|
||||
java-version: '21'
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Using Microsoft distribution on GHES
|
||||
@@ -117,7 +118,7 @@ steps:
|
||||
with:
|
||||
distribution: 'corretto'
|
||||
java-version: '21'
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Oracle
|
||||
@@ -130,7 +131,7 @@ steps:
|
||||
with:
|
||||
distribution: 'oracle'
|
||||
java-version: '21'
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### Alibaba Dragonwell
|
||||
@@ -143,7 +144,7 @@ steps:
|
||||
with:
|
||||
distribution: 'dragonwell'
|
||||
java-version: '8'
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### SapMachine
|
||||
@@ -155,7 +156,7 @@ steps:
|
||||
with:
|
||||
distribution: 'sapmachine'
|
||||
java-version: '21'
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### GraalVM
|
||||
@@ -169,8 +170,8 @@ steps:
|
||||
distribution: 'graalvm'
|
||||
java-version: '21'
|
||||
- run: |
|
||||
java -cp java HelloWorldApp
|
||||
native-image -cp java HelloWorldApp
|
||||
java --version
|
||||
native-image --version
|
||||
```
|
||||
|
||||
### GraalVM Community
|
||||
@@ -202,7 +203,7 @@ steps:
|
||||
with:
|
||||
distribution: 'jetbrains'
|
||||
java-version: '11'
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
The JetBrains installer uses the GitHub API to fetch the latest version. If you believe your project is going to be running into rate limits, you can provide a
|
||||
@@ -218,7 +219,7 @@ steps:
|
||||
java-package: 'jdk' # optional (jdk, jre, jdk+jcef, jre+jcef, jdk+ft, or jre+ft) - defaults to jdk
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
You can specify your package type (as shown in the [releases page](https://github.com/JetBrains/JetBrainsRuntime/releases/)) in the `java-package` parameter.
|
||||
@@ -241,7 +242,31 @@ steps:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
java-package: jdk # optional (jdk or jre) - defaults to jdk
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
### JavaFX Maven project
|
||||
|
||||
For JavaFX projects that use Maven, use `jdk+fx` (or `jre+fx`) as the `java-package` value together with a distribution that supports it (e.g. `zulu` or `liberica`). Then include the [`javafx-maven-plugin`](https://openjfx.io/openjfx-docs/#maven) in your `pom.xml` as described in the [Getting Started with JavaFX](https://openjfx.io/openjfx-docs/#maven) guide.
|
||||
|
||||
```yaml
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/setup-java@v5
|
||||
with:
|
||||
distribution: 'zulu'
|
||||
java-version: '21'
|
||||
java-package: jdk+fx
|
||||
cache: maven
|
||||
- name: Build with Maven
|
||||
run: mvn --no-transfer-progress compile
|
||||
```
|
||||
|
||||
To run the JavaFX application in CI:
|
||||
|
||||
```yaml
|
||||
- name: Run with Maven
|
||||
run: mvn --no-transfer-progress javafx:run
|
||||
```
|
||||
|
||||
## Installing custom Java architecture
|
||||
@@ -254,7 +279,7 @@ steps:
|
||||
distribution: '<distribution>'
|
||||
java-version: '11'
|
||||
architecture: x86 # optional - default value derived from the runner machine
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
## Installing Java from local file
|
||||
@@ -272,7 +297,7 @@ steps:
|
||||
java-version: '11.0.0'
|
||||
architecture: x64
|
||||
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
If your use-case requires a custom distribution (in the example, alpine-linux is used) or a version that is not provided by setup-java and you want to always install the latest version during runtime, then you can use the following code to auto-download the latest JDK, determine the semver needed for setup-java, and setup-java will take care of the installation and caching on the VM:
|
||||
@@ -297,7 +322,7 @@ If your use-case requires a custom distribution (in the example, alpine-linux is
|
||||
jdkFile: ${{ runner.temp }}/java_package.tar.gz
|
||||
java-version: {{ steps.fetch_latest_jdk.outputs.java_version }}
|
||||
architecture: x64
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
## Testing against different Java distributions
|
||||
@@ -318,7 +343,7 @@ jobs:
|
||||
with:
|
||||
distribution: ${{ matrix.distribution }}
|
||||
java-version: ${{ matrix.java }}
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
#### Testing against different platforms
|
||||
@@ -338,7 +363,7 @@ jobs:
|
||||
with:
|
||||
distribution: 'temurin'
|
||||
java-version: ${{ matrix.java }}
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
## Publishing using Apache Maven
|
||||
@@ -596,7 +621,7 @@ steps:
|
||||
distribution: 'temurin'
|
||||
java-version: '11'
|
||||
mvn-toolchain-id: 'some_other_id'
|
||||
- run: java -cp java HelloWorldApp
|
||||
- run: java --version
|
||||
```
|
||||
|
||||
In case you install multiple versions of Java at once you can use the same syntax as used in `java-versions`. Please note that you have to declare an ID for all Java versions that will be installed or the `mvn-toolchain-id` instruction will be skipped wholesale due to mapping ambiguities.
|
||||
|
||||
Reference in New Issue
Block a user