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

Deprecation warnings prevent using GJF with Gradle 7 in projects that can't upgrade to Java 11 #59

Closed
jimshowalter opened this issue Apr 13, 2021 · 13 comments

Comments

@jimshowalter
Copy link

Once you made the minimum Java runtime version be 11, a huge number of legacy Java projects (which probably means about 95% of all Java code every written!) were unable to use newer versions of GJF.

Unfortunately, older versions of GJF have deprecation warnings in Gradle 6.x that are now forbidden in Gradle 7.x.

So, it's a Catch-22. Projects either need to 1) stop using GJF, or 2) not upgrade Gradle.

Both of those are horrible options.

Please please please cut a release of GJF that is compatible with Java 8 and removes the deprecations.

> Task :verifyGoogleJavaFormat Property 'ignoreFailures' has redundant getters: 'getIgnoreFailures()' and 'isIgnoreFailures()'. This behaviour has been deprecated and is scheduled to be removed in Gradle 7.0. See https://docs.gradle.org/6.7.1/userguide/more_about_tasks.html#sec:up_to_date_checks for more details.

Also, is there some way projects stuck in this situation can override the ignoreFailures property in their own Gradle build files to not have redundant getters?

@sherter
Copy link
Owner

sherter commented May 2, 2021

Which version of the plugin are you using? 065ecdb (part of 0.9) should fix the deprecration warning.

@sherter
Copy link
Owner

sherter commented May 2, 2021

Once you made the minimum Java runtime version be 11, a huge number of legacy Java projects (which probably means about 95% of all Java code every written!) were unable to use newer versions of GJF.

And also I don't have any control over what runtime requirements google-java-format has. This gradle plugin doesn't require JRE 11 (all the integration tests run fine on openjdk8 and oraclejdk8). Maybe try downgrading to an older version of google-java-format (with toolVersion = x.x.x).

@jimshowalter
Copy link
Author

We tried 0.9 and it blew up with class-format exceptions due to running on Java 8, but perhaps something else is misconfigured. Will try again tomorrow.

@jimshowalter
Copy link
Author

If you follow the instructions in the readme in https://github.com/jimshowalter/gjf-problem, you'll reproduce the problem we're seeing. If you can figure out what combination of configuration will make Java 8 work with the formatter and with Gradle 7.x, that would be great!

@jimshowalter
Copy link
Author

Specifying toolVersion doesn't help.

@sherter
Copy link
Owner

sherter commented May 4, 2021

I really don't understand what's so complicated about this and why I am doing this now for you, but here you go:

diff --git a/build.gradle b/build.gradle
index a9cb798..8f33d68 100644
--- a/build.gradle
+++ b/build.gradle
@@ -30,6 +30,7 @@ targetCompatibility = 1.8

 apply plugin: 'com.github.sherter.google-java-format'
 googleJavaFormat {
+  toolVersion = '1.7' // Java 8 compatible version of google-java-format
   exclude '**/wrapper/dists/**'
   exclude '**/src/main/resources/**'
   exclude '**/src/test/resources/**'
diff --git a/gradle.properties b/gradle.properties
index 9f7f192..be1507c 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -2,5 +2,5 @@ group=org.gjf
 artifactId=problem
 version=1.0-SNAPSHOT
 benManesVersion=0.36.0
-googleJavaFormatVersion=0.8
+googleJavaFormatVersion=0.9
 jupiterVersion=5.7.1
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index e09fc66..940647e 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,5 +1,5 @@
 distributionBase=PROJECT
 distributionPath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.0-bin.zip
 zipStoreBase=PROJECT
 zipStorePath=wrapper/dists

@sherter sherter closed this as completed May 4, 2021
@jimshowalter
Copy link
Author

Thank you! This undoubtedly seemed obvious to you, but the interactions among the settings is not obvious to an outsider. In particular, it wasn't clear which tool version to use for Java 8. This wouldn't be an entirely bad thing to include in your readme.

@sherter
Copy link
Owner

sherter commented May 5, 2021

Sorry, I didn't want to be rude, it's just really annoying when people open and comment in multiple issues [1] to make absolutely sure that they are heard and get help from someone, instead of (and this is what open source is about) trying to understand and fix the problem themselves (and for others, by contributing back). I have enough of these kind of bug reports at work.

I can see now that you have put in some effort at least (creating an example project), but if you had read my comments and the README carefully, you would have known that setting toolVersion to '1.8' doesn't downgrade anything, it is just setting it to its default value.

That being said, you are right that it wouldn't be an entirely bad thing to say a word or two about google-java-format potentially having different (stricter) runtime requirements (documented in their release notes: https://github.com/google/google-java-format/releases). Feel free to open a pull request 😉 .

[1] #59, #58, google/google-java-format#593, google/google-java-format#602

@jimshowalter
Copy link
Author

Didn't take it as rude, and greatly appreciated getting it unsnarled. We are now running with Gradle 7.0 (the latest), Java 8, and your plugin.

ihnorton referenced this issue in TileDB-Inc/TileDB-Spark Jun 25, 2021
- Update format with sherter.google-java-format 0.9
- Use and reformat with earlier googleJavaFormat ¯\_(ツ)_/¯

`https://github.com/sherter/google-java-format-gradle-plugin/issues/59`
ihnorton referenced this issue in TileDB-Inc/TileDB-Spark Jun 25, 2021
- Update format with sherter.google-java-format 0.9
- Use and reformat with earlier googleJavaFormat ¯\_(ツ)_/¯

`https://github.com/sherter/google-java-format-gradle-plugin/issues/59`
@yegoryeshchenko
Copy link

Updated Gradle from 6.9.2 to 7.3.3, started getting same error:

`* What went wrong:
Some problems were found with the configuration of task ':googleJavaFormat' (type 'GoogleJavaFormat').

  • In plugin 'com.github.sherter.google-java-format' type 'com.github.sherter.googlejavaformatgradleplugin.GoogleJavaFormat' property 'filteredSources' is missing an input or output a
    nnotation.

    Reason: A property without annotation isn't considered during up-to-date checking.

    Possible solutions:

    1. Add an input or output annotation.
    2. Mark it as @internal.

    Please refer to https://docs.gradle.org/7.3.3/userguide/validation_problems.html#missing_annotation for more details about this problem.

  • In plugin 'com.github.sherter.google-java-format' type 'com.github.sherter.googlejavaformatgradleplugin.GoogleJavaFormat' property 'formattedSources' is missing an input or output
    annotation.
    `
    @sherter , what could be the reason ? how can I fix that ?

@jimshowalter
Copy link
Author

Did you follow the configuration info @sherter gave above? We followed it and are un 7.3.3 with the GJF plugin, and everything works fine.

@yegoryeshchenko
Copy link

yegoryeshchenko commented Jan 21, 2022

Did you follow the configuration info @sherter gave above? We followed it and are un 7.3.3 with the GJF plugin, and everything works fine.

the one thing worked for me - I downgraded toolVersion to 1.7 (using GJF v 0.9)

sorry, which configuration do you mean?

@jimshowalter
Copy link
Author

Scroll up: #59 (comment)

TWiStErRob added a commit to TWiStErRob/gcp-gradle-plugin that referenced this issue Jan 13, 2023
…sion of GJF gradle plugin (formatter version stays the same).

Verified by messing up some code running gradlew googleJavaFormat.
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

3 participants