Skip to content

Fix deprecated Gradle syntax and configuration features #3358

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

Merged
merged 5 commits into from
May 25, 2025

Conversation

jen20
Copy link
Contributor

@jen20 jen20 commented May 20, 2025

When running ./gradlew shadowJar compileTestJava --warning-mode=all on the current HEAD of main (68f805a), a number of warnings are produced for deprecated usages of Gradle configuration features. Upon fixing the trivial deprecations produced in the first pass, a second round of issues is also produced. This pull request fixes all of those, such that the command executes cleanly, without generating a Gradle problem report.

Each class of issue is addressed in a separate commit (which contains links to the Gradle documentation showing the fix mechanism to be the recommended approach), but broadly speaking there are five categories:

  1. Use of destination instead of outputLocation when configuring JUnit report output location (docs)
  2. Consistent use of key = value assignment rather than "space assignment" or propertyName(value) assignment (docs)
  3. Use of plugin blocks instead of conventions for the Java plugin (docs)
  4. Use of plugin blocks instead of conventions for the Application plugin (docs) and applying the ensuing required cleanup from the Gradle 7 migration (docs)
  5. Stopping the use of Task.project in Task actions (docs).

Other tasks which are not dependents of shadowJar or compileTestJava likely still use deprecated syntax or conventions - I will follow up with a second pull request to address those in future.

jen20 added 5 commits May 20, 2025 08:51
This fixes two Gradle deprecation warnings related to the output
location of JUnit XML reports, as documented in [1].

[1]: https://docs.gradle.org/8.13/dsl/org.gradle.api.reporting.Report.html#org.gradle.api.reporting.Report:destination
This fixes usages of variable assignment via both space assigment and
propertyName(value) per the deprecation warnings for Gradle 8, as
documented in [1]. Instead, we adopt the recommended property = value
syntax.

[1]: https://docs.gradle.org/8.13/userguide/upgrading_version_8.html#groovy_space_assignment_syntax
This wraps deprcated usages of Java plugin conventions to use a plugin
block, as documented in [1].

[1]: https://docs.gradle.org/8.13/userguide/upgrading_version_8.html#java_convention_deprecation
This commit fixes the deprecated usages of Gradle Application plugin
conventions, by wrapping usage in plugin blocks as described in [1].

It also replaces usage of mainClassName with mainClass, a change
necessitated by the Gradle 7 -> 8 migrations [2], but still supported
via plugin conventions.

[1]: https://docs.gradle.org/8.13/userguide/upgrading_version_8.html#application_convention_deprecation
[2]: https://docs.gradle.org/current/userguide/upgrading_version_7.html#javaapplication_api_cleanup
Per [1], usine of Task.project during task action execution is
deprecated, and instead values should be captured during configuration.
This commit replaces usage of Task.project and Task.rootProject by
capturing variables during configuration as documented.

[1]: https://docs.gradle.org/8.13/userguide/upgrading_version_7.html#task_project
@jen20
Copy link
Contributor Author

jen20 commented May 21, 2025

Incidentally I did not happen to see #3354 from @arnaud-lacurie (hi Arnaud!) before doing this, but it is different: that fixes the warnings for building with a newer JDK using Gradle 9, but does not address the issues of feature and configuration deprecation within Gradle itself.

@arnaud-lacurie arnaud-lacurie added the build improvement Improvement to the build system label May 22, 2025
@arnaud-lacurie arnaud-lacurie merged commit da26d61 into FoundationDB:main May 25, 2025
5 of 6 checks passed
@jen20 jen20 deleted the jen20/fix-gradle-deprecations branch May 25, 2025 12:46
normen662 pushed a commit to normen662/fdb-record-layer that referenced this pull request May 26, 2025
…#3358)

When running `./gradlew shadowJar compileTestJava --warning-mode=all` on
the current HEAD of `main` (68f805a), a number of warnings are
produced for deprecated usages of Gradle configuration features. Upon
fixing the trivial deprecations produced in the first pass, a second
round of issues is also produced. This pull request fixes all of those,
such that the command executes cleanly, without generating a Gradle
problem report.

Each class of issue is addressed in a separate commit (which contains
links to the Gradle documentation showing the fix mechanism to be the
recommended approach), but broadly speaking there are five categories:

1. Use of `destination` instead of `outputLocation` when configuring
JUnit report output location
([docs](https://docs.gradle.org/8.13/dsl/org.gradle.api.reporting.Report.html#org.gradle.api.reporting.Report:destination))
2. Consistent use of `key = value` assignment rather than "space
assignment" or `propertyName(value)` assignment
([docs](https://docs.gradle.org/8.13/userguide/upgrading_version_8.html#groovy_space_assignment_syntax))
3. Use of plugin blocks instead of conventions for the `Java` plugin
([docs](https://docs.gradle.org/8.13/userguide/upgrading_version_8.html#java_convention_deprecation))
4. Use of plugin blocks instead of conventions for the `Application`
plugin
([docs](https://docs.gradle.org/8.13/userguide/upgrading_version_8.html#application_convention_deprecation))
and applying the ensuing required cleanup from the Gradle 7 migration
([docs](https://docs.gradle.org/current/userguide/upgrading_version_7.html#javaapplication_api_cleanup))
5. Stopping the use of `Task.project` in Task actions
([docs](https://docs.gradle.org/8.13/userguide/upgrading_version_7.html#task_project)).

Other tasks which are not dependents of `shadowJar` or `compileTestJava`
likely still use deprecated syntax or conventions - I will follow up
with a second pull request to address those in future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build improvement Improvement to the build system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants