Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed reading of .mill-jvm-opts file #1929

Merged
merged 2 commits into from
Jul 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -1016,9 +1016,7 @@ def launcherScript(
| if [ -f "$$mill_jvm_opts_file" ] ; then
| while IFS= read line
| do
| case $$line in
| "-X"*) mill_jvm_opts="$${mill_jvm_opts} $$line"
| esac
| mill_jvm_opts="$${mill_jvm_opts} $$(echo $$line | grep -v "^[[:space:]]*[#]")"
| done <"$$mill_jvm_opts_file"
| mill_jvm_opts="$${mill_jvm_opts} -Dmill.jvm_opts_applied=true"
| fi
Expand Down
1 change: 1 addition & 0 deletions integration/forked-server/src/forked-server-tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package forked.server
object DocAnnotationsTests extends DocAnnotationsTests(fork = true, clientServer = true)
object HygieneTests extends HygieneTests(fork = true, clientServer = true)
object LargeProjectTests extends LargeProjectTests(fork = true, clientServer = true)
object MillJvmOptsTests extends MillJvmOptsTests(fork = true, clientServer = true)
object ScriptsInvalidationTests extends ScriptsInvalidationTests(fork = true, clientServer = true)
object ScriptsInvalidationForeignTests extends ScriptsInvalidationForeignTests(fork = true, clientServer = true)
object ZincIncrementalCompilationTests extends ZincIncrementalCompilationTests(fork = true, clientServer = true)
1 change: 1 addition & 0 deletions integration/forked/src/forked-tests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ package forked
object DocAnnotationsTests extends DocAnnotationsTests(fork = true, clientServer = false)
object HygieneTests extends HygieneTests(fork = true, clientServer = false)
object LargeProjectTests extends LargeProjectTests(fork = true, clientServer = false)
object MillJvmOptsTests extends MillJvmOptsTests(fork = true, clientServer = false)
object ScriptsInvalidationTests extends ScriptsInvalidationTests(fork = true, clientServer = false)
object ScriptsInvalidationForeignTests extends ScriptsInvalidationForeignTests(fork = true, clientServer = false)
object ZincIncrementalCompilationTests extends ZincIncrementalCompilationTests(fork = true, clientServer = false)
3 changes: 3 additions & 0 deletions integration/local/resources/mill-jvm-opts/.mill-jvm-opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@

# comment after an empty line
-DPROPERTY_PROPERLY_SET_VIA_JVM_OPTS=value-from-file
7 changes: 7 additions & 0 deletions integration/local/resources/mill-jvm-opts/build.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import mill._

def checkJvmOpts() = T.command {
val prop = System.getProperty("PROPERTY_PROPERLY_SET_VIA_JVM_OPTS")
if (prop != "value-from-file") sys.error("jvm-opts not correctly applied, value was: " + prop)
()
}
14 changes: 14 additions & 0 deletions integration/local/src/MillJvmOptsTests.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package mill.integration

import mill.util.ScriptTestSuite
import utest._

class MillJvmOptsTests(fork: Boolean, clientServer: Boolean)
extends IntegrationTestSuite("mill-jvm-opts", fork, clientServer) {
val tests = Tests {
initWorkspace()
"JVM options from file .mill-jvm-opts are properly read" - {
assert(eval("checkJvmOpts"))
}
}
}
2 changes: 1 addition & 1 deletion main/client/src/mill/main/client/MillEnv.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ static List<String> readMillJvmOpts() {
) {
while (sc.hasNextLine()) {
String arg = sc.nextLine();
if (!arg.trim().isEmpty() && arg.startsWith("#")) {
if (!arg.trim().isEmpty() && !arg.startsWith("#")) {
vmOptions.add(arg);
}
}
Expand Down