Skip to content
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

Move run-targets into RunModule #3090

Merged
merged 14 commits into from
Mar 26, 2024
34 changes: 29 additions & 5 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ object Deps {
def scalaCompiler(scalaVersion: String) = ivy"org.scala-lang:scala-compiler:${scalaVersion}"
// last scalafmt release supporting Java 8 is 3.7.15
val scalafmtDynamic = ivy"org.scalameta::scalafmt-dynamic:3.7.15" // scala-steward:off
def scalap(scalaVersion: String) = ivy"org.scala-lang:scalap:${scalaVersion}"
def scalaReflect(scalaVersion: String) = ivy"org.scala-lang:scala-reflect:${scalaVersion}"
val scalacScoveragePlugin = ivy"org.scoverage:::scalac-scoverage-plugin:1.4.11"
val scoverage2Version = "2.1.0"
Expand Down Expand Up @@ -448,7 +449,7 @@ trait MillStableScalaModule extends MillPublishScalaModule with Mima {
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalanativelib.ScalaNativeModule.mill$scalanativelib$ScalaNativeModule$$super$zincAuxiliaryClassFileExtensions"
),
// (7x) See https://github.com/com-lihaoyi/mill/pull/3064
// (6x) See https://github.com/com-lihaoyi/mill/pull/3064
// Moved targets up in trait hierarchy, but also call them via super, which I think is safe
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$zincWorker"
Expand All @@ -459,9 +460,6 @@ trait MillStableScalaModule extends MillPublishScalaModule with Mima {
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$runUseArgsFile"
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule#JavaModuleTests.mill$scalalib$JavaModule$JavaModuleTests$$super$testClasspath"
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$forkArgs"
),
Expand All @@ -470,6 +468,32 @@ trait MillStableScalaModule extends MillPublishScalaModule with Mima {
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$forkWorkingDir"
),
// (8x)
// Moved targets up in trait hierarchy, but also call them via super, which I think is safe
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$localRunClasspath"
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$runLocal"
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$run"
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$doRunBackground"
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$runBackgroundLogToConsole"
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$runMainBackground"
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$runMainLocal"
),
ProblemFilter.exclude[ReversedMissingMethodProblem](
"mill.scalalib.JavaModule.mill$scalalib$JavaModule$$super$runMain"
)
)
def mimaPreviousVersions: T[Seq[String]] = Settings.mimaBaseVersions
Expand Down Expand Up @@ -740,7 +764,7 @@ object scalalib extends MillStableScalaModule {

object worker extends MillPublishScalaModule with BuildInfo {
def moduleDeps = Seq(scalalib.api)
def ivyDeps = Agg(Deps.zinc, Deps.log4j2Core)
def ivyDeps = Agg(Deps.zinc, Deps.log4j2Core, Deps.scalap(scalaVersion()))
def buildInfoPackageName = "mill.scalalib.worker"
def buildInfoObjectName = "Versions"
def buildInfoMembers = Seq(
Expand Down
2 changes: 1 addition & 1 deletion example/basic/4-builtin-commands/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ foo.artifactName
/** Usage

> mill inspect foo.run
foo.run(JavaModule.scala:...)
foo.run(RunModule.scala:...)
Runs this module's code in a subprocess and waits for it to finish
Inputs:
foo.finalMainClass
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ object DocAnnotationsTests extends IntegrationTestSuite {

assert(
globMatches(
"""core.run(JavaModule.scala:...)
"""core.run(RunModule.scala:...)
| Runs this module's code in a subprocess and waits for it to finish
|
| args <str>...
Expand Down
11 changes: 11 additions & 0 deletions scalalib/api/src/mill/scalalib/api/ZincWorkerApi.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,9 @@ trait ZincWorkerApi {
auxiliaryClassFileExtensions = Seq.empty[String]
)

/**
* Find main classes by inspecting the Zinc compilation analysis file.
*/
def discoverMainClasses(compilationResult: CompilationResult): Seq[String]

def docJar(
Expand All @@ -153,4 +156,12 @@ trait ZincWorkerApi {
scalacPluginClasspath: Agg[PathRef],
args: Seq[String]
)(implicit ctx: ZincWorkerApi.Ctx): Boolean

/**
* Discover main classes by inspecting the classpath.
*/
def discoverMainClasses(classpath: Seq[os.Path]): Seq[String] = {
// We need this default-impl to keep binary compatinility (0.11.x)
Seq.empty
}
}
Loading