Skip to content

fix: add Gradle 9 compatibility#168

Open
klochowicz wants to merge 1 commit intomozilla:masterfrom
klochowicz:master
Open

fix: add Gradle 9 compatibility#168
klochowicz wants to merge 1 commit intomozilla:masterfrom
klochowicz:master

Conversation

@klochowicz
Copy link

Gradle 9 removed several deprecated APIs that this plugin relied on. This commit updates the plugin to use the new APIs and modernizes the build configuration to support the changes.

  1. Core API Changes (Gradle 9 removals)
  • Replace fileMode = 493 with filePermissions { unix("rwxr-xr-x") } The CopySpec.fileMode property was deprecated in Gradle 8 and removed in Gradle 9. The new filePermissions API provides the same functionality.

  • Replace project.exec {} with injected ExecOperations.exec {} The Project.exec() method was deprecated in Gradle 7.5 and removed in Gradle 9. Tasks must now use service injection to obtain ExecOperations. This requires changing task classes from open class to abstract class.

  1. Build Configuration Updates

These changes are required because the new Gradle 9 APIs (filePermissions, ExecOperations) are only available in Gradle 8.3+, so we must compile against a newer Gradle version:

  • Gradle wrapper: 7.1.1 → 8.5 Required to compile against the new APIs (filePermissions added in 8.3)

  • Kotlin: 1.3.50 → 1.9.22 The old Kotlin Gradle plugin uses APIs removed in Gradle 8.x

  • AGP: 4.0.1 → 8.2.0 Required for Gradle 8.5+ compatibility

  • Java target: 1.8 → 17 Required by both Gradle 8.5+ and AGP 8.x

  • plugin-publish: 0.14.0 → 1.2.1 The old version uses the pluginBundle {} DSL which was removed. Metadata (website, vcsUrl, tags) now goes in gradlePlugin {} block.

  • Add Guava dependency Versions.groovy uses Guava collections which were previously provided transitively by AGP 4.x but are no longer included in AGP 8.x.

  • Add null branch to when expression in CargoBuildTask Kotlin 1.7+ requires exhaustive when for sealed classes with nullable types.

  1. Test Matrix Updates
  • Updated supportedVersions to test AGP 8.x with Gradle 8.x
  • Updated jdkVersionFor() to use Java 17 for AGP 8.x

Fixes #160

Gradle 9 removed several deprecated APIs that this plugin relied on.
This commit updates the plugin to use the new APIs and modernizes the
build configuration to support the changes.

1. Core API Changes (Gradle 9 removals)

- Replace `fileMode = 493` with `filePermissions { unix("rwxr-xr-x") }`
  The CopySpec.fileMode property was deprecated in Gradle 8 and removed
  in Gradle 9. The new filePermissions API provides the same functionality.

- Replace `project.exec {}` with injected `ExecOperations.exec {}`
  The Project.exec() method was deprecated in Gradle 7.5 and removed in
  Gradle 9. Tasks must now use service injection to obtain ExecOperations.
  This requires changing task classes from `open class` to `abstract class`.

2. Build Configuration Updates

These changes are required because the new Gradle 9 APIs (filePermissions,
ExecOperations) are only available in Gradle 8.3+, so we must compile
against a newer Gradle version:

- Gradle wrapper: 7.1.1 → 8.5
  Required to compile against the new APIs (filePermissions added in 8.3)

- Kotlin: 1.3.50 → 1.9.22
  The old Kotlin Gradle plugin uses APIs removed in Gradle 8.x

- AGP: 4.0.1 → 8.2.0
  Required for Gradle 8.5+ compatibility

- Java target: 1.8 → 17
  Required by both Gradle 8.5+ and AGP 8.x

- plugin-publish: 0.14.0 → 1.2.1
  The old version uses the `pluginBundle {}` DSL which was removed.
  Metadata (website, vcsUrl, tags) now goes in `gradlePlugin {}` block.

- Add Guava dependency
  Versions.groovy uses Guava collections which were previously provided
  transitively by AGP 4.x but are no longer included in AGP 8.x.

- Add `null` branch to `when` expression in CargoBuildTask
  Kotlin 1.7+ requires exhaustive `when` for sealed classes with
  nullable types.

3. Test Matrix Updates

- Updated supportedVersions to test AGP 8.x with Gradle 8.x
- Updated jdkVersionFor() to use Java 17 for AGP 8.x

Fixes mozilla#160
// there's a way to specify them in the cargo command line -- rustc accepts
// them if passed in directly with `--cfg`, and cargo will pass them to rustc
// if you use them as default featureSpec.
// Kotlin 1.9+ requires exhaustive when for sealed classes with nullable types
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

happy to remove all the comments in the review process, but figured it would be easier to understand how this small file permissions change (the actual removed API) triggered cascading change in other dependencies.

Comment on lines -32 to +42
"7.0.0": ["7.1.1"],
"4.2.2": ["6.8.3", "7.1.1"],
"4.1.3": ["6.5.1", "6.8.3"],
"4.0.2": ["6.1.1", "6.8.3"],
"3.6.4": ["5.6.4", "6.8.3"],
"3.5.4": ["5.4.1", "5.6.4", "6.8.3"],
"3.1.2": ["4.10.2"]
"8.2.0": ["8.5"],
"8.3.0": ["8.5"],
"8.4.0": ["8.6"],
"8.5.0": ["8.7"],
"8.6.0": ["8.7"],
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what to keep here to avoid breaking code - I tested it with 8.5.0 locally.

perhaps it would require a minor version bump to avoid breaking old code?

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

Successfully merging this pull request may close these issues.

setFileMode slated for removal in Gradle 9.0

1 participant