Commit baf1b7d
authored
Allow running standalone single-file scripts using Mill (#5820)
First pass at #5714
Initial pass, this works:
```
$ ./mill -f Foo.java run --text hello
[6972/6972] dist.run
watching processId file (expected content = 63396): /Users/lihaoyi/Github/mill/test/out/mill-no-daemon/pid-63396/processId
============================== run --text hello ==============================
[55/55] run
[55] SLF4J: No SLF4J providers were found.
[55] SLF4J: Defaulting to no-operation (NOP) logger implementation
[55] SLF4J: See https://www.slf4j.org/codes.html#noProviders for further details.
[55] <h1>hello</h1>
[55/55] ============================== run --text hello ==============================
[6972/6972] ============================== dist.run test -i -f Foo.java run --text hello ============================== 1s
```
The basic approach is
- Allow `-f`/`--file` to be passed to specify a script file to use
rather than `build.mill`
- If `-f` is passed, use an alternate shortened `MillBuildBootstrap`
process that has a single build stage with a hard-coded `RootModule`
based on the extension of the script: `mill.meta.ScriptModule.Java`,
`.Scala`, or `.Kotlin`
In the common case where someone wants to just run a script, they can
run:
```
./mill Foo.java --text hello
```
As a shorthand for the full `./mill -f Foo.java run --text hello`. We
special-case the first token ending with `.java`, `.scala`, or `.kt` to
support this. I expect this would be what people want to do with their
scripts the vast majority of the time, so it deserves its own
extra-concise syntax even if it has some theoretical overlap with
user-defined tasks ending with those names
Other notes:
- For single-file projects, we assign them a subfolder in the out folder
where all the build takes place e.g. `foo/bar/Baz.kt` gets assigned
`out/foo/bar/Baz.kt/` as its out folder. Normal tasks and modules won't
normally have `.`s in their name, so this ensures that the single-file
projects won't collide with normal module and task output files
- Some of the task outputs from `mill.javalib.publish` have been given
short-hands `upickle.Reader`s for writing them in the YAML build header.
I expect we will need to add more such shorthands in future
- Started with some basic doc sections on the per-language `intro.adoc`
and `module-config.adoc` pages touching on usage of these single-file
projects, but I expect we'll need more documentation
- For this PR, the single-file projects are entirely standalone and not
connected to any enclosing Mill build, but that may be something we can
integrate in future to allow single-file projects to define `moduleDeps`
on the enclosing `build.mill`'s modules
Tested with a example tests1 parent cbb9e8a commit baf1b7d
File tree
79 files changed
+1083
-171
lines changed- core
- constants/src/mill/constants
- internal/cli
- src/mill/internal
- example
- javalib
- basic/5-single-file
- module
- 1-single-file
- 2-common-config
- custom-resources
- custom-src
- resources
- src/foo
- 3-custom-tasks
- src/foo
- 4-generated-sources
- 5-compilation-execution-flags
- src/foo
- kotlinlib
- basic/5-single-file
- module
- 1-single-file
- 10-dependency-injection
- dagger
- src/main
- test/src
- 2-common-config
- custom-resources
- custom-src
- resources
- src/foo
- 3-custom-tasks
- src/foo
- 4-generated-sources
- 5-compilation-execution-flags
- src/foo
- scalalib
- basic/5-single-file
- module
- 1-single-file
- 2-common-config
- custom-resources
- custom-src
- resources
- src
- 3-custom-tasks
- src
- 4-generated-sources
- 5-compilation-execution-flags
- src
- libs
- javalib/src/mill/javalib/publish
- tabcomplete/test/src/mill/tabcomplete
- runner
- daemon/src/mill/daemon
- meta
- src/mill/meta
- test
- website/docs/modules/ROOT/pages
- cli
- javalib
- kotlinlib
- scalalib
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
79 files changed
+1083
-171
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
21 | 27 | | |
22 | 28 | | |
23 | 29 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| 8 | + | |
| 9 | + | |
8 | 10 | | |
9 | 11 | | |
10 | 12 | | |
| |||
84 | 86 | | |
85 | 87 | | |
86 | 88 | | |
87 | | - | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
88 | 95 | | |
89 | | - | |
| 96 | + | |
90 | 97 | | |
91 | 98 | | |
92 | 99 | | |
93 | 100 | | |
94 | 101 | | |
95 | | - | |
| 102 | + | |
96 | 103 | | |
97 | 104 | | |
98 | 105 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 12 | + | |
16 | 13 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
128 | 128 | | |
129 | 129 | | |
130 | 130 | | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
File renamed without changes.
0 commit comments