github.com/stackb/rules_proto@v0.0.0-20240221195024-5428336c51f1/pkg/plugin/builtin/java_plugin.go (about) 1 package builtin 2 3 import ( 4 "path" 5 6 "github.com/bazelbuild/bazel-gazelle/label" 7 "github.com/stackb/rules_proto/pkg/protoc" 8 ) 9 10 func init() { 11 protoc.Plugins().MustRegisterPlugin(&JavaPlugin{}) 12 } 13 14 // JavaPlugin implements Plugin for the built-in protoc java plugin. 15 type JavaPlugin struct{} 16 17 // Name implements part of the Plugin interface. 18 func (p *JavaPlugin) Name() string { 19 return "builtin:java" 20 } 21 22 // Configure implements part of the Plugin interface. 23 func (p *JavaPlugin) Configure(ctx *protoc.PluginContext) *protoc.PluginConfiguration { 24 srcjar := path.Join(ctx.Rel, ctx.ProtoLibrary.BaseName()+".srcjar") 25 return &protoc.PluginConfiguration{ 26 Label: label.New("build_stack_rules_proto", "plugin/builtin", "java"), 27 Outputs: []string{srcjar}, 28 Out: srcjar, 29 Options: ctx.PluginConfig.GetOptions(), 30 } 31 }