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

Add includeFilter and excludeFilter as a posibility to decide what .proto's to generate #29

Merged
merged 1 commit into from Jan 13, 2016

Conversation

monzonj
Copy link
Contributor

@monzonj monzonj commented Apr 21, 2015

Hello
Thanks for this great plugin.

includeFilter and excludeFilter are common among plugins that generate code. In this particular case it would allow us to select what protos we want to ignore or "compile".

It's useful especially when having dependencies with a number of protos but we are only interested in only a few. Also when some libraries contain protos and also the java classes and we do not want to re-compile them in order to avoid duplicates in our classpath

An example (that I already use) would be:

(excludeFilter in PB.protobufConfig) := "value-types.proto" || "documentation.proto"

That would include all protos except "value-types.proto" and "documentation.proto"

The default setup doesn't modify the existing filter. This is: "*.proto"

For more information about include and exclude filter, please have a look to: http://www.scala-sbt.org/0.13/docs/Howto-Customizing-Paths.html#Include%2Fexclude+files+in+the+source+directory

Regards

…e what protobufs to use in the code generation
@monzonj
Copy link
Contributor Author

monzonj commented Apr 21, 2015

By they way. This pull request does not include an update to README.MD. Let me know if you consider it important to document (it's kind of expected behaviour, though)

@thesamet
Copy link
Collaborator

The change looks pretty straightforward, will it be possible to merge it?

@iphydf
Copy link

iphydf commented Nov 16, 2015

What is blocking this?

@xuwei-k
Copy link
Member

xuwei-k commented Jan 5, 2016

+1

@gseitz gseitz merged commit dbf8a8a into sbt:master Jan 13, 2016
eed3si9n added a commit to eed3si9n/sbt-protobuf that referenced this pull request Mar 5, 2024
**Problem**
When compiling complex protobuf schema, you often
run into a situation where you need some external
schema during the compilation, but you don't
necessarily want to include the resulting Java
output as your own output because there's already
a precompiled or well-known bytecode version of
the class.
A good example of this is classes under com/google/protobuf,
but there are others as well.

In theory sbt#29 has added excludeFilter support,
but in practice sbt's file filter doesn't work
for directory name matching.

**Solution**
This reimplements the protobuf file filtering
using the new Glob, which can match directory names.

As a demonstration, `protobufExcludeFilters` is
initialized to glob `Glob(d.toPath()) / "google" / "protobuf" / "*.proto"`.
This will filter out protobuf sources which
are precompiled in "com.google.protobuf" % "protobuf-java".
@eed3si9n eed3si9n mentioned this pull request Mar 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants