-
Notifications
You must be signed in to change notification settings - Fork 460
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
Add plugin support for Bazel #76
Comments
Note to self: AFAICT, Bazel only has one build command, so we may have to choose one of |
Ah, just to correct myself, I now understand that Bazel has a |
@nedtwigg I've realised that I've not had the time and interest to pursue this further as of late. How would you like me to deal with this issue for now? |
Just upload anything you think might be useful to somebody else who might wanna do this 👍 |
Note for whoever wants to take this on: When naming the Bazel plugin, the Bazel developers recommend following these guidelines for naming it. |
Another note for whoever wants to take this on: IIUC, Spotless would need a command-line interface first, such that it could be run from the terminal without needing Gradle or Maven as an intermediary. Only then could Spotless be integrated as a Bazel "plugin" ("rule" being the correct term IIUC). |
...or, maybe I'm mistaken about needing a command-line interface! For all I know, Bazel's extension language Starlark could be powerful enough to allow Spotless to be ported. But further research would be needed. |
A colleague and I have been thinking about this a lot, and the cleanest way we've found is to start with a binary wrapper (as Jonathan suggested early on in this thread) that takes a config that specifies the same stuff you would in a Seems to me like implementing said binary wrapper would basically amount to building a command line application, so it seems silly not to expose it as such for any users who want that (even if it's not really a standard use case). Would you guys accept a well written and tested implementation of a command line application for Spotless? It might be a while before I have the time, but we'd be willing to work on such a thing. Let me know and I'll open a ticket for it. Then I'd also be willing to put in some work on this ticket after that is complete. |
Definitely! Some minor points
A broader, structural point is the "current feature matrix" in the root readme, and especially this note about it:
I am fine with adding a new column for "bazel", or a new column for "CLI", but it's even better if "bazel" piggybacks on "CLI" which somehow piggybacks on either gradle or maven. jbang is a clever project which (ab)uses gradle to smash java into single-file-scripts, might have useful lessons for a similar piggybacking. Implications of a CLI columnIf the CLI gets its own column (which is fine), there are a few questions which have obvious answers in the context of a build-system-plugin (see docs), which are not-at-all-obvious in the context of an independent CLI.
I don't know much about Bazel, but I would imagine that it has some kind of convention / opinion on these two topics. If it does, then the spirit of YAGNI might recommend that this CLI should have a package |
Thanks Ned! I've created a ticket for the CLI and I'm going to respond to your last comment there. I know there's some crossover between talking about CLI and Bazel there, but it seems mostly focused around how to design the CLI. |
This looks like the kind of thing that we'd hook into https://github.com/apple/apple_rules_lint and expose via https://github.com/bazel-contrib/rules_jvm . Doing so would allow a test target and a "fix" target to be exposed as part of the build. Can Spotless be run on a subset of the tree? Bazel targets tend to focus on a "per package" level in Java projects, and we'd want to have the same level of granularity here. |
spotless-lib lets you take a list of steps and put them together in a Defining a source tree to run on, up-to-date-checking, how you define the steps, etc. is all a concern of the plugin. |
If google-java-format issue google/google-java-format#917 ever reaches a positive conclusion, it could make porting Spotless to Bazel easier. |
Bazel is something which has interested me for a while now, so writing a Spotless plugin for it may prove to be a good way to get my feet wet with it. However I'm limited for time with my studies and I suspect I won't be able to work on something this big until late May 2017 or later.
Here's what I currently understand about Bazel with regards to plugin-writing:
spotless-lib
(or a Java binary wrapper around it) without porting it to Skylark.The text was updated successfully, but these errors were encountered: