I have a application.dev.conf
and application.test.conf
under my conf
folder in my Play 2.3 application but I do not want it to be packaged as part of my distribution? What is the right excludeFilter
for it?
Actually lpiepiora's answer will do the trick, however note that filtering on mappings in Universal
will only exclude application.dev.conf
from the conf
folder and NOT from the jar itself.
I don't know about the play
framework but in general if you have something like this:
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}"
}
}
would produce the following package structure:
hello/
├── lib
│ └── com.world.hello-1234-SNAPSHOT.jar
├── conf
│ └── application.conf
However if you look into the jar, you will see that your dev.conf
file is still in there:
$ 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
This is actually not really harmful but if you want to remove them too, here is the answer: How to exclude resources during packaging with SBT but not during testing
mappings in (Compile, packageBin) ~= { _.filter(!_._1.getName.endsWith(".dev.conf")) }
You could use mappings
to exclude both files.
mappings in Universal := {
val origMappings = (mappings in Universal).value
origMappings.filterNot { case (_, file) => file.endsWith("application.dev.conf") || file.endsWith("application.test.conf") }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With