-
-
Notifications
You must be signed in to change notification settings - Fork 382
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
Support mill init
from an existing sbt project
#4586
Open
ShreckYe
wants to merge
73
commits into
com-lihaoyi:main
Choose a base branch
from
ShreckYe:init-from-sbt
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+3,207
−137
Open
Changes from all commits
Commits
Show all changes
73 commits
Select commit
Hold shift + click to select a range
ac22329
Initially copy and adapt some code to support `mill init` from an exi…
ShreckYe d2ad688
Add a cross module for the models and split the code because Mill use…
ShreckYe 39f928e
Initially implement assembling and adding the `sbt-mill-init-generate…
ShreckYe 3c9f155
Add code to add the sbt plugin and run the `millInitGenerateProjectTr…
ShreckYe 923ddf4
Remove the files generated by sbt in "main/init/sbt/test/resources/sc…
ShreckYe 268eb63
Replace "SBT"s with lowercase "sbt"
ShreckYe 86e1807
Move the old "sbt-mill-init-generate-project-tree" Mill module and ru…
ShreckYe 9991d8a
Remove unneeded code in the generated sbt plugin project and add µTes…
ShreckYe a253537
Move `ProjectTreePlugin` into the sbt project and set up the build lo…
ShreckYe 01bfcf5
Initially complete implementing `SbtBuildGenMain` and the sbt plugin …
ShreckYe 8b141aa
Remove the unnecessary code marked with TODOs to be removed in the pr…
ShreckYe 1fd0b65
Do not diff a subproject's `BuildInfo` with `ThisBuild`'s anymore in …
ShreckYe f38991b
Move the "mill.scalalib.SbtModule" import into `SbtBuildGenMain` to f…
ShreckYe f70e818
Export and import sbt's `scalaVersion` too
ShreckYe 7e1e2b6
Exclude the Scala Standard Libraries
ShreckYe 6f4c45d
Add the https://github.com/pbassiner/sbt-multi-project-example projec…
ShreckYe 913ef1d
Generate the expected snapshots for "sbt-multi-project-example" and i…
ShreckYe ac9d657
Generate the expected snapshots for "sbt-multi-project-example" with …
ShreckYe f8d748b
Set the settings in `ThisBuild` in "sbt-multi-project-example" so the…
ShreckYe 4156577
Add POM settings in `ThisBuild` in "sbt-multi-project-example" to tes…
ShreckYe f0d1378
Stop updating the expected test sample snapshots
ShreckYe ea780d7
Copy and adapt the docs and some code for sbt from those for Gradle r…
ShreckYe b59e33f
Copy and adapt the integration tests for sbt from those for Gradle, r…
ShreckYe 31154ac
Add a TODO
ShreckYe 3d2fafe
Add the example tests, and add more and rearrange the integration tes…
ShreckYe 44f6ada
Set up sbt in the CI to fix the failing CI tests
ShreckYe 802f005
Move `setup-sbt` to `post-build-setup`
ShreckYe 39baa2d
Refine a TODO
ShreckYe 0c9b749
Merge branch 'main' into init-from-sbt
ShreckYe 3db8288
Fix compiling and test issues after the merge
ShreckYe 918359e
Split the `sbt assembly` command into a tuple, and replace `scala.sys…
ShreckYe 4419d7f
Fix calling the sbt command in the `sbtPluginJarResources` Mill task …
ShreckYe 68d830f
Get the `sbt millInitExportBuild` command to work on Windows with a w…
ShreckYe 7155ec8
Fix a bug that the exported projects are ordered differently in diffe…
ShreckYe 3ef1bef
Try fixing integration test timeout in the CI
ShreckYe 1655bb9
Fix a compiling error introduced in the previous commit
ShreckYe 6b717b7
Try fixing more integration test failures on CI, both on Linux with J…
ShreckYe 018cd53
Fix the failing example tests added in commit 3d2fafed6a2cdcbce2f8c6c…
ShreckYe 4112c6f
Run `./mill mill.scalalib.scalafmt.ScalafmtModule/reformatAll` since …
ShreckYe 40cdaa3
Add one more exception in docs from the integration test failures fix…
ShreckYe 3cfb3aa
Add `setup-sbt` in `autofix.ci` too as it fails without it
ShreckYe e66f8ee
Merge branch 'main' into init-from-sbt
ShreckYe 7ed2c3a
Fix the merge
ShreckYe ee28377
Support converting child projects nested in a parent directory which …
ShreckYe 88c31b1
Run more `compile` and `test` tasks in the submodules of part of the …
ShreckYe f533126
Reformat `GradleBuildGenMain.scala`
ShreckYe 6e48c2b
[autofix.ci] apply automated fixes
autofix-ci[bot] 2286ed0
Fix the integration tests failing on windows caused by `split('\n')`
ShreckYe 768a2b1
Fix the bug the converted sbt test modules extend `MavenTests` instea…
ShreckYe cd168ff
Update (fix) an integration test accordingly
ShreckYe 9ee23de
Try fixing Mill `test` in the converted project of `MillInitScalaCsv1…
ShreckYe 87afa17
Move the `jvmId` config arg to `BasicConfig` and support it in `SbtBu…
ShreckYe 02206a6
Support the `baseProject` config arg too in `SbtBuildGenMain` and upd…
ShreckYe c819207
Fix assertions in `MillInitSbtMultiProjectExampleTests` that fail due…
ShreckYe 22033e9
Support comparing a module's `def`'s with and extending super base mo…
ShreckYe 34b837d
Fix assertions in `MillInitSbtMultiProjectExampleTests` that fail due…
ShreckYe 729fc9d
Fix bugs introduced in commit 22033e909dd461689b374815ca4602b087b8830…
ShreckYe f1bfd9a
Fix some grammar mistakes
ShreckYe af5454d
Rename some integration tests for explicitness and consistency
ShreckYe 8794040
Update `MillInitSbtZioHttpTests` with the result and improve `testAll…
ShreckYe ca1c827
Support more `CrossVersion` types
ShreckYe 1cd32b0
Fix a warning discovered by CI `lint-autofix`
ShreckYe d34d385
Fix a warning by making a def private
ShreckYe 1d8011c
Supported converting `type, `classifier`, and `exclusions` in sbt dep…
ShreckYe 12e9d73
Run more `compile` and `test` tasks in the submodules of all the conv…
ShreckYe 2be0d80
Reformat "main/init/package.mill" as `lint-autofix` fails on CI
ShreckYe 44c7381
Add a comment
ShreckYe 8ca434a
Review the reasons why the tasks succeed or fail and improve comments…
ShreckYe 75af776
Run more `compile` and `test` tasks in `MillInitSbtScalaCheckTests`
ShreckYe 6cac44b
Merge branch 'main' into init-from-sbt
ShreckYe c2256f8
Reformat
ShreckYe 10d2076
Add some `override`s following commit 57ab8e6218f5fab869e238037edfc8d…
ShreckYe d0d1e39
Update the expected test snapshots and fix the unit tests broken by t…
ShreckYe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,23 @@ | ||
/** Usage | ||
|
||
> rm build.mill # remove any existing build file | ||
|
||
> git init . | ||
> git remote add -f origin https://github.com/scalacenter/library-example.git | ||
> git checkout v1.0.1 | ||
|
||
> ./mill init | ||
converting module library-example | ||
Dependency Dependency(com.lightbend.paradox,paradox-theme-generic,false,0.4.4,Some(paradox-theme)) with an unknown configuration "paradox-theme" is dropped. | ||
Dependency Dependency(com.lightbend.paradox,paradox-theme-generic,false,0.4.4,Some(paradox-theme)) with an unknown configuration "paradox-theme" is dropped. | ||
generated 1 Mill build file(s) | ||
removing existing Mill build files | ||
writing Mill build file to build.mill | ||
converted sbt build to Mill | ||
formatting Mill build files | ||
Formatting 1 Scala sources | ||
init completed, run "mill resolve _" to list available tasks | ||
|
||
> ./mill compile | ||
done compiling | ||
*/ |
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,25 @@ | ||
/** Usage | ||
|
||
> rm build.mill # remove any existing build file | ||
|
||
> git init . | ||
> git remote add -f origin https://github.com/tototoshi/scala-csv.git | ||
> git checkout 2.0.0 | ||
|
||
> ./mill init | ||
converting sbt build | ||
Running the added `millInitExportBuild` sbt task to export the build | ||
converting module scala-csv | ||
generated 1 Mill build file(s) | ||
removing existing Mill build files | ||
writing Mill build file to build.mill | ||
converted sbt build to Mill | ||
formatting Mill build files | ||
Formatting 1 Scala sources | ||
init completed, run "mill resolve _" to list available tasks | ||
|
||
> ./mill compile # You will have to further configure the `CrossScalaModule` for different Scala versions | ||
error: class CSVReader protected (private val lineReader: LineReader)(implicit format: CSVFormat) extends Closeable with CSVReaderCompat { | ||
error: ^ | ||
error: one error found | ||
*/ |
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,78 @@ | ||
package mill.integration | ||
|
||
import mill.testkit.IntegrationTester | ||
import utest.* | ||
|
||
val defaultInitCommand = | ||
Seq("init", "--base-module", "BaseModule", "--deps-object", "Deps", "--merge") | ||
|
||
case class SplitResolvedTasks(successful: Seq[String], failed: Seq[String]) { | ||
val all = (successful ++ failed).sorted | ||
} | ||
|
||
extension (tester: IntegrationTester) | ||
/** | ||
* @param expectedCompileTasks [[ None ]] to denote that the `resolve __.compile` task fails | ||
* @param expectedTestTasks [[ None ]] to denote that the `resolve __.test` task fails | ||
* @return | ||
*/ | ||
def testMillInit( | ||
initCommand: Seq[String] = defaultInitCommand, | ||
expectedInitResult: Boolean = true, | ||
// expectedCompileResult: Boolean, | ||
expectedCompileTasks: Option[SplitResolvedTasks], | ||
expectedTestTasks: Option[SplitResolvedTasks] | ||
) = { | ||
import tester.* | ||
|
||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||
assert(initResult.isSuccess == expectedInitResult) | ||
|
||
/* | ||
val compileResult = eval("compile") | ||
assert(compileResult.isSuccess == expectedCompileResult) | ||
*/ | ||
|
||
def testAllResolvedTasks(taskName: String, expected: Option[SplitResolvedTasks]) = { | ||
val resolveAllTasksResult = eval(("resolve", s"__.$taskName")) | ||
expected.fold( | ||
assert(!resolveAllTasksResult.isSuccess) | ||
)(expected => { | ||
assert(resolveAllTasksResult.isSuccess) | ||
val resolvedAllTasks = resolveAllTasksResult.out.linesIterator.toSeq.sorted | ||
Predef.assert( | ||
expected.all == resolvedAllTasks, | ||
s""" | ||
|expected: ${expected.all} | ||
|resolved: $resolvedAllTasks | ||
|""".stripMargin | ||
) | ||
|
||
for (task <- expected.successful) | ||
Predef.assert(eval(task).isSuccess, s"task $task failed") | ||
|
||
for (task <- expected.failed) | ||
Predef.assert(!eval(task).isSuccess, s"task $task succeeded") | ||
}) | ||
} | ||
|
||
testAllResolvedTasks("compile", expectedCompileTasks) | ||
testAllResolvedTasks("test", expectedTestTasks) | ||
} | ||
|
||
extension (module: String) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, let's use normal methods rather than extensions |
||
def compileTask: String = | ||
s"$module.compile" | ||
private def testModuleOrTask: String = | ||
s"$module.test" | ||
def testTask: String = | ||
testModuleOrTask | ||
def testModule: String = | ||
testModuleOrTask | ||
def testCompileTask: String = | ||
testModule.compileTask | ||
def testTestTask: String = | ||
testModule.testTask | ||
def allCompileTasks: Seq[String] = | ||
Seq(compileTask, testCompileTask) | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets move this to a
object InitUtils
object with static methods