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

nimbus-gradle-plugin: Support absolute and relative paths. #6224

Merged
merged 3 commits into from
May 2, 2024

Conversation

linabutler
Copy link
Member

@linabutler linabutler commented May 2, 2024

Hi @jeddai! 👋🏼

When I was fixing the Fenix auto-publishing workflow last week, I noticed that it didn't like absolute paths to the Application Services repo. I added a low-effort check that threw an exception for (Unix-style) absolute paths, but wanted to fix the issue for real.

I tracked down the bellyaching to how the Nimbus Gradle Plugin was resolving paths—and fixed it up in this PR so that it can handle both kinds of paths ☺️ I've tested this logic locally, and it works with both absolute and relative paths in autoPublish.application-services.dir now!

I think this is an O(n) change.

Here's an explanation of what I did, copied from the commit message:

  • Use project.file(...) to resolve paths relative to the
    project directory, instead of the File constructor. The
    .file() method understands absolute paths.
  • Use project.layout.buildDirectory.dir(...) to resolve
    paths relative to the build directory, instead of manually
    building the path from the deprecated project.buildDir
    property.
  • Use / instead of File.separator for paths. This is the style
    that Gradle recommends, and it simplifies how we build path strings.
    The Java File APIs canonicalize / to \ on Windows, so it's
    not necessary to use File.separator explicitly.

And, in a follow-up commit, I noticed a couple of places where we could use the Groovy withReader method.

Pull Request checklist

  • Breaking changes: This PR follows our breaking change policy
    • This PR follows the breaking change policy:
      • This PR has no breaking API changes, or
      • There are corresponding PRs for our consumer applications that resolve the breaking changes and have been approved
  • Quality: This PR builds and tests run cleanly
    • Note:
      • For changes that need extra cross-platform testing, consider adding [ci full] to the PR title.
      • If this pull request includes a breaking change, consider cutting a new release after merging.
  • Tests: This PR includes thorough tests or an explanation of why it does not
  • Changelog: This PR includes a changelog entry in CHANGELOG.md or an explanation of why it does not need one
    • Any breaking changes to Swift or Kotlin binding APIs are noted explicitly
  • Dependencies: This PR follows our dependency management guidelines
    • Any new dependencies are accompanied by a summary of the due diligence applied in selecting them.

Branch builds: add [firefox-android: branch-name] to the PR title.

@linabutler linabutler requested a review from jeddai May 2, 2024 03:52
@codecov-commenter
Copy link

codecov-commenter commented May 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.83%. Comparing base (c6550f7) to head (8b95708).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #6224   +/-   ##
=======================================
  Coverage   83.83%   83.83%           
=======================================
  Files         117      117           
  Lines       15693    15693           
=======================================
  Hits        13157    13157           
  Misses       2536     2536           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@linabutler linabutler force-pushed the nimbus-gradle-plugin-paths branch 2 times, most recently from 64706e1 to 6a6f59e Compare May 2, 2024 05:56
Copy link
Member

@jeddai jeddai left a comment

Choose a reason for hiding this comment

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

This looks great!

This commit refactors how the Nimbus Gradle Plugin handles
project-relative directories, so that developers can specify
relative and absolute paths to Application Services in the
`autoPublish.application-services.dir` property when using the Fenix
auto-publishing workflow.

The changes are:

* Use `project.file(...)` to resolve paths relative to the
  project directory, instead of the `File` constructor. The
  `.file()` method understands absolute paths.
* Use `project.layout.buildDirectory.dir(...)` to resolve
  paths relative to the build directory, instead of manually
  building the path from the deprecated `project.buildDir`
  property.
* Use `/` instead of `File.separator` for paths. This is the style
  that Gradle recommends, and it simplifies how we build path strings.
  The Java File APIs canonicalize `/` to `\` on Windows, so it's
  not necessary to use `File.separator` explicitly.
This ensures that the streams are closed after they're consumed.
@linabutler linabutler added this pull request to the merge queue May 2, 2024
Merged via the queue into main with commit 5e198a9 May 2, 2024
16 checks passed
@linabutler linabutler deleted the nimbus-gradle-plugin-paths branch May 2, 2024 19:03
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.

None yet

3 participants