scala - Filtering resources in SBT -
scala - Filtering resources in SBT -
i trying setup sbt compile existing project not utilize maven directory structure. using full configuration , have set javasource & resourcedirectory settings follows:
def settings = defaults.defaultsettings ++ seq( resourcedirectory in compile <<= basedirectory( _ / "java" ), javasource in compile <<= basedirectory( _ / "java" ) ) now want able filter resources include in jar artifact, ant, plus exclude .java files our resources mixed in source code. example:
<fileset dir="java" includes="**/*.txt, **/*.csv" excludes="**/*.java" /> is there way this?
use defaultexcludes scoped unmanagedresources task , optionally configuration. example, setting excludes .java files main resources:
defaultexcludes in compile in unmanagedresources := "*.java" in compile restricts setting apply main resources. using in test instead, apply test resources. omitting configuration (that is, no in compile or in test), setting apply both main , test resources.
in unmanagedresources applies these excludes resources only. apply excludes sources, example, scope in unmanagedsources. reason unmanaged part emphasize these apply unmanaged (or manually edited) sources only.
the defaultexcludes key has type sbt.filefilter, setting value must of type. in illustration above, "*.java" implicitly converted filefilter. * interpreted wildcard , filter accepts files name ends in '.java'. combine filters, utilize || , &&. example, if .scala files needed excluded well, argument := be:
"*.java" || "*.scala" in original ant fileset, include , exclude filters select mutually exclusive sets of files, 1 necessary.
it possible straight build seq[file] unmanagedresources. example:
unmanagedresources in compile <<= unmanagedresourcedirectories in compile map { (dirs: seq[file]) => ( dirs ** ("*.txt" || "*.csv" -- "*.java") ).get } the ** method selects descendents match filefilter argument. can verify files selected expect running show unmanaged-resources.
scala sbt
Comments
Post a Comment