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

How to get a newer maven version alongside JDK 17 #685

Closed
2 of 5 tasks
ghoshbishakh opened this issue Sep 12, 2024 · 7 comments
Closed
2 of 5 tasks

How to get a newer maven version alongside JDK 17 #685

ghoshbishakh opened this issue Sep 12, 2024 · 7 comments
Assignees
Labels
bug Something isn't working

Comments

@ghoshbishakh
Copy link

Description:

After setting up JDK 17, the maven version we get is 3.8.8
We want to get the latest maven version, 3.9.x

Here is the workflow:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin'
      - run: mvn --version

Task version:
v4

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted
@ghoshbishakh ghoshbishakh added bug Something isn't working needs triage labels Sep 12, 2024
@aparnajyothi-y
Copy link
Contributor

Hello @ghoshbishakh, Thank you for creating this issue and we will look into it :)

@gowridurgad gowridurgad self-assigned this Sep 13, 2024
@gowridurgad
Copy link

Hi @ghoshbishakh, To use Maven version 3.9.9 alongside JDK 17, Maven needs to be manually installed since the ubuntu-latest runner image comes with Maven 3.8.8 by default. For reference, please visit https://github.com/actions/runner-images/blob/main/images/ubuntu/Ubuntu2204-Readme.md.
Here is an updated workflow configuration:

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install latest Maven
        run: |
          MAVEN_VERSION=3.9.9
          wget https://downloads.apache.org/maven/maven-3/$MAVEN_VERSION/binaries/apache-maven-$MAVEN_VERSION-bin.tar.gz
          tar xzvf apache-maven-$MAVEN_VERSION-bin.tar.gz
          sudo mv apache-maven-$MAVEN_VERSION /opt/maven
          sudo rm -f /usr/bin/mvn  # Remove existing symbolic link if it exists
          sudo ln -s /opt/maven/bin/mvn /usr/bin/mvn  # Create new symbolic link
      - name: Set up JDK
        uses: actions/setup-java@v4
        with:
          java-version: '17'
          distribution: 'temurin' 
      - run: mvn --version

@ghoshbishakh
Copy link
Author

Thanks a lot @gowridurgad . I will try it out.

@jglick
Copy link

jglick commented Sep 26, 2024

I think this should be reopened: 3.8.8 is not compatible with Java 17-based tools (fixed in apache/maven#1286 in 3.9.6), so it is important to be running a newer version.

@gowridurgad
Copy link

Hi @jglick, We are able to use Maven version 3.8.8 alongside JDK 17. Attached a screenshot for your reference. However, if you need to use Maven 3.9.x, you can manually install it in your GitHub Actions workflow.

Screenshot 2024-09-27 at 4 21 48 PM

@timja
Copy link

timja commented Oct 1, 2024

Hi @jglick, We are able to use Maven version 3.8.8 alongside JDK 17. Attached a screenshot for your reference. However, if you need to use Maven 3.9.x, you can manually install it in your GitHub Actions workflow.

The difference here will be a Maven plugin compiled with Java 17. Before the fix in 3.9.6 Maven could build Java 17 projects but couldn't use Maven plugins with bytecode newer than Java 14.

@kwin
Copy link

kwin commented Oct 10, 2024

Using Maven Wrapper is the easiest way to enforce a specific Maven version on most operating systems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants