实际上 lpiepiora 的答案可以解决问题,但请注意过滤mappings in Universal
只会排除application.dev.conf
来自conf
folder 而不是来自罐子本身。
我不知道play
框架,但一般来说,如果你有这样的东西:
hello
├── src
│ └── main
│ ├── scala
│ │ └── com.world.hello
│ │ └── Main.scala
│ ├── resources
│ │ ├── application.dev.conf
│ │ └── application.conf
Doing:
mappings in (Universal, ) ++= {
((resourceDirectory in Compile).value * "*").get.filterNot(f => f.getName.endsWith(".dev.conf")).map { f =>
f -> s"conf/${f.name}"
}
}
将产生以下包结构:
hello/
├── lib
│ └── com.world.hello-1234-SNAPSHOT.jar
├── conf
│ └── application.conf
然而,如果你观察罐子,你会发现你的dev.conf
文件仍然在那里:
$ unzip -v com.world.hello-1234-SNAPSHOT.jar
Archive: com.world.hello-1234-SNAPSHOT.jar
Length Method Size Cmpr Date Time CRC-32 Name
-------- ------ ------- ---- ---------- ----- -------- ----
371 Defl:N 166 55% 10-01-2018 15:20 36c30a78 META-INF/MANIFEST.MF
0 Stored 0 0% 10-01-2018 15:20 00000000 com/
0 Stored 0 0% 10-01-2018 15:20 00000000 com/world/
0 Stored 0 0% 10-01-2018 15:20 00000000 com/world/hello/
0 Stored 0 0% 10-01-2018 15:20 00000000 com/world/hello/
13646 Defl:N 4361 68% 10-01-2018 12:06 7e2dce2f com/world/hello/Main$.class
930 Defl:N 445 52% 10-01-2018 13:57 5b180d92 application.conf
930 Defl:N 445 52% 10-01-2018 13:57 5b180d92 application.dev.conf
这实际上并不是真正有害,但如果您也想删除它们,答案如下:如何在使用 SBT 打包期间排除资源,但在测试期间不排除资源 https://stackoverflow.com/questions/20491505/how-to-exclude-resources-during-packaging-with-sbt-but-not-during-testing
mappings in (Compile, packageBin) ~= { _.filter(!_._1.getName.endsWith(".dev.conf")) }