Setting `unmanagedResourceDirectories` breaks depl

2020-03-31 03:33发布

问题:

I have a little bit odd setup. My Java sources are located at /src

There are .properties files next to some Java classes. I want them to be packaged to final jar.

Scala sources and resources follow SBT convention and are located at /srcnew/main/[scala|resources]

Here is how my build.scala looks like

sourceDirectory := baseDirectory.value / "srcnew",
unmanagedResourceDirectories in Compile := Seq(baseDirectory.value / "src"),
includeFilter in unmanagedResources := "*.properties",
javaSource in Compile := baseDirectory.value / "src",

Even though resourceDirectory still points to /srcnew/main/resources resources don't make it to final jar (built with sbt-assembly).

I also tried

unmanagedResourceDirectories  := Seq(baseDirectory.value / "src", baseDirectory.value / "srcnew/main/resources"),

and surprisingly it doesn't help either.

回答1:

Turned out that problem was in line

includeFilter in unmanagedResources := "*.properties"

instead it should be

includeFilter in unmanagedResources := ((includeFilter in unmanagedResources).value || "*.properties") -- "*.java",

the only thing I don't understand is why filter on unmanagedResources affects resourceDirectory. Does anyone know ?



标签: scala sbt