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

setFileMode slated for removal in Gradle 9.0 #160

Open
bell345 opened this issue Jan 8, 2025 · 3 comments
Open

setFileMode slated for removal in Gradle 9.0 #160

bell345 opened this issue Jan 8, 2025 · 3 comments

Comments

@bell345
Copy link

bell345 commented Jan 8, 2025

When building with a newer version of Gradle (8.9), there is a deprecation warning caused by the use of setFileMode in RustAndroidPlugin.kt, see:

fileMode = 493 // 0755 in decimal; Kotlin doesn't have octal literals (!).

This API is currently deprecated and is slated for removal in Gradle 9.0, due for release in Q2 2025. Therefore, this usage should be replaced with an implementation with the newer filePermissions(Action) API.

I am planning to contribute a quick PR in a few hours to resolve this issue.

@bell345
Copy link
Author

bell345 commented Jan 8, 2025

Now I see that the new API doesn't exist in the Gradle version used for this plugin (4.0.1) because it was introduced in 8.3.

I'm now creating a fork to update to the latest versions of Gradle and AGP (8.12 and 8.7, respectively). If there is interest I will consider making a pull request.

@ncalexan
Copy link
Member

ncalexan commented Jan 8, 2025

@bell345 I think we'd definitely be interested. I don't have a strong understanding of how Gradle versions for plugins work with backward compatibility: if we build r-a-g with Gradle 8, is it easy to use in projects with Gradle 7 and below? I think the answer is no, and if that's true, I think we'd probably need to do some work to understand usage in the wild to understand how far forward we can pull the plugin Gradle version.

@bell345
Copy link
Author

bell345 commented Jan 14, 2025

So I've been working on trying to modernise the plugin implementation and test suite. There are actually several deprecated features that are planned for removal in Gradle 9:

  • As mentioned, the setFileMode API
  • The VersionNumber API, which was originally intended only as an internal API
  • The Project.buildDir variable, in favor of a more awkward layout.buildDirectory API
  • Automatic convention for testClassesDirs and classpath in newly created Test tasks

This isn't even counting all of the idiomatic things that Gradle now recommends, such as Java toolchains, the use of Property everywhere and the plugin block.

Initially I tried to only focus on the deprecation warnings, but I got sidetracked and ended up doing a lot more work to get the project to resemble a Gradle plugin as intended in 2025. I also replaced the Groovy/Spock tests with Kotest; there isn't really much justification for that move, besides my personal dislike of Groovy.

I had attempted to try and keep compatibility with older AGP versions but I've had to deal with endless baffling errors such as "Protocol message contained an invalid tag" and "module cannot be null" (even when it is not null). After basically a week straight working on compatibility issues, I've decided to publish my forked version as "v0.10.0" with limited backwards compatibility on the Gradle plugin repository for my own use (as of writing this comment it is under review).

Given the scope of the changes far exceeds this one issue (see my self PR for more details), I might consider making smaller, focused PRs into the upstream repository where the changes are more appropriate. For example, I updated the documentation to feature Kotlin DSL prominently and with a proper target matrix table; that may be useful in of itself outside of the modernisation changes.

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

2 participants