sbt to exclude source directory

1,126 views
Skip to first unread message

TH Lim

unread,
Sep 10, 2011, 9:57:29 AM9/10/11
to simple-build-tool
Hi,

I like to obsolete my Java sources and leave them in its default
directory, src/main/java and exclude them from compilation. How do I
config build.sbt to exclude src/main/java directory? Also, can I
exclude a file or group of files specify with RE. Can these be easily
configured in build.sbt?

Thanks

Frédérick Dubois

unread,
Sep 10, 2011, 2:56:09 PM9/10/11
to simple-b...@googlegroups.com
Hi,

Well, there might be a better way but I'd add this to my build.sbt:

javaSource in Compile := file("some/path/that/doesnt/exist")

-Fred

> --
> You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
> To post to this group, send email to simple-b...@googlegroups.com.
> To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.
>
>

Mark Harrah

unread,
Sep 11, 2011, 9:03:10 PM9/11/11
to simple-b...@googlegroups.com

For direct control over the source directories used, you can directly define the unmanagedSourceDirectories task, which produces a valud of type Seq[File].

For example, if you only want the src/main/scala directory:

unmanagedSourceDirectories in Compile <<= baseDirectory(base =>
(base / "src" / "main" / "scala") :: Nil
)

There is basic support for glob filters. See Paths[1]. Also, there is PatternFilter[2], which accepts a java.util.regex.Pattern. The settings to configure are sourceFilter to define the sources that should be included and/or defaultExcludes to exclude sources:

sourceFilter in unmanagedSources := "*.java" | "*.scala"

defaultExcludes in unmanagedSources := "*Test.java"

(In 0.11.0, these names are deprecated in favor of includeFilter and excludeFilter for consistency with resource and classpath filters.)

-Mark

[1] https://github.com/harrah/xsbt/wiki/Paths
[2] http://harrah.github.com/xsbt/latest/api/sbt/PatternFilter.html

Reply all
Reply to author
Forward
0 new messages