Yi EungJun 2015-03-03
build: Fix a bug that conf directory is ignored
Problem: When using a Standalone distribution created by Playframework
2, config files, application.conf and application-logger.xml, in conf
directory are ignored because the distribution has config files in jar
file and use them instead of conf directory.

Solution: Add some lines of shell script into the startup script to set
config files explicitly by "-Dconfig.file" and "-Dlogger.file" so that
Yobi uses them.
@8e00b08f9942b59b725e615d951d9529071342e0
build.sbt
--- build.sbt
+++ build.sbt
@@ -73,6 +73,15 @@
 mappings in Universal :=
     (mappings in Universal).value.filterNot { case (_, file) => file.startsWith("conf/") }
 
+NativePackagerKeys.bashScriptExtraDefines += """# Added by build.sbt
+    |YOBI_HOME=$(cd "$(realpath "$(dirname "$(realpath "$0")")")/.."; pwd -P)
+    |
+    |yobi_config_file="$YOBI_HOME"/conf/application.conf
+    |yobi_log_config_file="$YOBI_HOME"/conf/application-logger.xml
+    |[ -f "$yobi_config_file" ] && addJava "-Dconfig.file=$yobi_config_file"
+    |[ -f "$yobi_log_config_file" ] && addJava "-Dlogger.file=$yobi_log_config_file"
+    |""".stripMargin
+
 lazy val yobi = (project in file("."))
       .enablePlugins(PlayScala)
       .enablePlugins(SbtWeb)
Add a comment
List