-
-
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
base: main
Are you sure you want to change the base?
Changes from 43 commits
ac22329
d2ad688
39f928e
3c9f155
923ddf4
268eb63
86e1807
9991d8a
a253537
01bfcf5
8b141aa
1fd0b65
f38991b
f70e818
7e1e2b6
6f4c45d
913ef1d
ac9d657
f8d748b
4156577
f0d1378
ea780d7
b59e33f
31154ac
3d2fafe
44f6ada
802f005
39baa2d
0c9b749
3db8288
918359e
4419d7f
68d830f
7155ec8
3ef1bef
1655bb9
6b717b7
018cd53
4112c6f
40cdaa3
3cfb3aa
e66f8ee
7ed2c3a
ee28377
88c31b1
f533126
6e48c2b
2286ed0
768a2b1
cd168ff
9ee23de
87afa17
02206a6
c819207
22033e9
34b837d
729fc9d
f1bfd9a
af5454d
8794040
ca1c827
1cd32b0
d34d385
1d8011c
12e9d73
2be0d80
44c7381
8ca434a
75af776
6cac44b
c2256f8
10d2076
d0d1e39
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
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 | ||
*/ |
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 | ||
*/ |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,230 @@ | ||||||||
package mill.integration | ||||||||
|
||||||||
import mill.integration.MillInitSbtTests.{bumpSbtTo1107, initCommand} | ||||||||
import utest.* | ||||||||
|
||||||||
object MillInitSbtTests { | ||||||||
val initCommand = ("init", "--base-module", "BaseModule", "--deps-object", "Deps", "--merge") | ||||||||
def bumpSbtTo1107(workspacePath: os.Path) = | ||||||||
// bump sbt version to resolve compatibility issues with lower sbt versions and higher JDK versions | ||||||||
os.write.over(workspacePath / "project" / "build.properties", "sbt.version = 1.10.7") | ||||||||
} | ||||||||
|
||||||||
// relatively small libraries | ||||||||
|
||||||||
object MillInitLibraryExampleTests extends BuildGenTestSuite { | ||||||||
def tests: Tests = Tests { | ||||||||
/* | ||||||||
- 21 KB | ||||||||
- sbt 1.5.2 | ||||||||
*/ | ||||||||
val url = "https://github.com/scalacenter/library-example/archive/refs/tags/v1.0.1.zip" | ||||||||
|
||||||||
test - integrationTest(url) { tester => | ||||||||
import tester.* | ||||||||
|
||||||||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||||||||
assert(initResult.isSuccess) | ||||||||
|
||||||||
val compileResult = eval("compile") | ||||||||
assert(compileResult.isSuccess) | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
object MillInitScalaCsv200Tests extends BuildGenTestSuite { | ||||||||
def tests: Tests = Tests { | ||||||||
/* | ||||||||
- 34 KB | ||||||||
- originally sbt 1.10.0 | ||||||||
*/ | ||||||||
val url = "https://github.com/tototoshi/scala-csv/archive/refs/tags/2.0.0.zip" | ||||||||
|
||||||||
test - integrationTest(url) { tester => | ||||||||
import tester.* | ||||||||
|
||||||||
bumpSbtTo1107(workspacePath) | ||||||||
|
||||||||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||||||||
assert(initResult.isSuccess) | ||||||||
|
||||||||
val compileResult = eval("compile") | ||||||||
// Cross builds are not supported yet. | ||||||||
assert(!compileResult.isSuccess) | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
object MillInitScalaCsv136Tests extends BuildGenTestSuite { | ||||||||
def tests: Tests = Tests { | ||||||||
/* | ||||||||
- 28 KB | ||||||||
- originally sbt 1.2.8 | ||||||||
*/ | ||||||||
val url = "https://github.com/tototoshi/scala-csv/archive/refs/tags/1.3.6.zip" | ||||||||
|
||||||||
test - integrationTest(url) { tester => | ||||||||
import tester.* | ||||||||
|
||||||||
bumpSbtTo1107(workspacePath) | ||||||||
|
||||||||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||||||||
assert(initResult.isSuccess) | ||||||||
|
||||||||
val compileResult = eval("compile") | ||||||||
// It works here, but scala 2.11 with JDK 6 seems not supported when run with JDK 17 in shell. | ||||||||
assert(compileResult.isSuccess) | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
// same as the one in the unit tests | ||||||||
object MillInitSbtMultiProjectExampleTests extends BuildGenTestSuite { | ||||||||
def tests: Tests = Tests { | ||||||||
/* | ||||||||
- 12 KB | ||||||||
- originally sbt 1.0.2 | ||||||||
*/ | ||||||||
val url = | ||||||||
"https://github.com/pbassiner/sbt-multi-project-example/archive/152b31df9837115b183576b0080628b43c505389.zip" | ||||||||
|
||||||||
test - integrationTest(url) { tester => | ||||||||
import tester.* | ||||||||
|
||||||||
bumpSbtTo1107(workspacePath) | ||||||||
|
||||||||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||||||||
assert(initResult.isSuccess) | ||||||||
|
||||||||
val compileResult = eval("compile") | ||||||||
assert(compileResult.isSuccess) | ||||||||
|
||||||||
val compileSubmodulesResult = eval("_.compile") | ||||||||
if (System.getProperty("java.version").split('.').head.toInt <= 11) | ||||||||
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. Can use implement a 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. I have moved |
||||||||
assert(compileSubmodulesResult.isSuccess) | ||||||||
else | ||||||||
// Submodules don't compile well with JDK 17 and 21, which seems to be due to incompatible bytecode versions in dependencies. | ||||||||
assert(!compileSubmodulesResult.isSuccess) | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
// relatively large libraries | ||||||||
|
||||||||
object MillInitZioHttpTests extends BuildGenTestSuite { | ||||||||
def tests: Tests = Tests { | ||||||||
/* | ||||||||
- 1.4 MB | ||||||||
- originally sbt 1.10.0 | ||||||||
*/ | ||||||||
val url = "https://github.com/zio/zio-http/archive/refs/tags/v3.0.1.zip" | ||||||||
|
||||||||
test - integrationTest(url) { tester => | ||||||||
import tester.* | ||||||||
|
||||||||
bumpSbtTo1107(workspacePath) | ||||||||
|
||||||||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||||||||
assert(initResult.isSuccess) | ||||||||
|
||||||||
val compileResult = eval("compile") | ||||||||
assert(compileResult.isSuccess) | ||||||||
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. Apart from 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. I will resolve these after fixing #4586 (comment). 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. As expained in #4586 (comment). |
||||||||
|
||||||||
val compileSubmodulesResult = eval("_.compile") | ||||||||
// Some dependencies with currently unsupported `CrossVersion` `For3Use2_13` are not imported properly | ||||||||
assert(!compileSubmodulesResult.isSuccess) | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
// Scala.js and scala-native projects are not properly imported | ||||||||
object MillInitSbtScalazTests extends BuildGenTestSuite { | ||||||||
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. When I run this built in SBT, I see the following subprojects:
But the converted Mill code only shows:
How come the other SBT subprojects are not being converted? 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. I think it is due to this TODO which is not resolved yet: /*
TODO This does not support converting child projects nested in a parent directory which is not a project yet.
Supporting this may involve refactoring `Node[Project]` into `Node[Option[Project]]`
or adding a subproject as a direct child with its ancestor directory project (I am not sure whether this works).
*/
val input = Tree.from(projectNodesByParentDirs(None).head) { node =>
val dirs = node.dirs
val children = projectNodesByParentDirs.getOrElse(Some(dirs), Seq.empty)
(node, children)
} I will first give the latter approach "adding a subproject as a direct child with its ancestor directory project" a try. 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. While that refactoring sounds plausible, I'm not sure it's the cause here. e.g. the 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. This is fixed after the TODO is resolved. See: mill/integration/feature/init/src/MillInitSbtTests.scala Lines 195 to 197 in 44c7381
|
||||||||
def tests: Tests = Tests { | ||||||||
/* | ||||||||
- 0.8 MB | ||||||||
- sbt 1.9.7 | ||||||||
*/ | ||||||||
val url = "https://github.com/scalaz/scalaz/archive/refs/tags/v7.3.8.zip" | ||||||||
|
||||||||
test - integrationTest(url) { tester => | ||||||||
import tester.* | ||||||||
|
||||||||
os.call(("chmod", "+x", "sbt"), cwd = workspacePath) | ||||||||
|
||||||||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||||||||
assert(initResult.isSuccess) | ||||||||
|
||||||||
val compileResult = eval("compile") | ||||||||
assert(compileResult.isSuccess) | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
// Scala.js and scala-native projects are not properly imported | ||||||||
object MillInitSbtCatsTests extends BuildGenTestSuite { | ||||||||
def tests: Tests = Tests { | ||||||||
/* | ||||||||
- 1.9 MB | ||||||||
- sbt 1.10.7 | ||||||||
- MUnit | ||||||||
*/ | ||||||||
val url = "https://github.com/typelevel/cats/archive/refs/tags/v2.13.0.zip" | ||||||||
|
||||||||
test - integrationTest(url) { tester => | ||||||||
import tester.* | ||||||||
|
||||||||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||||||||
assert(initResult.isSuccess) | ||||||||
|
||||||||
val compileResult = eval("compile") | ||||||||
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. Similarly, SBT lasts the following subprojects
So how is it the Mill build only contains a subset
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. I will look into this. This might be related to #4586 (comment) too. 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. Modules without |
||||||||
assert(compileResult.isSuccess) | ||||||||
} | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
// Converting child projects nested in a parent directory which is not a project is not supported yet. | ||||||||
object MillInitSbtPlayFrameworkTests extends BuildGenTestSuite { | ||||||||
def tests: Tests = Tests { | ||||||||
// Commented out as it causes `java.util.concurrent.TimeoutException: Future timed out after [600000 milliseconds]` in the CI. | ||||||||
/* | ||||||||
/* | ||||||||
- 4.8 MB | ||||||||
- sbt 1.10.5 | ||||||||
*/ | ||||||||
val url = "https://github.com/playframework/playframework/archive/refs/tags/3.0.6.zip" | ||||||||
|
||||||||
test - integrationTest(url) { tester => | ||||||||
import tester.* | ||||||||
|
||||||||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||||||||
assert(initResult.isSuccess) | ||||||||
|
||||||||
val compileResult = eval("compile") | ||||||||
assert(compileResult.isSuccess) | ||||||||
} | ||||||||
*/ | ||||||||
} | ||||||||
} | ||||||||
|
||||||||
// Scala.js and scala-native projects are not properly imported | ||||||||
object MillInitSbtScalaCheckTests extends BuildGenTestSuite { | ||||||||
def tests: Tests = Tests { | ||||||||
/* | ||||||||
- 245 KB | ||||||||
- originally sbt 1.10.1 | ||||||||
*/ | ||||||||
val url = "https://github.com/typelevel/scalacheck/archive/refs/tags/v1.18.1.zip" | ||||||||
|
||||||||
test - integrationTest(url) { tester => | ||||||||
import tester.* | ||||||||
|
||||||||
bumpSbtTo1107(workspacePath) | ||||||||
|
||||||||
val initResult = eval(initCommand, stdout = os.Inherit, stderr = os.Inherit) | ||||||||
assert(initResult.isSuccess) | ||||||||
|
||||||||
val compileResult = eval("compile") | ||||||||
assert(compileResult.isSuccess) | ||||||||
} | ||||||||
} | ||||||||
} |
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.
These examples should also run tests and asserting on the stdout/stderr to make sure we're correctly picking up the test sources and wiring up the test suites. For the smaller examples (
library-example
andsbt-multi-project-example
) I would expect all tests to pass, for the larger examples (Scalaz, Zio) I would hope to at least have one of the test suites compiling and passingThere 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.
I have added the expected
compile
andtest
tests that succeed or fail and comments explaining why in each integration test. A summary:compile
tasks succeed, but its test module using scalaprops is not supported in conversion yet.compile
tasks succeed, but itstest
task fails as paths relative to the workspace are used in the test sources such asnew File("src/test/resources/simple.csv")
causingFileNotFoundException
.compile
andtest
tasks succeed when Mill is run with JDK 11.compile
tasks fail because common sources shared among multiple platforms (JVM, Scala.js, and Scala Native) in cross-builds are not supported in conversion yet, its tests use ScalaCheck and are not supported in conversion yet.CrossType.Pure
are not imported properly as their platform project directory names start with ".". Most other modules depend on these modules and therefore don't compile as well.compile
tasks fail for the similar reason that it's a build with multiple platforms, and its test modules are not imported as they not using any supported test library.