I made a plugin to run it during compilation of maven modules. But since my org is now moving to bazel — Do we have a way that we can directly run plugins(mojos)in bazel?
If not, is there a way during bazel build of a java code that we can invoke another java code which has all the project info just like MavenProject
parameter in mojos?
Advertisement
Answer
It sounds like what you might want to try is a java_plugin
, which is for running annotation processors with java_binary
and java_library
:
https://docs.bazel.build/versions/master/be/java.html#java_plugin
and you specify the plugin with the plugins
attribute of java_binary
or java_library
:
https://docs.bazel.build/versions/master/be/java.html#java_binary.plugins
java_binary( name = ..., srcs = ..., deps = ..., plugins = [":my_plugin"], ) java_plugin( name = "my_plugin", srcs = ..., deps = ..., processor_class = "...", )