Skip to content

Commit

Permalink
Merge branch 'refactor-find-root-modules' into genidea-meta
Browse files Browse the repository at this point in the history
  • Loading branch information
lefou authored Jul 14, 2023
2 parents 1dad111 + 3779e9b commit 4d381e9
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 36 deletions.
20 changes: 8 additions & 12 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
License
=======


The MIT License (MIT)
MIT License

Copyright (c) 2017 Li Haoyi ([email protected])

Expand All @@ -13,13 +9,13 @@ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
4 changes: 2 additions & 2 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ object Deps {
val scalacScoverage2Serializer =
ivy"org.scoverage::scalac-scoverage-serializer:${scoverage2Version}"
// keep in sync with doc/antora/antory.yml
val semanticDB = ivy"org.scalameta:::semanticdb-scalac:4.7.8"
val semanticDB = ivy"org.scalameta:::semanticdb-scalac:4.8.1"
val semanticDbJava = ivy"com.sourcegraph:semanticdb-java:0.8.18"
val sourcecode = ivy"com.lihaoyi::sourcecode:0.3.0"
val upickle = ivy"com.lihaoyi::upickle:3.1.0"
val utest = ivy"com.lihaoyi::utest:0.8.1"
val windowsAnsi = ivy"io.github.alexarchambault.windows-ansi:windows-ansi:0.0.5"
val zinc = ivy"org.scala-sbt::zinc:1.9.1"
val zinc = ivy"org.scala-sbt::zinc:1.9.2"
// keep in sync with doc/antora/antory.yml
val bsp4j = ivy"ch.epfl.scala:bsp4j:2.1.0-M5"
val fansi = ivy"com.lihaoyi::fansi:0.4.0"
Expand Down
71 changes: 61 additions & 10 deletions ci/mill.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ rem You can give the required mill version with --mill-version parameter
rem If no version is given, it falls back to the value of DEFAULT_MILL_VERSION
rem
rem Project page: https://github.com/lefou/millw
rem Script Version: 0.4.6
rem Script Version: 0.4.7
rem
rem If you want to improve this script, please also contribute your changes back!
rem
Expand All @@ -16,7 +16,11 @@ rem but I don't think we need to support them in 2019
setlocal enabledelayedexpansion

if [!DEFAULT_MILL_VERSION!]==[] (
set "DEFAULT_MILL_VERSION=0.10.10"
set "DEFAULT_MILL_VERSION=0.11.0"
)

if [!GITHUB_RELEASE_CDN!]==[] (
set "GITHUB_RELEASE_CDN="
)

set "MILL_REPO_URL=https://github.com/com-lihaoyi/mill"
Expand Down Expand Up @@ -55,19 +59,62 @@ if [!MILL_VERSION!]==[] (
set MILL_VERSION=%DEFAULT_MILL_VERSION%
)

set MILL_DOWNLOAD_PATH=%USERPROFILE%\.mill\download
if [!MILL_DOWNLOAD_PATH!]==[] (
set MILL_DOWNLOAD_PATH=%USERPROFILE%\.mill\download
)

rem without bat file extension, cmd doesn't seem to be able to run it
set MILL=%MILL_DOWNLOAD_PATH%\!MILL_VERSION!.bat

if not exist "%MILL%" (
set VERSION_PREFIX=%MILL_VERSION:~0,4%
# Since 0.5.0
set DOWNLOAD_SUFFIX=-assembly
if [!VERSION_PREFIX!]==[0.0.] set DOWNLOAD_SUFFIX=
if [!VERSION_PREFIX!]==[0.1.] set DOWNLOAD_SUFFIX=
if [!VERSION_PREFIX!]==[0.2.] set DOWNLOAD_SUFFIX=
if [!VERSION_PREFIX!]==[0.3.] set DOWNLOAD_SUFFIX=
if [!VERSION_PREFIX!]==[0.4.] set DOWNLOAD_SUFFIX=
# Since 0.11.0
set DOWNLOAD_FROM_MAVEN=1
if [!VERSION_PREFIX!]==[0.0.] (
set DOWNLOAD_SUFFIX=
set DOWNLOAD_FROM_MAVEN=0
)
if [!VERSION_PREFIX!]==[0.1.] (
set DOWNLOAD_SUFFIX=
set DOWNLOAD_FROM_MAVEN=0
)
if [!VERSION_PREFIX!]==[0.2.] (
set DOWNLOAD_SUFFIX=
set DOWNLOAD_FROM_MAVEN=0
)
if [!VERSION_PREFIX!]==[0.3.] (
set DOWNLOAD_SUFFIX=
set DOWNLOAD_FROM_MAVEN=0
)
if [!VERSION_PREFIX!]==[0.4.] (
set DOWNLOAD_SUFFIX=
set DOWNLOAD_FROM_MAVEN=0
)
if [!VERSION_PREFIX!]==[0.5.] (
set DOWNLOAD_FROM_MAVEN=0
)
if [!VERSION_PREFIX!]==[0.6.] (
set DOWNLOAD_FROM_MAVEN=0
)
if [!VERSION_PREFIX!]==[0.7.] (
set DOWNLOAD_FROM_MAVEN=0
)
if [!VERSION_PREFIX!]==[0.8.] (
set DOWNLOAD_FROM_MAVEN=0
)
if [!VERSION_PREFIX!]==[0.9.] (
set DOWNLOAD_FROM_MAVEN=0
)
set VERSION_PREFIX=%MILL_VERSION:~0,5%
if [!VERSION_PREFIX!]==[0.10.] (
set DOWNLOAD_FROM_MAVEN=0
)
set VERSION_PREFIX=%MILL_VERSION:~0,8%
if [!VERSION_PREFIX!]==[0.11.0-M] (
set DOWNLOAD_FROM_MAVEN=0
)
set VERSION_PREFIX=

for /F "delims=- tokens=1" %%A in ("!MILL_VERSION!") do set MILL_VERSION_BASE=%%A
Expand All @@ -82,9 +129,13 @@ if not exist "%MILL%" (
rem there seems to be no way to generate a unique temporary file path (on native Windows)
set DOWNLOAD_FILE=%MILL%.tmp

set DOWNLOAD_URL=%MILL_REPO_URL%/releases/download/!MILL_VERSION_TAG!/!MILL_VERSION!!DOWNLOAD_SUFFIX!
if [!DOWNLOAD_FROM_MAVEN]==[1] (
set DOWNLOAD_URL=https://repo1.maven.org/maven2/com/lihaoyi/mill-dist/!MILL_VERSION!/mill-dist-!MILL_VERSION!.jar
) else (
set DOWNLOAD_URL=!GITHUB_RELEASE_CDN!%MILL_REPO_URL%/releases/download/!MILL_VERSION_TAG!/!MILL_VERSION!!DOWNLOAD_SUFFIX!
)

echo Downloading mill %MILL_VERSION% from %MILL_REPO_URL%/releases ... 1>&2
echo Downloading mill %MILL_VERSION% from !DOWNLOAD_URL! ... 1>&2

if not exist "%MILL_DOWNLOAD_PATH%" mkdir "%MILL_DOWNLOAD_PATH%"
rem curl is bundled with recent Windows 10
Expand Down
2 changes: 1 addition & 1 deletion docs/antora.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ asciidoc:
mill-version: '0.11.1'
mill-last-tag: '0.11-1'
bsp-version: '2.1.0-M5'
example-semanticdb-version: '4.7.8'
example-semanticdb-version: '4.8.1'
example-scala-2-13-version: '2.13.11'
example-utest-version: '0.8.1'
11 changes: 5 additions & 6 deletions docs/modules/ROOT/pages/Installation_IDE_Support.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -290,14 +290,13 @@ Apart from downloading and installing new versions of Mill globally, there are
a few ways of selecting/updating your Mill version. This will only work, if you
have choosen one of the <<_bootstrap_scripts,Boostrap script methods>>:

* Create a `.mill-version` file to specify the version of Mill you wish to use:
* Create a `.mill-version` or `.config/mill-version` file to specify the version of Mill you wish to use:
[source,bash]
----
echo "0.5.0" > .mill-version
----

`.mill-version` takes precedence over the version of Mill specified in the
`./mill` script.
`.mill-version` takes precedence over `.config/mill-version` or the version of Mill specified in the `./mill` script.

* Pass in a `MILL_VERSION` environment variable, e.g.
[source,bash]
Expand All @@ -313,14 +312,14 @@ MILL_VERSION=0.5.0-3-4faefb ./mill __.compile
----

to override the Mill version manually. This takes precedence over the version
specified in `./mill` or `.mill-version`
specified in `./mill`, `.config/mill-version` or `.mill-version`

=== Automatic Mill updates

If your project is hosted on GitHub, GitLab, or Bitbucket, you can use
https://github.com/scala-steward-org/scala-steward[Scala Steward] to
automatically open a pull request to update your Mill version (in
`.mill-version` file), whenever there is a newer version available.
`.mill-version` or `.config/mill-version` file), whenever there is a newer version available.

TIP: Scala Steward can also
xref:Configuration.adoc#_keeping_up_to_date_with_scala_steward[scan your project dependencies]
Expand All @@ -336,6 +335,6 @@ https://github.com/com-lihaoyi/mill/releases[available] as binaries named

The easiest way to use a development release is to use one of the
<<_bootstrap_scripts>>, which support <<_overriding_mill_versions>> via an
`MILL_VERSION` environment variable or a `.mill-version` file.
`MILL_VERSION` environment variable or a `.mill-version` or `.config/mill-version` file.


10 changes: 7 additions & 3 deletions runner/src/mill/runner/MillBuildBootstrap.scala
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,11 @@ object MillBuildBootstrap {
getChildRootModule(rootModule0, depth, projectRoot)
}

def getChildRootModule(rootModule0: RootModule, depth: Int, projectRoot: os.Path) = {
def getChildRootModule(
rootModule0: RootModule,
depth: Int,
projectRoot: os.Path
): Either[String, RootModule] = {

val childRootModules: Seq[RootModule] = rootModule0
.millInternal
Expand Down Expand Up @@ -382,11 +386,11 @@ object MillBuildBootstrap {
)
}

def recRoot(projectRoot: os.Path, depth: Int) = {
def recRoot(projectRoot: os.Path, depth: Int): os.Path = {
projectRoot / Seq.fill(depth)("mill-build")
}

def recOut(projectRoot: os.Path, depth: Int) = {
def recOut(projectRoot: os.Path, depth: Int): os.Path = {
projectRoot / "out" / Seq.fill(depth)("mill-build")
}
}
3 changes: 1 addition & 2 deletions runner/src/mill/runner/RunnerState.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import mill.define.{BaseModule, Segments}
import mill.util.Watchable
import upickle.default.{ReadWriter, macroRW}
import mill.api.JsonFormatters._
import mill.eval.Evaluator
import mill.main.RootModule

/**
Expand Down Expand Up @@ -33,7 +32,7 @@ case class RunnerState(
frames: Seq[RunnerState.Frame],
errorOpt: Option[String]
) {
def add(frame: RunnerState.Frame = RunnerState.Frame.empty, errorOpt: Option[String] = None) = {
def add(frame: RunnerState.Frame = RunnerState.Frame.empty, errorOpt: Option[String] = None): RunnerState = {
this.copy(frames = Seq(frame) ++ frames, errorOpt = errorOpt)
}
}
Expand Down

0 comments on commit 4d381e9

Please sign in to comment.