sbt-protobuf icon indicating copy to clipboard operation
sbt-protobuf copied to clipboard

add `protobufExcludePaths` setting key

Open clairemcginty opened this issue 4 years ago • 1 comments

It would be helpful to have a protobufExcludePaths setting key. Example use case: excluding conflicting schema definitions from multiple external sources. The granularity would probably be best at the individual file level (not directory). happy to contribute this if others are in favor of this feature!

clairemcginty avatar Oct 25 '21 18:10 clairemcginty

sbt's unmanagedSource looks like this:

https://github.com/sbt/sbt/blob/v1.5.5/main/src/main/scala/sbt/Defaults.scala#L590-L603

    unmanagedSources / fileInputs := {
      val include = (unmanagedSources / includeFilter).value
      val filter = (unmanagedSources / excludeFilter).value match {
        // Hidden files are already filtered out by the FileStamps method
        case NothingFilter | HiddenFileFilter => include
        case exclude                          => include -- exclude
      }
      val baseSources =
        if (sourcesInBase.value) Globs(baseDirectory.value.toPath, recursive = false, filter) :: Nil
        else Nil
      unmanagedSourceDirectories.value
        .map(d => Globs(d.toPath, recursive = true, filter)) ++ baseSources
    },
    unmanagedSources := (unmanagedSources / inputFileStamps).value.map(_._1.toFile),

This allows include and exclude filtering, and and it automatically registers the inputs to watch ~.

eed3si9n avatar Oct 25 '21 22:10 eed3si9n

Here's my PR for this - https://github.com/sbt/sbt-protobuf/pull/175

eed3si9n avatar Mar 05 '24 08:03 eed3si9n