Skip to content

Commit

Permalink
Reworked .mill-jvm-opts reader to support files without final newli…
Browse files Browse the repository at this point in the history
…ne (#2162)

Reworked `.mill-jvm-opts` reader in shell script prepended to the mill assembly jar.

I tried to keep POSIX shell compatibility, hence it's a bit lenghty.

Fix #2140

Pull request: #2162
  • Loading branch information
lefou authored Dec 2, 2022
1 parent 8fc3638 commit 3a63870
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -1161,10 +1161,20 @@ def launcherScript(
| fi
|
| if [ -f "$$mill_jvm_opts_file" ] ; then
| while IFS= read line
| do
| mill_jvm_opts="$${mill_jvm_opts} $$(echo $$line | grep -v "^[[:space:]]*[#]")"
| done <"$$mill_jvm_opts_file"
| # We need to append a newline at the end to fix
| # https://github.com/com-lihaoyi/mill/issues/2140
| newline="
|"
| mill_jvm_opts="$$(
| echo "$$newline" | cat "$$mill_jvm_opts_file" - | (
| while IFS= read line
| do
| mill_jvm_opts="$${mill_jvm_opts} $$(echo $$line | grep -v "^[[:space:]]*[#]")"
| done
| # we are in a sub-shell, so need to return it explicitly
| echo "$${mill_jvm_opts}"
| )
| )"
| mill_jvm_opts="$${mill_jvm_opts} -Dmill.jvm_opts_applied=true"
| fi
|}
Expand Down Expand Up @@ -1515,7 +1525,6 @@ object docs extends Module {
}

def assembly = T {

val version = millVersion()
val devRunClasspath = dev.runClasspath().map(_.path)
val filename = if (scala.util.Properties.isWin) "mill.bat" else "mill"
Expand Down

0 comments on commit 3a63870

Please sign in to comment.