Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: added support to pom.xml and build.gradle #441

Open
wants to merge 11 commits into
base: main
Choose a base branch
from
258 changes: 258 additions & 0 deletions .github/workflows/e2e-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,261 @@ jobs:
- name: Verify Java
run: bash __tests__/verify-java.sh "11.0.2" "${{ steps.setup-java.outputs.path }}"
shell: bash

setup-java-version-from-pom-spring-boot-specification:
name: ${{ matrix.distribution }} version from pom.xml - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create pom.xml file
shell: bash
run: |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > pom.xml
echo "<project>" >> pom.xml
echo " <modelVersion>4.0.0</modelVersion>" >> pom.xml
echo " <groupId>com.test</groupId>" >> pom.xml
echo " <artifactId>Test</artifactId>" >> pom.xml
echo " <version>0.0.1-SNAPSHOT</version>" >> pom.xml
echo " <name>Test</name>" >> pom.xml
echo " <properties>" >> pom.xml
echo " <java.version>11</java.version>" >> pom.xml
echo " </properties>" >> pom.xml
echo " <dependencies>" >> pom.xml
echo " </dependencies>" >> pom.xml
echo " <build>" >> pom.xml
echo " <plugins>" >> pom.xml
echo " <plugin>" >> pom.xml
echo " <groupId>org.springframework.boot</groupId>" >> pom.xml
echo " <artifactId>spring-boot-maven-plugin</artifactId>" >> pom.xml
echo " </plugin>" >> pom.xml
echo " </plugins>" >> pom.xml
echo " </build>" >> pom.xml
echo "</project>" >> pom.xml
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: 'pom.xml'
- name: Verify Java
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
shell: bash

setup-java-version-from-pom-maven-compiler-source-specification:
name: ${{ matrix.distribution }} version from pom.xml - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create pom.xml file
shell: bash
run: |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > pom.xml
echo "<project>" >> pom.xml
echo " <modelVersion>4.0.0</modelVersion>" >> pom.xml
echo " <groupId>foo.bar</groupId>" >> pom.xml
echo " <artifactId>FooBarr</artifactId>" >> pom.xml
echo " <version>0.0.1-SNAPSHOT</version>" >> pom.xml
echo " <properties>" >> pom.xml
echo " <maven.compiler.source>1.8</maven.compiler.source>" >> pom.xml
echo " <maven.compiler.target>1.8</maven.compiler.target>" >> pom.xml
echo " </properties>" >> pom.xml
echo " <build>" >> pom.xml
echo " <plugins>" >> pom.xml
echo " <plugin>" >> pom.xml
echo " <groupId>org.apache.maven.plugins</groupId>" >> pom.xml
echo " <artifactId>maven-compiler-plugin</artifactId>" >> pom.xml
echo " <version>3.10.1</version>" >> pom.xml
echo " </plugin>" >> pom.xml
echo " </plugins>" >> pom.xml
echo " </build>" >> pom.xml
echo "</project>" >> pom.xml
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: 'pom.xml'
- name: Verify Java
run: bash __tests__/verify-java.sh "8" "${{ steps.setup-java.outputs.path }}"
shell: bash

