scabbard icon indicating copy to clipboard operation
scabbard copied to clipboard

Any chance this works with Bazel?

Open jeffzoch opened this issue 2 years ago • 4 comments

Hoping to try this out in bazel - has anyone tried this before?

jeffzoch avatar Apr 06 '22 19:04 jeffzoch

I think image generation should work fine when the annotation processor is added as java_plugin. IDE integration probably needs work, let me investigate and add official samples.

arunkumar9t2 avatar Apr 06 '22 20:04 arunkumar9t2

Thank you! I am currently trying to get image generation working myself - not sure which processor should be set as the processor_class in the java_plugin though

jeffzoch avatar Apr 06 '22 22:04 jeffzoch

I have it working with

 java_plugin(                                                                                                                                                  
     name = "scabbard",                                                                                                                                        
     visibility = ["//visibility:public"],                                                                                                                     
     deps = ["@maven//:dev_arunkumar_scabbard_processor"],  #rules_jvm_external usage                                                                                                
     javacopts = ["-Ascabbard.failOnError=true"] # or whatever                                                                                                              
 )  

and then running bazel build //path/to/your/java/library_or_binary --plugin //path/to/scabbard The source code indicates that it is written to https://docs.oracle.com/javase/7/docs/api/javax/tools/StandardLocation.html#SOURCE_OUTPUT which turns out to be bazel-bin/path/to/your/java/library_or_binary/library_or_binary-gensrc.jar Unzipping that jar shows a scabbard directory with all the output.

Obviously this means they would be included in the binary so I wouldn't run the production build with the scabbard plugin. Don't know enough bazel or scabbard to say if there's an alternate solution.

Since we're using rules_jvm_external, this also required using com.github.kittinunf.result 3.0.1 in maven.bzl as hinted in another issue.

theindexer avatar Jun 16 '22 18:06 theindexer

Thanks @theindexer

I am looking towards an official way to support this possibly with first party bazel rules. Experimented with a aspect here https://github.com/arunkumar9t2/bazel-playground/blob/main/tools/generated_sources_collector/generated_sources_collector.bzl that merges source jar for all transitive dependencies unzippping which will give you all the images.

Example

I will continue investigating how IDE can use this information.

arunkumar9t2 avatar Aug 08 '22 05:08 arunkumar9t2