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

False claim of syntax error #68

Open
Bios-Marcel opened this issue Oct 18, 2021 · 6 comments
Open

False claim of syntax error #68

Bios-Marcel opened this issue Oct 18, 2021 · 6 comments

Comments

@Bios-Marcel
Copy link

The plugin claims a syntax error, even though the task compileJava runs just fine. There's absolutely no syntax error in any of the files. I've also tried running the clean task. I really don't know what's going on. It worked and at some point just stopped working.

> Task :client:googleJavaFormat FAILED


Detected Java syntax errors in the following files (you can exclude them from this task, see "https://github.com/sherter/google-java-format-gradle-plugin" for details):

D:\repos\demo\client\src\main\java\com\isp\kkg\client\Client.java
D:\repos\demo\client\src\main\java\com\isp\kkg\client\ClientHello.java
D:\repos\demo\client\src\test\java\com\isp\kkg\client\DummyTest.java

Is there anything else I can give you? I can even send you the project as a zip if you want. It's just a demo anyways.

Bios-Marcel added a commit to Bios-Marcel/gradle-multi-project-demo that referenced this issue Oct 18, 2021
Features:
* Formatting (Borked: sherter/google-java-format-gradle-plugin#68)
* PMD
* Shadow Jar
* Testing
* Demo Project
* run task
* build abstraction
@Bios-Marcel
Copy link
Author

I uploaded the demo I am using. I tried it on another machine and it worked. So something might be going on with caching or so?

https://github.com/Bios-Marcel/gradle-multi-project-demo

@edsrzf
Copy link

edsrzf commented Oct 22, 2021

I'm also seeing this after upgrading from 0.8 to 0.9. I've updated Gradle and the JDK at the same time, so there could be other things at play too.

@aecio
Copy link
Contributor

aecio commented Oct 23, 2021

I had this same error after updating to JDK 17 and Gradle 7.2. I found two errors that may cause this message:

  • One happens if you are using an old version of google-java-formatter, which does not support Java 17. Make sure to use a recent version like 1.12.0.
  • The other happens because enabling internal JDK modules are required to run on JDK 17. I posted a fix for this here: Java 17 with gradle 7 Support #67 (comment).

I also opened PR #66 to provide a better error message, but unfortunately, the project seems to be unmaintained currently (#57).

@cies
Copy link

cies commented Jan 27, 2022

I have the same problem, with Java 14 source compatibility and Gradle 7.2

One happens if you are using an old version of google-java-formatter, which does not support Java 17. Make sure to use a recent version like 1.12.0.

@aecio: where do I set this? This is an intellij plugin right? Isn't that different from the gradle plugin we discuss here?

@aecio
Copy link
Contributor

aecio commented Jan 27, 2022

This Gradle plugin is a wrapper for the original Google's library google-java-formatter. As described in the README of this project, you can change the library version by adding the following configuration in your Gradle build file:

googleJavaFormat {
  toolVersion = '1.1-SNAPSHOT'
}

@cies
Copy link

cies commented Sep 4, 2022

One more hint for those who try to fix this issue:

Make sure your gradlew uses the right JDK version. I had this problem when using the latest plugin version with the latest toolVersion specified in the gradle file with the flags as specified in #67 ... Still it did not work because my gradlew used my system default JDK11.

I fixed it with:

mkdir -p $HOME/.gradle
echo "org.gradle.java.home=$HOME/.jdks/temurin-17.xyz/" > $HOME/.gradle/gradle.properties

Where $HOME/.jdks/temurin-17.xyz/ should be replaced with the path to right JDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants