Skip to content

Commit e6d04a2

Browse files
authored
Fix main class discovery for KotlinModule (#4797)
Fixes #4772 Previously it inherited the Zinc-based main class discovery via `JavaModule`, which overrode the generic classpath-scanning approach from `RunModule`. This PR adjusts the overrides such the `KotlinModule` uses the disk-based discovery API. Removed all the now-unnecessary `def mainClass` annotations in the kotlinlib example tests, except for the one in `example/kotlinlib/module/1-common-config` that is useful for educational purposes. @lefou do you know what the difference between the two implementations is? I'm wondering what the Zinc-based approach gives us, or whether we can just standardize on the disk-based approach that seems like it should work for all JVM languages
1 parent f35464c commit e6d04a2

File tree

19 files changed

+5
-36
lines changed

19 files changed

+5
-36
lines changed

example/kotlinlib/basic/1-simple/build.mill

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import mill._, kotlinlib._
66
object foo extends KotlinModule {
77
def kotlinVersion = "1.9.24"
88

9-
def mainClass = Some("foo.FooKt")
10-
119
def ivyDeps = Seq(
1210
ivy"com.github.ajalt.clikt:clikt-jvm:4.4.0",
1311
ivy"org.jetbrains.kotlinx:kotlinx-html-jvm:0.11.0"

example/kotlinlib/basic/3-multi-module/build.mill

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ trait MyModule extends KotlinModule {
1313
}
1414

1515
object foo extends MyModule {
16-
def mainClass = Some("foo.FooKt")
1716
def moduleDeps = Seq(bar)
1817
def ivyDeps = Seq(
1918
ivy"com.github.ajalt.clikt:clikt-jvm:4.4.0"

example/kotlinlib/basic/6-realistic/build.mill

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ trait MyModule extends KotlinModule with PublishModule {
2828
object foo extends MyModule {
2929
def moduleDeps = Seq(bar, qux)
3030

31-
def mainClass = Some("foo.FooKt")
32-
3331
def generatedSources = Task {
3432
os.write(
3533
Task.dest / "Version.kt",

example/kotlinlib/dependencies/1-ivy-deps/build.mill

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ object `package` extends RootModule with KotlinModule {
66

77
def kotlinVersion = "1.9.24"
88

9-
def mainClass = Some("foo.FooKt")
10-
119
def ivyDeps = Seq(
1210
ivy"com.fasterxml.jackson.core:jackson-databind:2.13.4"
1311
)

example/kotlinlib/dependencies/3-unmanaged-jars/build.mill

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ object `package` extends RootModule with KotlinModule {
66

77
def kotlinVersion = "1.9.24"
88

9-
def mainClass = Some("foo.FooKt")
10-
119
def unmanagedClasspath = Task {
1210
if (!os.exists(moduleDir / "lib")) Seq()
1311
else Seq.from(os.list(moduleDir / "lib").map(PathRef(_)))

example/kotlinlib/dependencies/4-downloading-unmanaged-jars/build.mill

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ object `package` extends RootModule with KotlinModule {
66

77
def kotlinVersion = "1.9.24"
88

9-
def mainClass = Some("foo.FooKt")
10-
119
def unmanagedClasspath = Task {
1210
os.write(
1311
Task.dest / "fastjavaio.jar",

example/kotlinlib/dependencies/5-repository-config/build.mill

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@ val sonatypeReleases = Seq(
1111

1212
object foo extends KotlinModule {
1313

14-
def mainClass = Some("foo.FooKt")
15-
1614
def kotlinVersion = "1.9.24"
1715

1816
def ivyDeps = Seq(

example/kotlinlib/module/2-custom-tasks/build.mill

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ object `package` extends RootModule with KotlinModule {
66

77
def kotlinVersion = "1.9.24"
88

9-
def mainClass = Some("foo.FooKt")
10-
119
def ivyDeps = Seq(ivy"com.github.ajalt.clikt:clikt-jvm:4.4.0")
1210

1311
def generatedSources: T[Seq[PathRef]] = Task {

example/kotlinlib/module/3-override-tasks/build.mill

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ object foo extends KotlinModule {
66

77
def kotlinVersion = "1.9.24"
88

9-
def mainClass = Some("foo.FooKt")
10-
119
def sources = Task {
1210
os.write(
1311
Task.dest / "Foo.kt",

example/kotlinlib/module/4-compilation-execution-flags/build.mill

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ object `package` extends RootModule with KotlinModule {
66

77
def kotlinVersion = "1.9.24"
88

9-
def mainClass = Some("foo.FooKt")
10-
119
def forkArgs = Seq("-Xmx4g", "-Dmy.jvm.property=hello")
1210
def forkEnv = Map("MY_ENV_VAR" -> "WORLD")
1311

0 commit comments

Comments
 (0)