salesforce / rules_spring

Bazel rule for building Spring Boot apps as a deployable jar
BSD 3-Clause "New" or "Revised" License
224 stars 48 forks source link

Make springboot rule customizable with extension code #89

Open plaird opened 3 years ago

plaird commented 3 years ago

After we migrate the rule implementation to Java (see Issue #3) it wouldn't be hard to provide plug points for customizations. For example, we have the exclude (aka exclude_deps) attribute that is a static list of deps that should not be packaged. If a user wants to do something more custom, it would be nice if they could provide a class that implements an interface that we would invoke with a method:

boolean acceptDependency(String depName);

And other important steps in the packaging would have the same treatment like:

List<String> customizeManifest(List<String> manifestLines);

This would allow us to avoid implementing one-off requirements by users. We could just point them to this facility, and they can customize it themselves. If the customization is popular, we could then turn it into an official feature.

The rule user would need to provide the Java class(es) via a new attribute (? or think of a better solution), like:

springboot(
   ...
   extension_deps = [ "//tools/acme/springboot:acme_springboot_custom_whizbang"],
)