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

Any chance this works with Bazel? #103

Open
jeffzoch opened this issue Apr 6, 2022 · 4 comments
Open

Any chance this works with Bazel? #103

jeffzoch opened this issue Apr 6, 2022 · 4 comments
Labels
enhancement New feature or request samples

Comments

@jeffzoch
Copy link

jeffzoch commented Apr 6, 2022

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

@arunkumar9t2
Copy link
Owner

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 arunkumar9t2 added enhancement New feature or request samples labels Apr 6, 2022
@arunkumar9t2 arunkumar9t2 added this to To do in Scabbard Development via automation Apr 6, 2022
@jeffzoch
Copy link
Author

jeffzoch commented Apr 6, 2022

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

@theindexer
Copy link

theindexer commented Jun 16, 2022

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.

@arunkumar9t2
Copy link
Owner

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request samples
Projects
Development

No branches or pull requests

3 participants