thesamet/sbt-protoc

ProtocPlugin should not activate for all projects in a multi-project build

jeffrey-aguilera opened this issue ยท 5 comments

override def trigger: PluginTrigger = allRequirements

should be replaced with

override def trigger: PluginTrigger = noTrigger

(or just deleted, as noTrigger is the default).

projectSettings has side-effects (e.g., creating directories) and so it should not be called unless the plugin has been explicitly enabled.

(This is especially annoying when using AkkaGrpcPlugin, which does not auto-activate; but its dependency on ProtocPlugin triggers a project-wide activation.)

Hi @jeffrey-aguilera , thanks for the feedback, since this would be a breaking change, I would be hesitant to do this. Can you clarify how the current behavior negatively impacts your project, as the default behavior of the plugin is no-op unless PB.targets is set.

Updated: I see that you mentioned side-effects such as directory creation - we could certainly look into the side effects and eliminate if there are no targets defined.

The observable difference is the creation of all the output directories; logging errors for projects that do not use protobuf; and incorrect plugins listing in sbt.

For instance, I have a stream of errors like:

/Users/jaguilera/KariusDx/karius/project/com.kariusdx.invoicing-grpc/main/proto: warning: directory does not exist.
/Users/jaguilera/KariusDx/karius/project/com.kariusdx/main/protobuf: warning: directory does not exist.
/Users/jaguilera/KariusDx/karius/project/com.kariusdx.invoicing/main/protobuf: warning: directory does not exist.
/Users/jaguilera/KariusDx/karius/project/com.kariusdx.rendering/main/protobuf: warning: directory does not exist.
/Users/jaguilera/KariusDx/karius/project/com.kariusdx.salesforce/main/protobuf: warning: directory does not exist.
/Users/jaguilera/KariusDx/karius/project/com.kariusdx.actors/main/protobuf: warning: directory does not exist.
/Users/jaguilera/KariusDx/karius/project/com.kariusdx.http/main/protobuf: warning: directory does not exist.
/Users/jaguilera/KariusDx/karius/project/com.google-protobuf/main/proto: warning: directory does not exist.
/Users/jaguilera/KariusDx/karius/project/com.kariusdx.s3/main/protobuf: warning: directory does not exist.
/Users/jaguilera/KariusDx/karius/project/com.kariusdx.mail/main/protobuf: warning: directory does not exist.

(many more ... I have a large monorepo with about 10 protobuf projects and 100+ non-protobuf)

I believe the warnings are printed when a project that defines in PB.targets dependsOn a project that doesn't have a src/main/protobuf. The new version, 1.0.0-RC4 filters out non-existing directories before passing them to protoc. Also, it wouldn't create directories unnecessarily. Can you try out 1.0.0-RC4 and report if there are any side-effects remaining?

I come here with the same problem.
I can confirm 1.0.0-RC4 doesn't have this issue ๐Ÿ‘
Thanks Samet

I believe the issue is resolved at this point. Don't hesitate to leave further comments if there are any undesirable side effects for projects without PB.targets