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

Implement (experimental) unused dependency checking feature. #437

Merged
merged 1 commit into from
Jan 8, 2021

Conversation

jongerrish
Copy link
Contributor

@jongerrish jongerrish commented Jan 1, 2021

  • Add a tristate (off/warn/error) experimental_report_unused_deps attribute to the toolchain.
  • Implement unused dependency checking in JDepsMerger tool.
  • Collect jdeps dependency artifacts if experimental_report_unused_deps is enabled (warn/error) and pass to KotlinBuilder. Passing these inputs triggers JDepsMerge action for each target causing the unused deps checking logic to be executed. Currently these inputs are not used by the KotlinBuilder but will be required for future work implementing a reduced classpath feature.
  • Add tests for experimental_report_unused_deps off/warn/error
  • Enable experimental_report_unused_deps as "warn" for examples/android

@jongerrish jongerrish changed the title WIP: Report unused dependencies with buildozer command. Implement unused dependency checking feature. Jan 2, 2021
@jongerrish jongerrish changed the title Implement unused dependency checking feature. Implement (experimental) unused dependency checking feature. Jan 2, 2021
val command =
"""
|$open ** Please remove the following dependencies:$close ${unusedLabels.joinToString(" ")} from $label
|$open ** You can use the following buildozer command:$close buildozer 'remove deps ${unusedLabels.joinToString(" ")}' $label
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not entirely sure what the \u001b[0m ANSI code is, but if the buildozer command matches ^buildozer '(.*)'\\s+(.*)$, ibazel can automatically run it when it sees it (see https://github.com/bazelbuild/bazel-watcher#output-runner)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I copied these codes from Bazel's Java strict deps compiler plugin :-)

Looks like you can set any regex patterns anyway with the output runner, so should be good?

attribute to the toolchain.

Implement unused dependency checking in `JDepsMerger` tool.

Collect jdeps dependency artifacts if experimental_report_unused_deps
is enabled (warn/error) and pass to KotlinBuilder. Passing these inputs
triggers `JDepsMerge` action for each target causing the unused deps
checking logic to be executed. Currently these inputs are not used by
the `KotlinBuilder` but will be required for future work implementing
a reduced classpath feature.

Add tests for experimental_report_unused_deps off/warn/error

Enable experimental_report_unused_deps as "warn" for examples/android
@restingbull restingbull merged commit a43314c into bazelbuild:master Jan 8, 2021
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.

3 participants