Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
lihaoyi committed Oct 25, 2024
1 parent 3b971c6 commit cc579e6
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 62 deletions.
46 changes: 2 additions & 44 deletions build.mill
Original file line number Diff line number Diff line change
Expand Up @@ -643,8 +643,7 @@ def launcherScript(
shellCommands = {
val jvmArgsStr = shellJvmArgs.mkString(" ")
def java(mainClass: String, passMillJvmOpts: Boolean) = {
val millJvmOpts = if (passMillJvmOpts) "$mill_jvm_opts" else ""
s"""exec "$$JAVACMD" $jvmArgsStr $$JAVA_OPTS $millJvmOpts -cp "${shellClassPath.mkString(
s"""exec "$$JAVACMD" $jvmArgsStr $$JAVA_OPTS -cp "${shellClassPath.mkString(
":"
)}" $mainClass "$$@""""
}
Expand All @@ -655,49 +654,19 @@ def launcherScript(
| JAVACMD="$$JAVA_HOME/bin/java"
|fi
|
|mill_jvm_opts=""
|init_mill_jvm_opts () {
| if [ -z $$MILL_JVM_OPTS_PATH ] ; then
| mill_jvm_opts_file=".mill-jvm-opts"
| else
| mill_jvm_opts_file=$$MILL_JVM_OPTS_PATH
| fi
|
| if [ -f "$$mill_jvm_opts_file" ] ; then
| # 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
|}
|
|# Client-server mode doesn't seem to work on WSL, just disable it for now
|# https://stackoverflow.com/a/43618657/871202
|if grep -qEi "(Microsoft|WSL)" /proc/version > /dev/null 2> /dev/null ; then
| init_mill_jvm_opts
| if [ -z $$COURSIER_CACHE ] ; then
| COURSIER_CACHE=.coursier
| fi
| ${java(millMainClass, true)}
|else
| if [ "$${1%"-i"*}" != "$$1" ] ; then # first arg starts with "-i"
| init_mill_jvm_opts
| ${java(millMainClass, true)}
| else
| case "$$1" in
| -i | --interactive | --repl | --no-server | --bsp )
| init_mill_jvm_opts
| ${java(millMainClass, true)}
| ;;
| *)
Expand All @@ -711,8 +680,7 @@ def launcherScript(
cmdCommands = {
val jvmArgsStr = cmdJvmArgs.mkString(" ")
def java(mainClass: String, passMillJvmOpts: Boolean) = {
val millJvmOpts = if (passMillJvmOpts) "!mill_jvm_opts!" else ""
s""""%JAVACMD%" $jvmArgsStr %JAVA_OPTS% $millJvmOpts -cp "${cmdClassPath.mkString(
s""""%JAVACMD%" $jvmArgsStr %JAVA_OPTS% -cp "${cmdClassPath.mkString(
";"
)}" $mainClass %*"""
}
Expand All @@ -726,17 +694,7 @@ def launcherScript(
|if "%1" == "--no-server" set _I_=true
|if "%1" == "--bsp" set _I_=true
|
|set "mill_jvm_opts="
|set "mill_jvm_opts_file=.mill-jvm-opts"
|if not "%MILL_JVM_OPTS_PATH%"=="" set "mill_jvm_opts_file=%MILL_JVM_OPTS_PATH%"
|
|if defined _I_ (
| if exist %mill_jvm_opts_file% (
| for /f "delims=" %%G in (%mill_jvm_opts_file%) do (
| set line=%%G
| if "!line:~0,2!"=="-X" set "mill_jvm_opts=!mill_jvm_opts! !line!"
| )
| )
| ${java(millMainClass, true)}
|) else (
| ${java(millMainClass, false)}
Expand Down
16 changes: 0 additions & 16 deletions docs/modules/ROOT/partials/Installation_IDE_Support.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -213,22 +213,6 @@ _.mill-jvm-opts_
-Dmy.jvm.property=$PWD
----

You can use this to override the Mill server working directory, e.g.
moving it from the bespoke sandbox folder to the workspace root via:

_.mill-jvm-opts_
----
-Duser.dir=$PWD
----


`.mill-jvm-opts` also supports environment variable interpolation, e.g.

_.mill-jvm-opts_
----
-Duser.dir=$PWD
----

The file name `.mill-jvm-opts` can be overridden via the `MILL_JVM_OPTS_PATH` environment
variable.

Expand Down
1 change: 0 additions & 1 deletion example/thirdparty/acyclic/.mill-jvm-opts

This file was deleted.

9 changes: 9 additions & 0 deletions example/thirdparty/acyclic/build.mill
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
package build
import mill._, scalalib._, publish._

// acyclic test suite assumes files are on disk at specific paths relative to `os.pwd`.
// To avoid changing the test code, we instead copy the necessary files into the `os.pwd`
// when preparing the resources for test suite execution
os.copy.over(
interp.watch(mill.api.WorkspaceRoot.workspaceRoot / "acyclic"),
os.pwd / "acyclic",
createFolders = true
)

object Deps {
def acyclic = ivy"com.lihaoyi:::acyclic:0.3.6"
def scalaCompiler(scalaVersion: String) = ivy"org.scala-lang:scala-compiler:$scalaVersion"
Expand Down
2 changes: 1 addition & 1 deletion main/server/src/mill/main/server/Server.scala
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ abstract class Server[T](
os.remove.all(socketPath)

val relFile = socketPath.relativeTo(os.pwd).toNIO.toFile
serverLog("listening on socket " + relFile)
serverLog("listening on socket " + relFile + " " + os.pwd)
// Use relative path because otherwise the full path might be too long for the socket API
val addr = AFUNIXSocketAddress.of(relFile)
AFUNIXServerSocket.bindOn(addr)
Expand Down
2 changes: 2 additions & 0 deletions runner/src/mill/runner/MillServerMain.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import scala.util.Try

object MillServerMain {
def main(args0: Array[String]): Unit = SystemStreams.withTopLevelSystemStreamProxy {
println("MillServerMain")
pprint.log(sys.props)
// Disable SIGINT interrupt signal in the Mill server.
//
// This gets passed through from the client to server whenever the user
Expand Down

0 comments on commit cc579e6

Please sign in to comment.