Skip to content

Commit e72f1d1

Browse files
authored
Revised build importer implementations (#5428)
This PR rewrites importer implementations using a new architecture that is easy to maintain and extend. ## Motivation While working on adding support for cross projects, the build models used in the existing implementations turned out to be insufficient for the use-case. This prompted work on an alternate architecture that culminated in this pull request. ## Solution New data models are introduced to define a build specification. This includes an ADT whose members have a one-to-one correspondence with module types defined within Mill. Importer implementations were updated to target the new models. ## New and dropped features - Added support for converting cross-platform and cross version SBT projects. - Added support for configuring `ErrorProneModule` for Gradle and Maven projects. - Added support for configuring `jvmId`. - Dropped support for mapping `resources`. - Redundant command line options were removed. ## Other improvements - Fixed mapping for `PomSettings` in Maven conversion. - Fixed mapping for `artifactName` in SBT conversion. - Publish is skipped for Maven modules where it is explicitly disabled. Example, `testsuite-osgi` module in [netty](https://github.com/netty/) project. - Prevent runtime failure by handling Maven `ModelBuildingException`. ## Limitations - As before, build customizations are not supported. This includes custom sources, custom Gradle configurations, and Maven profiles. - SBT cross-platform support is limited to projects using `sbt-crossproject` plugin. ## Summary of code changes The previous implementation has been completely removed. Source files for application entry points and some tests were retained, but the contents have changed. - The new shared models are housed in the `buildgen.api` module. Together with new code in `buildgen` these account for ~1300 LOC. - The new Gradle plugin is isolated in the `gradle.exportplugin` module. The Gradle importer implementation and unit tests account for ~430 and ~700 LOC, respectively. - The Maven importer implementation and unit tests account for ~500 and ~1350 LOC, respectively. - The SBT importer implementation and unit tests account for ~600 and ~2200 LOC, respectively. - The integration tests and golden files account for ~150 and ~11500 LOC, respectively. - The manual integration tests account for ~400 LOC. ## Testing - Updated integration tests to use golden testing for checking settings. - Added `integration.manual[migrating]` module to develop and test the conversions against real world projects. Summary of fixes/enhancements made to improve support for test projects. - Fixed `init` error in path handling for `spring-ai`. - Fixed `init`/configuration error by removing custom resources for `byte-buddy`/`joda-beans`. - Added `spring-boot-dependencies` BOM dependency for `microconfig`. - Generated `ErrorPluginModule` configurations for `mockito`. - Generated cross-platform/version configurations for `Airstream`, `cats`, `enumeratum`, `fs2`, `nscala-time`, `refined`, `scala-logging`, `scopt`, `scrypto`. ## Future work - Add support for converting Kotlin/Android projects. - Add support for converting SBT projects that use the `sbt-projectmatrix` plugin.
1 parent 055226c commit e72f1d1

File tree

257 files changed

+17967
-6597
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+17967
-6597
lines changed

.scalafmt.conf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ project {
2929
"glob:**/example/**/*-spotless*/**",
3030
"glob:**/javalib/test/resources/checkstyle/**",
3131
"glob:**/init/test/resources/giter8/hello.g8/src/main/g8/build.mill",
32+
"glob:**/init/gradle/test/resources/**",
33+
"glob:**/init/maven/test/resources/**",
34+
"glob:**/init/sbt/test/resources/**",
3235
"glob:**/javalib/test/resources/javalib/palantirformat/**",
3336
"glob:**/integration/failure/parse-error/**",
3437
"glob:**/testkit/test/resources/example-test-example-project/build.mill",

example/migrating/javalib/3-maven-complete-large/build.mill

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
> git remote add -f origin https://github.com/iluwatar/java-design-patterns
77
> git checkout ede37bd05568b1b8b814d8e9a1d2bbd71d9d615d
88

9-
> ./mill init --jvm-id 21 # Repo needs Java >=21 to build and test
9+
> ./mill init
10+
11+
> echo 21 > .mill-jvm-version # Repo needs Java >=21 to build and test
1012

1113
> rm twin/src/test/java/com/iluwatar/twin/BallThreadTest.java # skip flaky test
1214
> rm actor-model/src/test/java/com/iluwatar/actor/ActorModelTest.java # skip flaky test

example/migrating/javalib/4-gradle-complete/build.mill

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
> git remote add -f origin https://github.com/komamitsu/fluency.git
77
> git checkout 2.7.3 # multi-module Java project that requires Java 16+
88

9-
> ./mill init --base-module FluencyModule --jvm-id 16
9+
> ./mill init
1010
converting Gradle build
1111
...
1212
init completed, run "mill resolve _" to list available tasks

example/migrating/javalib/5-gradle-incomplete/build.mill

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44

55
> git init .
66
> git remote add -f origin https://github.com/mockito/mockito.git
7-
> git checkout v5.15.2 # multi-module Java project that requires Java 17+
7+
> git checkout v5.19.0 # multi-module Java project
88

9-
> ./mill init --base-module MockitoModule --jvm-id 17 # init ignores custom dependency configurations
9+
> ./mill init --gradle-jvm-id 17 # imported modules are not fully functional
1010
converting Gradle build
11-
ignoring errorprone dependency (com.google.errorprone,error_prone_core,2.23.0)
1211
init completed, run "mill resolve _" to list available tasks
1312

14-
> ./mill __.compile # compilation error can be by fixed by using the Mill plugin for ErrorProne
15-
error: plug-in not found: ErrorProne
13+
> ./mill mockito-core.compile # module jvmId needs tweaking
14+
error: java.lang.UnsupportedClassVersionError: com/google/errorprone/ErrorProneJavacPlugin has been compiled by a more recent version...
1615
*/

example/migrating/scalalib/2-sbt-incomplete/build.mill

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,15 @@
33
> rm build.mill # remove any existing build file
44

55
> git init .
6-
> git remote add -f origin https://github.com/tototoshi/scala-csv.git
7-
> git checkout 2.0.0
6+
> git remote add -f origin https://github.com/fthomas/refined.git
7+
> git checkout v0.11.3
88

99
> ./mill init
1010
converting sbt build
1111
...
1212
init completed, run "mill resolve _" to list available tasks
1313

14-
> ./mill compile # You will have to further configure the `CrossScalaModule` for different Scala versions
15-
compiling 7 Scala sources and 3 Java sources to ...
16-
error: class CSVReader protected (private val lineReader: LineReader)(implicit format: CSVFormat) extends Closeable with CSVReaderCompat {
17-
error: ^
18-
error: one error found
14+
> ./mill modules.core.jvm[2.12.20].compile # source roots for custom version ranges need tweaking
15+
compiling 22 Scala sources to ...
16+
error: ...object boolean is not a member of package eu.timepit.refined
1917
*/
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package mill.integration
2+
import utest.*
3+
object MillInitGradleAsmTests extends MillInitTestSuite {
4+
def tests = Tests {
5+
test - checkImport(
6+
gitUrl = "https://gitlab.ow2.org/asm/asm.git",
7+
gitBranch = "ASM_9_8",
8+
initArgs = Seq("--gradle-jvm-id", "11"),
9+
passingTasks = Seq("asm.compile"),
10+
failingTasks = Seq("tools.retrofitter.compile")
11+
)
12+
}
13+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package mill.integration
2+
import utest.*
3+
object MillInitGradleEhcache3Tests extends MillInitTestSuite {
4+
def tests = Tests {
5+
test - checkImport(
6+
gitUrl = "https://github.com/ehcache/ehcache3.git",
7+
gitBranch = "v3.10.8",
8+
initArgs = Seq("--gradle-jvm-id", "11"),
9+
failingTasks = Seq("ehcache-api.compile")
10+
)
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package mill.integration
2+
import utest.*
3+
object MillInitGradleFastCsvTests extends MillInitTestSuite {
4+
def tests = Tests {
5+
test - checkImport(
6+
gitUrl = "https://github.com/osiegmar/FastCSV.git",
7+
gitBranch = "v4.0.0",
8+
initArgs = Seq("--gradle-jvm-id", "24"),
9+
failingTasks = Seq("lib.compile")
10+
)
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package mill.integration
2+
import utest.*
3+
object MillInitGradleJCommanderTests extends MillInitTestSuite {
4+
def tests = Tests {
5+
test - checkImport(
6+
gitUrl = "https://github.com/cbeust/jcommander.git",
7+
gitBranch = "2.0",
8+
initArgs = Seq("--gradle-jvm-id", "11"),
9+
failingTasks = Seq("test.compile")
10+
)
11+
}
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
package mill.integration
2+
import utest.*
3+
object MillInitGradleMicroconfigTests extends MillInitTestSuite {
4+
def tests = Tests {
5+
test - checkImport(
6+
gitUrl = "https://github.com/microconfig/microconfig.git",
7+
gitBranch = "v4.9.5",
8+
initArgs = Seq("--merge"),
9+
passingTasks = Seq("_.test")
10+
)
11+
}
12+
}

0 commit comments

Comments
 (0)