-
-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Took a bit of fiddling because we had to stop using `os.Path#ext` because it only takes the last segment, and also now one of the extensions is a suffix of another. There will likely be a short tail of bugs that arise because of this, but it shouldn't be too burdensome to resolve them. Otherwise this functionality should be relatively cheap to add and maintain since we already have the extensions and file names centralized in `CodeGenConstants.java`. This is a compromise between `.mill` and `.mill.sc`. I still believe long term `.mill` is better, but I can believe that short term pain of having everything not understand your `.mill` extensions is painful. This lets people use `.mill.sc` where preferable, and `.mill` otherwise by default. I expect long term `.mill` will be superior once all the tooling has caught up, but until then people can use `.mill.sc` if they want the generic `.sc` Scala script support that many tools use. Having two extensions isn't that unusual, e.g. Bazel supports both `BUILD` and `BUILD.bazel` as file extenions, supported indefinitely. The cost of adding two extensions isn't significantly more than the cost of adding one: in any case we need to send PRs to the various tools, and a PR adding two extensions isn't any more difficult than a PR adding one. Added an example test `13-helper-files-mill-sc`, variant of `11-helper-files`, which should exercise most of the file discovery/import/codegen/etc. logic that may be impacted by the extension
- Loading branch information
Showing
80 changed files
with
873 additions
and
640 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package build | ||
import mill._, scalalib._ | ||
import $file.foo.versions | ||
import $file.util.MyModule | ||
object `package` extends RootModule with MyModule{ | ||
def forkEnv = Map( | ||
"MY_SCALA_VERSION" -> build.scalaVersion(), | ||
"MY_PROJECT_VERSION" -> versions.myProjectVersion, | ||
) | ||
} | ||
///** See Also: util.mill.sc */ | ||
///** See Also: foo/package.mill.sc */ | ||
///** See Also: foo/versions.mill.sc */ | ||
|
||
|
||
// Apart from having `package` files in subfolders to define modules, Mill | ||
// also allows you to have helper code in any `*.mill` file in the same folder | ||
// as your `build.mill` or a `package.mill`. | ||
// | ||
// Different helper scripts and ``build.mill``/``package`` files can all refer to | ||
// each other using the `build` object, which marks the root object of your build. | ||
// In this example: | ||
// | ||
// * `build.mill` can be referred to as simple `build` | ||
// * `util.mill` can be referred to as simple `$file.util` | ||
// * `foo/package` can be referred to as simple `build.foo` | ||
// * `foo/versions.mill` can be referred to as simple `$file.foo.versions` | ||
|
||
/** Usage | ||
> ./mill run | ||
Main Env build.util.myScalaVersion: 2.13.14 | ||
Main Env build.foo.versions.myProjectVersion: 0.0.1 | ||
> ./mill foo.run | ||
Foo Env build.util.myScalaVersion: 2.13.14 | ||
Foo Env build.foo.versions.myProjectVersion: 0.0.1 | ||
*/ |
10 changes: 10 additions & 0 deletions
10
example/depth/large/13-helper-files-mill-sc/foo/package.mill.sc
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,10 @@ | ||
package build.foo | ||
import mill._, scalalib._ | ||
import $file.util | ||
import $file.foo.versions.myProjectVersion | ||
object `package` extends RootModule with build_.util.MyModule { | ||
def forkEnv = Map( | ||
"MY_SCALA_VERSION" -> util.myScalaVersion, | ||
"MY_PROJECT_VERSION" -> myProjectVersion | ||
) | ||
} |
8 changes: 8 additions & 0 deletions
8
example/depth/large/13-helper-files-mill-sc/foo/src/Foo.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 |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package foo | ||
|
||
object Foo { | ||
def main(args: Array[String]): Unit = { | ||
println("Foo Env build.util.myScalaVersion: " + sys.env("MY_SCALA_VERSION")) | ||
println("Foo Env build.foo.versions.myProjectVersion: " + sys.env("MY_PROJECT_VERSION")) | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
example/depth/large/13-helper-files-mill-sc/foo/versions.mill.sc
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 @@ | ||
package build.foo | ||
|
||
def myProjectVersion = "0.0.1" |
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,6 @@ | ||
object Main { | ||
def main(args: Array[String]): Unit = { | ||
println("Main Env build.util.myScalaVersion: " + sys.env("MY_SCALA_VERSION")) | ||
println("Main Env build.foo.versions.myProjectVersion: " + sys.env("MY_PROJECT_VERSION")) | ||
} | ||
} |
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,9 @@ | ||
package build | ||
|
||
import mill._, scalalib._ | ||
|
||
def myScalaVersion = "2.13.14" | ||
|
||
trait MyModule extends ScalaModule { | ||
def scalaVersion = myScalaVersion | ||
} |
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
10 changes: 4 additions & 6 deletions
10
integration/failure/build-file-in-subfolder/src/BuildFileInSubfolderTests.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
Oops, something went wrong.