googlejavaformat-action icon indicating copy to clipboard operation
googlejavaformat-action copied to clipboard

[WARNING]Version "1.22.0" of Google Java Format cannot be found. Fallback to latest. | But it actually exists

Open BeshEater opened this issue 1 year ago • 1 comments

Recently I tried to set up a new GitHub Action flow using googlejavaformat-action, it works great, but I always get this particular warning in logs: [warning]Version "1.22.0" of Google Java Format cannot be found. Fallback to latest. but I'm pretty sure it actually exists, and it also downloads the same version on the next step. See full logs:

##[group]Run axel-op/googlejavaformat-action@v3
with:
  args: --skip-reflowing-long-strings --set-exit-if-changed
  version: 1.22.0
  skip-commit: true
  github-token: ***
  files: **/*.java
env:
  GIT_USER_EMAIL: [email protected]
  GIT_USER_NAME: GitHub Actions
  .....
  JAVA_HOME: /opt/hostedtoolcache/Java_Corretto_jdk/17.0.11-9.1/x64
  JAVA_HOME_17_X64: /opt/hostedtoolcache/Java_Corretto_jdk/17.0.11-9.1/x64
##[endgroup]
##[warning]Version "1.22.0" of Google Java Format cannot be found. Fallback to latest.
Version of JDK: 17
##[group]Downloading Google Java Format
Downloading executable to /home/runner/google-java-format.jar
[command]/opt/hostedtoolcache/Java_Corretto_jdk/17.0.11-9.1/x64/bin/java --add-exports jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED --add-exports jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED -jar /home/runner/google-java-format.jar --version
google-java-format: Version 1.22.0
##[endgroup]

Github Action Config:

# Lint the code (fail if not successful)
- name: Linting
  uses: axel-op/googlejavaformat-action@v3
  with:
    args: "--skip-reflowing-long-strings --set-exit-if-changed"
    version: 1.22.0
    skip-commit: true
    github-token: ${{ secrets.GITHUB_TOKEN }}

What could cause a warning like that? How could I provide a specific version then?

BeshEater avatar May 20 '24 18:05 BeshEater

After some more digging, I finally figured out what was the problem. Apparently for some reason after version 1.14.0 the google-java-format project started to add v prefix for all the release names in GitHub - https://github.com/google/google-java-format/releases?page=2 And that is what this plugin uses internally - check the name field from this JSON - https://api.github.com/repos/google/google-java-format/releases BUT in Maven they don't use v prefix - https://mvnrepository.com/artifact/com.google.googlejavaformat/google-java-format what a surprise, huh?

So in a nutshell I need to provide a version name with v prefix like

# Lint the code (fail if not successful)
- name: Linting
  uses: axel-op/googlejavaformat-action@v3
  with:
    args: "--skip-reflowing-long-strings --set-exit-if-changed"
    version: v1.22.0 
    skip-commit: true
    github-token: ${{ secrets.GITHUB_TOKEN }}

Probably it will be better to add a special notion about this peculiarity in README.md, or even handle this v prefix in the code.

BeshEater avatar May 22 '24 10:05 BeshEater

Apparently for some reason after version 1.14.0 the google-java-format project started to add v prefix for all the release names in GitHub

Yes, you're right. I don't want to add too many magic features in the code which would make it (in my opinion) even more confusing, so I'll just pin this issue and close it as a "won't fix".

axel-op avatar Feb 17 '25 23:02 axel-op