-
-
Notifications
You must be signed in to change notification settings - Fork 349
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
.mill-jvm-opts
to interpolate environment variables, add `.mi…
…ll-opts` (#3841) This PR extends `.mill-jvm-opts` to support interpolating JVM variables. This provides a bit of flexibility in allowing `$PWD` and `$USER` to be used when passing `-Dproperty=` to Mill. This could in theory be fleshed out even further to run arbitrary shell snippets, but for now I this should provide enough flexibility to meet the immediate needs. Also added a `.mill-opts`, which is similar to `.mill-jvm-opts` but used for Mill arguments rather than JVM arguments. This provides a way to persistent required Mill configuration in a format that is similar to what we already have today (CLI args). This would be a common place to put things like `--jobs=0.5C` or `--allow-positional` or `--no-build-lock`. Updated the integration tests and documentation related discussions * #1226 * #3840
- Loading branch information
Showing
15 changed files
with
145 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
|
||
# comment after an empty line | ||
-DPROPERTY_PROPERLY_SET_VIA_JVM_OPTS=value-from-file | ||
-Dproperty.properly.set.via.jvm.opts=value-from-file | ||
-Dproperty.with.interpolated.working.dir=value-with-$PWD | ||
-Xss120m |
5 changes: 5 additions & 0 deletions
5
integration/feature/mill-jvm-opts/resources/.mill-jvm-opts-alternate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
# comment after an empty line | ||
-Dproperty.properly.set.via.jvm.opts=alternate-value-from-file | ||
-Dproperty.with.interpolated.working.dir=alternate-value-with-$PWD | ||
-Xss220m |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
# comment after an empty line | ||
--jobs=17 |
3 changes: 3 additions & 0 deletions
3
integration/feature/mill-jvm-opts/resources/.mill-opts-alternate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
# comment after an empty line | ||
--jobs=29 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 34 additions & 3 deletions
37
integration/feature/mill-jvm-opts/src/MillJvmOptsTests.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,45 @@ | ||
package mill.integration | ||
|
||
import mill.main.client.Util | ||
import mill.testkit.UtestIntegrationTestSuite | ||
|
||
import utest._ | ||
|
||
object MillJvmOptsTests extends UtestIntegrationTestSuite { | ||
val tests: Tests = Tests { | ||
test("JVM options from file .mill-jvm-opts are properly read") - integrationTest { tester => | ||
test("simple") - integrationTest { tester => | ||
import tester._ | ||
val res = eval("checkJvmOpts") | ||
assert(res.isSuccess) | ||
} | ||
test("interpolatedEnvVars") - integrationTest { tester => | ||
if (!Util.isWindows) { // PWD does not exist on windows | ||
import tester._ | ||
val res = eval(("show", "getEnvJvmOpts")) | ||
val out = res.out | ||
val expected = "\"value-with-" + tester.workspacePath + "\"" | ||
assert(out == expected) | ||
} | ||
} | ||
test("alternate") - integrationTest { tester => | ||
if (!Util.isWindows) { | ||
import tester._ | ||
val res = eval( | ||
("show", "getEnvJvmOpts"), | ||
env = Map("MILL_JVM_OPTS_PATH" -> ".mill-jvm-opts-alternate") | ||
) | ||
assert(res.out == "\"alternate-value-with-" + tester.workspacePath + "\"") | ||
} | ||
} | ||
test("nonJvmOpts") - integrationTest { tester => | ||
import tester._ | ||
val res = eval(("show", "getNonJvmOpts")) | ||
assert(res.out == "17") | ||
} | ||
test("nonJvmOptsAlternate") - integrationTest { tester => | ||
import tester._ | ||
assert(eval("checkJvmOpts").isSuccess) | ||
val res = | ||
eval(("show", "getNonJvmOpts"), env = Map("MILL_OPTS_PATH" -> ".mill-opts-alternate")) | ||
assert(res.out == "29") | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.