Skip to content

Commit 7c55315

Browse files
authored
scala library: warn about absent --plugins configuration (#275)
* Fix scala golden example * {proto|grpc}_scala_library: warn about empty --plugins
1 parent 10e5812 commit 7c55315

6 files changed

Lines changed: 14 additions & 9 deletions

File tree

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
BAZEL := bzl
1+
BAZEL := bazel
22

33
.PHONY: tidy
44
tidy: deps

example/golden/testdata/scala/BUILD.in

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@ exports_files(["config.yaml"])
22

33
# gazelle:proto_language scala enabled true
44
# gazelle:proto_rule proto_scala_library attr exports @com_google_protobuf//:protobuf_java
5-
# gazelle:proto_rule proto_scala_library option --plugins=protoc-gen-scala
6-
# gazelle:proto_rule grpc_scala_library option --plugins=protoc-gen-akka-grpc

example/golden/testdata/scala/BUILD.out

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,3 @@ exports_files(["config.yaml"])
22

33
# gazelle:proto_language scala enabled true
44
# gazelle:proto_rule proto_scala_library attr exports @com_google_protobuf//:protobuf_java
5-
# gazelle:proto_rule proto_scala_library option --plugins=protoc-gen-scala
6-
# gazelle:proto_rule grpc_scala_library option --plugins=protoc-gen-akka-grpc

example/golden/testdata/scala/config.yaml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ rules:
1313
implementation: stackb:rules_proto:proto_compile
1414
- name: proto_scala_library
1515
implementation: stackb:rules_proto:proto_scala_library
16-
visibility:
17-
- //visibility:public
1816
deps:
1917
- "@com_google_protobuf//:protobuf_java"
2018
- "@maven_scala//:com_thesamet_scalapb_lenses_2_12"
2119
- "@maven_scala//:com_thesamet_scalapb_scalapb_runtime_2_12"
22-
- name: grpc_scala_library
23-
implementation: stackb:rules_proto:grpc_scala_library
20+
options:
21+
- "--plugins=protoc-gen-scala"
2422
visibility:
2523
- //visibility:public
24+
- name: grpc_scala_library
25+
implementation: stackb:rules_proto:grpc_scala_library
2626
deps:
2727
- "@com_google_protobuf//:protobuf_java"
2828
- "@maven_akka//:com_lightbend_akka_grpc_akka_grpc_runtime_2_12"
@@ -35,6 +35,10 @@ rules:
3535
- "@maven_scala//:io_grpc_grpc_api"
3636
- "@maven_scala//:io_grpc_grpc_protobuf"
3737
- "@maven_scala//:io_grpc_grpc_stub"
38+
options:
39+
- "--plugins=protoc-gen-akka-grpc"
40+
visibility:
41+
- //visibility:public
3842
languages:
3943
- name: scala
4044
plugins:

example/golden/testdata/scala/syntax/BUILD.out

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ grpc_scala_library(
2424
visibility = ["//visibility:public"],
2525
deps = [
2626
":syntax_proto_scala_library",
27+
"//lib:scala",
2728
"//proto:proto_proto_scala_library",
2829
"@com_google_protobuf//:protobuf_java",
2930
"@maven_akka//:com_lightbend_akka_grpc_akka_grpc_runtime_2_12",

pkg/rule/rules_scala/scala_library.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ func (s *scalaLibrary) ProvideRule(cfg *protoc.LanguageRuleConfig, pc *protoc.Pr
8989
// the list of output files
9090
outputs := make([]string, 0)
9191

92+
if len(options.plugins) == 0 {
93+
log.Printf("warning: the rule %s should have at least one plugin name for the --plugins option. This informs the rule which plugin(s) outputs correspond to this library rule", s.Name())
94+
}
95+
9296
for _, name := range options.plugins {
9397
plugin := getPluginConfiguration(pc.Plugins, name)
9498
if plugin == nil {

0 commit comments

Comments
 (0)