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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/main/scala/sbtprotobuf/ProtobufPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ object ProtobufPlugin extends Plugin {
lazy val protobufSettings: Seq[Setting[_]] = inConfig(protobufConfig)(Seq[Setting[_]](
sourceDirectory <<= (sourceDirectory in Compile) { _ / "protobuf" },
sourceDirectories <<= sourceDirectory apply (_ :: Nil),
includeFilter := "*.proto",
javaSource <<= (sourceManaged in Compile) { _ / "compiled_protobuf" },
externalIncludePath <<= target(_ / "protobuf_external"),
protoc := "protoc",
Expand Down Expand Up @@ -103,9 +104,9 @@ object ProtobufPlugin extends Plugin {
}

private def sourceGeneratorTask =
(streams, sourceDirectories in protobufConfig, includePaths in protobufConfig, protocOptions in protobufConfig, generatedTargets in protobufConfig, cacheDirectory, protoc) map {
(out, srcDirs, includePaths, protocOpts, otherTargets, cache, protocCommand) =>
val schemas = srcDirs.toSet[File].flatMap(srcDir => (srcDir ** "*.proto").get.map(_.getAbsoluteFile))
(streams, sourceDirectories in protobufConfig, includePaths in protobufConfig, includeFilter in protobufConfig, excludeFilter in protobufConfig, protocOptions in protobufConfig, generatedTargets in protobufConfig, cacheDirectory, protoc) map {
(out, srcDirs, includePaths, includeFilter, excludeFilter, protocOpts, otherTargets, cache, protocCommand) =>
val schemas = srcDirs.toSet[File].flatMap(srcDir => (srcDir ** (includeFilter -- excludeFilter) ).get.map(_.getAbsoluteFile))
val cachedCompile = FileFunction.cached(cache / "protobuf", inStyle = FilesInfo.lastModified, outStyle = FilesInfo.exists) { (in: Set[File]) =>
compile(protocCommand, schemas, includePaths, protocOpts, otherTargets, out.log)
}
Expand Down