setup-java-version-from-pom-maven-compiler-release-specification:
name: ${{ matrix.distribution }} version from pom.xml - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create pom.xml file
shell: bash
run: |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > pom.xml
echo "<project>" >> pom.xml
echo " <modelVersion>4.0.0</modelVersion>" >> pom.xml
echo " <groupId>foo.bar</groupId>" >> pom.xml
echo " <artifactId>FooBarr</artifactId>" >> pom.xml
echo " <version>0.0.1-SNAPSHOT</version>" >> pom.xml
echo " <properties>" >> pom.xml
echo " <maven.compiler.release>8</maven.compiler.release>" >> pom.xml
echo " </properties>" >> pom.xml
echo " <build>" >> pom.xml
echo " <plugins>" >> pom.xml
echo " <plugin>" >> pom.xml
echo " <groupId>org.apache.maven.plugins</groupId>" >> pom.xml
echo " <artifactId>maven-compiler-plugin</artifactId>" >> pom.xml
echo " <version>3.10.1</version>" >> pom.xml
echo " </plugin>" >> pom.xml
echo " </plugins>" >> pom.xml
echo " </build>" >> pom.xml
echo "</project>" >> pom.xml
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: 'pom.xml'
- name: Verify Java
run: bash __tests__/verify-java.sh "8" "${{ steps.setup-java.outputs.path }}"
shell: bash
setup-java-version-from-pom-maven-compiler-plugin-configuration:
name: ${{ matrix.distribution }} version from pom.xml - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create pom.xml file
shell: bash
run: |
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > pom.xml
echo "<project>" >> pom.xml
echo " <modelVersion>4.0.0</modelVersion>" >> pom.xml
echo " <groupId>foo.bar</groupId>" >> pom.xml
echo " <artifactId>FooBar</artifactId>" >> pom.xml
echo " <version>0.0.1-SNAPSHOT</version>" >> pom.xml
echo " <build>" >> pom.xml
echo " <plugins>" >> pom.xml
echo " <plugin>" >> pom.xml
echo " <groupId>org.apache.maven.plugins</groupId>" >> pom.xml
echo " <artifactId>maven-compiler-plugin</artifactId>" >> pom.xml
echo " <version>3.10.1</version>" >> pom.xml
echo " <configuration>" >> pom.xml
echo " <source>1.8</source>" >> pom.xml
echo " <target>1.8</target>" >> pom.xml
echo " </configuration>" >> pom.xml
echo " </plugin>" >> pom.xml
echo " </plugins>" >> pom.xml
echo " </build>" >> pom.xml
echo "</project>" >> pom.xml
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: 'pom.xml'
- name: Verify Java
run: bash __tests__/verify-java.sh "8" "${{ steps.setup-java.outputs.path }}"
shell: bash
setup-java-version-from-build-gradle-java-library-plugin-specification:
name: ${{ matrix.distribution }} version from build.gradle - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create build.gradle file
shell: bash
run: |
echo "java {" > build.gradle
echo " toolchain {" >> build.gradle
echo " languageVersion.set(JavaLanguageVersion.of(11))" >> build.gradle
echo " }" >> build.gradle
echo "}" >> build.gradle
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: 'build.gradle'
- name: Verify Java
run: bash __tests__/verify-java.sh "11" "${{ steps.setup-java.outputs.path }}"
shell: bash

setup-java-version-from-build-gradle-java-plugin-source-compatibility-specification:
name: ${{ matrix.distribution }} version from build.gradle - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create pom.xml file
shell: bash
run: |
echo "java {" > build.gradle
echo " sourceCompatibility = JavaVersion.VERSION_1_8" >> build.gradle
echo " targetCompatibility = JavaVersion.VERSION_1_8" >> build.gradle
echo "}" >> build.gradle
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: 'build.gradle'
- name: Verify Java
run: bash __tests__/verify-java.sh "8" "${{ steps.setup-java.outputs.path }}"
shell: bash

setup-java-version-from-build-gradle-java-plugin-target-compatibility-specification:
name: ${{ matrix.distribution }} version from build.gradle - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [macos-latest, windows-latest, ubuntu-latest]
distribution: ['adopt', 'zulu', 'liberica']
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Create pom.xml file
shell: bash
run: |
echo "java {" > build.gradle
echo " targetCompatibility = JavaVersion.VERSION_21" >> build.gradle
echo "}" >> build.gradle
- name: setup-java
uses: ./
id: setup-java
with:
distribution: ${{ matrix.distribution }}
java-version-file: 'build.gradle'
- name: Verify Java
run: bash __tests__/verify-java.sh "21" "${{ steps.setup-java.outputs.path }}"
shell: bash
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ This action allows you to work with Java and Scala projects.

- `java-version`: The Java version that is going to be set up. Takes a whole or [semver](#supported-version-syntax) Java version. If not specified, the action will expect `java-version-file` input to be specified.

- `java-version-file`: The path to the `.java-version` file. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file).
- `java-version-file`: The path to the `.java-version` or `pom.xml` or `build.gradle` file. See more details in [about `.java-version` file](docs/advanced-usage.md#Java-version-file).

- `distribution`: _(required)_ Java [distribution](#supported-distributions).

Expand Down