gpt4 book ai didi

scala - 如何排除conf文件夹下的文件进行分发?

转载 作者:行者123 更新时间:2023-12-04 14:27:45 27 4
gpt4 key购买 nike

我有一个 application.dev.confapplication.test.conf下我的 conf我的 Play 2.3 应用程序中的文件夹,但我不希望它被打包为我的发行版的一部分?什么是对的excludeFilter为了它?

最佳答案

实际上 lpiepiora 的回答可以解决问题,但是请注意过滤 mappings in Universal只会排除 application.dev.conf来自 conf文件夹 而不是来自 jar 本身。

我不知道 play框架,但总的来说,如果你有这样的东西:

hello
├── src
│ └── main
│ ├── scala
│ │ └── com.world.hello
│ │ └── Main.scala
│ ├── resources
│ │ ├── application.dev.conf
│ │ └── application.conf

正在做:
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

但是,如果您查看 jar ,您会看到您的 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

这实际上并不是真的有害,但如果你也想删除它们,这里是答案: How to exclude resources during packaging with SBT but not during testing
mappings in (Compile, packageBin) ~= { _.filter(!_._1.getName.endsWith(".dev.conf")) }

关于scala - 如何排除conf文件夹下的文件进行分发?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24375624/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com