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

Kill mill.modules package #2513

Merged
merged 7 commits into from
May 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion bsp/src/mill/bsp/BSP.scala
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import mill.{Agg, T, BuildInfo => MillBuildInfo}
import mill.define.{Command, Discover, ExternalModule, Task}
import mill.eval.Evaluator
import mill.main.{BspServerHandle, BspServerResult, BspServerStarter}
import mill.modules.Util.millProjectModule
import mill.util.Util.millProjectModule
import mill.scalalib.{CoursierModule, Dep}
import mill.util.PrintLogger
import os.Path
Expand Down
2 changes: 1 addition & 1 deletion bsp/worker/src/mill/bsp/worker/MillScalaBuildServer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import ch.epfl.scala.bsp4j.{
}
import mill.{Agg, T}
import mill.api.internal
import mill.modules.Jvm
import mill.util.Jvm
import mill.scalalib.{JavaModule, ScalaModule, SemanticDbJavaModule, TestModule}
import mill.testrunner.TestRunner
import sbt.testing.Fingerprint
Expand Down
17 changes: 10 additions & 7 deletions build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ object Deps {

val jgraphtCore = ivy"org.jgrapht:jgrapht-core:1.4.0" // 1.5.0+ dont support JDK8

val jline = ivy"org.jline:jline:3.21.0"
val jna = ivy"net.java.dev.jna:jna:5.13.0"
val jnaPlatform = ivy"net.java.dev.jna:jna-platform:5.13.0"

Expand Down Expand Up @@ -665,7 +666,10 @@ object main extends MillModule {

object api extends MillApiModule with BuildInfo with MillAutoTestSetup {
def buildInfoPackageName = "mill.api"
def buildInfoMembers = Seq(BuildInfo.Value("millVersion", millVersion(), "Mill version."))
def buildInfoMembers = Seq(
BuildInfo.Value("millVersion", millVersion(), "Mill version."),
BuildInfo.Value("millDocUrl", Settings.docUrl, "Mill documentation url.")
)
override def ivyDeps = Agg(
Deps.osLib,
Deps.upickle,
Expand All @@ -675,9 +679,10 @@ object main extends MillModule {
)
}
object util extends MillApiModule with MillAutoTestSetup {
override def moduleDeps = Seq(api)
override def moduleDeps = Seq(api, client)
override def ivyDeps = Agg(
Deps.fansi
Deps.coursier,
Deps.jline
)
}
object define extends MillModule with BuildInfo {
Expand All @@ -687,9 +692,8 @@ object main extends MillModule {
)
override def ivyDeps = Agg(
Deps.millModuledefs,
Deps.millModuledefsPlugin,
// Deps.millModuledefsPlugin,
Deps.scalametaTrees,
Deps.coursier,
// Necessary so we can share the JNA classes throughout the build process
Deps.jna,
Deps.jnaPlatform,
Expand Down Expand Up @@ -719,8 +723,7 @@ object main extends MillModule {
"millScalacPluginDeps",
Deps.millModuledefsString,
"Scalac compiler plugin dependencies to compile the build script."
),
BuildInfo.Value("millDocUrl", Settings.docUrl, "Mill documentation url.")
)
)
}

Expand Down
78 changes: 58 additions & 20 deletions ci/mill-bootstrap.patch
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
diff --git a/build.sc b/build.sc
index 5d071823cd..be020eb125 100644
index 0311fdf8b5..eefefd4ded 100644
--- a/build.sc
+++ b/build.sc
@@ -19,17 +19,18 @@ import com.github.lolgab.mill.mima.{
Expand All @@ -11,9 +11,10 @@ index 5d071823cd..be020eb125 100644
import mill.main.MainModule
import mill.scalalib._
import mill.scalalib.publish._
import mill.modules.Jvm
-import mill.modules.Jvm
-import mill.define.SelectMode
-
+import mill.util.Jvm
+import mill.resolve.SelectMode
+import $ivy.`com.lihaoyi::mill-contrib-buildinfo:`
+import mill.contrib.buildinfo.BuildInfo
Expand All @@ -25,7 +26,7 @@ index 5d071823cd..be020eb125 100644
import mill.api.{Logger, Result}
import os.{CommandResult, SubprocessException}

@@ -164,12 +165,8 @@ object Deps {
@@ -165,12 +166,8 @@ object Deps {
val requests = ivy"com.lihaoyi::requests:0.8.0"
}

Expand All @@ -40,7 +41,7 @@ index 5d071823cd..be020eb125 100644
def millBinPlatform: T[String] = T {
val tag = millLastTag()
if (tag.contains("-M")) tag
@@ -218,8 +215,8 @@ val buildBridgeScalaVersions =
@@ -219,8 +216,8 @@ val buildBridgeScalaVersions =
if (!buildAllCompilerBridges) Seq()
else bridgeScalaVersions

Expand All @@ -51,7 +52,7 @@ index 5d071823cd..be020eb125 100644
def scalaVersion = crossScalaVersion
def publishVersion = bridgeVersion
def artifactName = T { "mill-scala-compiler-bridge" }
@@ -238,239 +235,25 @@ class BridgeModule(val crossScalaVersion: String) extends PublishModule with Cro
@@ -239,239 +236,25 @@ class BridgeModule(val crossScalaVersion: String) extends PublishModule with Cro
def generatedSources = T {
import mill.scalalib.api.ZincWorkerUtil.{grepJar, scalaBinaryVersion}
val resolvedJars = resolveDeps(
Expand Down Expand Up @@ -296,7 +297,7 @@ index 5d071823cd..be020eb125 100644
def commonPomSettings(artifactName: String) = {
PomSettings(
description = artifactName,
@@ -524,27 +307,8 @@ trait MillCoursierModule extends CoursierModule {
@@ -525,27 +308,8 @@ trait MillCoursierModule extends CoursierModule {
)
}

Expand Down Expand Up @@ -325,7 +326,7 @@ index 5d071823cd..be020eb125 100644
}

/** A Module compiled with applied Mill-specific compiler plugins: mill-moduledefs. */
@@ -855,7 +619,9 @@ object scalajslib extends MillModule with BuildInfo {
@@ -858,7 +622,9 @@ object scalajslib extends MillModule with BuildInfo {
override def ivyDeps = Agg(Deps.sbtTestInterface)
}
object worker extends Cross[WorkerModule]("1")
Expand All @@ -336,7 +337,7 @@ index 5d071823cd..be020eb125 100644
def testDepPaths = T { Seq(compile().classes) }
override def moduleDeps = Seq(scalajslib.`worker-api`, main.client, main.api)
override def ivyDeps = Agg(
@@ -919,8 +685,10 @@ object contrib extends MillModule {
@@ -922,8 +688,10 @@ object contrib extends MillModule {

object api extends MillPublishModule

Expand All @@ -349,7 +350,7 @@ index 5d071823cd..be020eb125 100644
override def sources = T.sources {
// We want to avoid duplicating code as long as the Play APIs allow.
// But if newer Play versions introduce incompatibilities,
@@ -1083,8 +851,10 @@ object scalanativelib extends MillModule {
@@ -1086,8 +854,10 @@ object scalanativelib extends MillModule {
override def ivyDeps = Agg(Deps.sbtTestInterface)
}
object worker extends Cross[WorkerModule]("0.4")
Expand All @@ -362,7 +363,7 @@ index 5d071823cd..be020eb125 100644
def testDepPaths = T { Seq(compile().classes) }
override def moduleDeps = Seq(scalanativelib.`worker-api`)
override def ivyDeps = scalaNativeWorkerVersion match {
@@ -1203,7 +973,10 @@ trait IntegrationTestModule extends MillScalaModule {
@@ -1206,7 +976,10 @@ trait IntegrationTestModule extends MillScalaModule {
}
}

Expand All @@ -374,7 +375,7 @@ index 5d071823cd..be020eb125 100644
object local extends ModeModule
object fork extends ModeModule
object server extends ModeModule
@@ -1217,15 +990,15 @@ object example extends MillScalaModule {
@@ -1220,15 +993,15 @@ object example extends MillScalaModule {

def moduleDeps = Seq(integration)

Expand All @@ -398,7 +399,7 @@ index 5d071823cd..be020eb125 100644
def sources = T.sources()
def testRepoRoot: T[PathRef] = T.source(millSourcePath)
def compile = example.compile()
@@ -1275,7 +1048,7 @@ object example extends MillScalaModule {
@@ -1278,7 +1051,7 @@ object example extends MillScalaModule {
val title =
if (seenCode) ""
else {
Expand All @@ -407,7 +408,7 @@ index 5d071823cd..be020eb125 100644
val exampleDashed = examplePath.segments.mkString("-")
val download = s"{mill-download-url}/$label-$exampleDashed.zip[download]"
val browse = s"{mill-example-url}/$examplePath[browse]"
@@ -1306,9 +1079,9 @@ object example extends MillScalaModule {
@@ -1309,9 +1082,9 @@ object example extends MillScalaModule {
}

object integration extends MillScalaModule {
Expand All @@ -420,8 +421,39 @@ index 5d071823cd..be020eb125 100644

def moduleDeps = Seq(scalalib, scalajslib, scalanativelib, runner.test)

@@ -1636,8 +1409,8 @@ object dev extends MillModule {
mill.modules.Jvm.createJar(Agg(), mill.modules.Jvm.JarManifest(manifestEntries))
@@ -1390,7 +1163,7 @@ def launcherScript(
val millMainClass = "mill.main.client.MillClientMain"
val millClientMainClass = "mill.main.client.MillClientMain"

- mill.modules.Jvm.universalScript(
+ Jvm.universalScript(
shellCommands = {
val jvmArgsStr = shellJvmArgs.mkString(" ")
def java(mainClass: String, passMillJvmOpts: Boolean) = {
@@ -1565,7 +1338,7 @@ object dev extends MillModule {
}

override def assemblyRules = super.assemblyRules ++ Seq(
- mill.modules.Assembly.Rule.ExcludePattern("mill/local-test-overrides/.*")
+ mill.scalalib.Assembly.Rule.ExcludePattern("mill/local-test-overrides/.*")
)

lazy val allPublishModules = build.millInternal.modules.collect {
@@ -1585,7 +1358,7 @@ object dev extends MillModule {
val shellArgs = Seq("-DMILL_CLASSPATH=$0") ++ commonArgs
val cmdArgs = Seq(""""-DMILL_CLASSPATH=%~dpnx0"""") ++ commonArgs
os.move(
- Jvm.createAssembly(
+ mill.scalalib.Assembly.createAssembly(
devRunClasspath,
prependShellScript = launcherScript(
shellArgs,
@@ -1636,16 +1409,16 @@ object dev extends MillModule {
"Created-By" -> "Scala mill",
"Class-Path" -> classpath
)
- mill.modules.Jvm.createJar(Agg(), mill.modules.Jvm.JarManifest(manifestEntries))
+ Jvm.createJar(Agg(), Jvm.JarManifest(manifestEntries))
}

- def run(args: String*) = T.command {
Expand All @@ -431,7 +463,13 @@ index 5d071823cd..be020eb125 100644
case Nil => mill.api.Result.Failure("Need to pass in cwd as first argument to dev.run")
case wd0 +: rest =>
val wd = os.Path(wd0, T.workspace)
@@ -1664,67 +1437,11 @@ object docs extends Module {
os.makeDir.all(wd)
- try mill.modules.Jvm.runSubprocess(
+ try Jvm.runSubprocess(
Seq(launcher().path.toString) ++ rest,
forkEnv(),
workingDir = wd
@@ -1667,67 +1440,11 @@ object docs extends Module {
def moduleDeps = build.millInternal.modules.collect { case m: MillApiModule => m }

def unidocSourceUrl = T {
Expand Down Expand Up @@ -500,7 +538,7 @@ index 5d071823cd..be020eb125 100644
private val npmExe = if (scala.util.Properties.isWin) "npm.cmd" else "npm"
private val antoraExe = if (scala.util.Properties.isWin) "antora.cmd" else "antora"
def npmBase: T[os.Path] = T.persistent { T.dest }
@@ -1777,7 +1494,7 @@ object docs extends Module {
@@ -1780,7 +1497,7 @@ object docs extends Module {

val contribReadmes = T.traverse(contrib.contribModules)(m =>
T.task {
Expand All @@ -509,7 +547,7 @@ index 5d071823cd..be020eb125 100644
}
)()

@@ -2009,7 +1726,7 @@ def exampleZips: Target[Seq[PathRef]] = T {
@@ -2012,7 +1729,7 @@ def exampleZips: Target[Seq[PathRef]] = T {
examplePath = exampleMod.millSourcePath
} yield {
val example = examplePath.subRelativeTo(T.workspace)
Expand All @@ -518,7 +556,7 @@ index 5d071823cd..be020eb125 100644
os.copy(examplePath, T.dest / exampleStr, createFolders = true)
os.copy(bootstrapLauncher().path, T.dest / exampleStr / "mill")
val zip = T.dest / s"$exampleStr.zip"
@@ -2019,51 +1736,10 @@ def exampleZips: Target[Seq[PathRef]] = T {
@@ -2022,51 +1739,10 @@ def exampleZips: Target[Seq[PathRef]] = T {
}

def uploadToGithub(authKey: String) = T.command {
Expand Down Expand Up @@ -571,7 +609,7 @@ index 5d071823cd..be020eb125 100644
ev.withFailFast(false),
Seq(
"__.compile",
@@ -2076,7 +1752,8 @@ def validate(ev: Evaluator): Command[Unit] = T.command {
@@ -2079,7 +1755,8 @@ def validate(ev: Evaluator): Command[Unit] = T.command {
"docs.localPages"
),
selectMode = SelectMode.Separated
Expand Down
3 changes: 2 additions & 1 deletion contrib/jmh/src/mill/contrib/jmh/JmhModule.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package mill.contrib.jmh

import mill._, scalalib._, modules._
import mill._, scalalib._
import mill.util.Jvm

/**
* This module provides an easy way to integrate <a href="https://openjdk.org/projects/code-tools/jmh/">JMH</a> benchmarking with Mill.
Expand Down
2 changes: 1 addition & 1 deletion contrib/playlib/src/mill/playlib/RouterModule.scala
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package mill.playlib

import mill.api.PathRef
import mill.modules.Util.millProjectModule
import mill.util.Util.millProjectModule
import mill.playlib.api.RouteCompilerType
import mill.scalalib._
import mill.scalalib.api._
Expand Down
2 changes: 1 addition & 1 deletion contrib/proguard/src/mill/contrib/proguard/Proguard.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import mill.java9rtexport.Export
import mill.T
import mill.Agg
import mill.api.{Loose, PathRef}
import mill.modules.Jvm
import mill.util.Jvm
import mill.scalalib.{DepSyntax, ScalaModule}
import os.{Path, Shellable}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package mill.contrib.proguard
import scala.util.control.NonFatal
import mill._
import mill.define.Target
import mill.modules.Util.millProjectModule
import mill.util.Util.millProjectModule
import mill.scalalib.ScalaModule
import mill.util.TestEvaluator
import mill.util.TestUtil
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import mill.contrib.scoverage.api.ScoverageReportWorkerApi.ReportType
import mill.scalalib.api.ZincWorkerUtil
import mill.scalalib.{Dep, DepSyntax, JavaModule, ScalaModule}
import mill.api.Result
import mill.modules.Util.millProjectModule
import mill.util.Util.millProjectModule

import scala.util.Try

Expand Down
2 changes: 1 addition & 1 deletion contrib/testng/test/src/mill/testng/TestNGTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package testng

import mill.api.Result.Exception
import mill.define.Target
import mill.modules.Util.millProjectModule
import mill.util.Util.millProjectModule
import mill.scalalib._
import mill.util.{TestEvaluator, TestUtil}
import utest.framework.TestPath
Expand Down
2 changes: 1 addition & 1 deletion example/scalamodule/10-assembly-config/build.sc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mill._, scalalib._
import mill.modules.Assembly._
import mill.scalalib.Assembly._

object foo extends ScalaModule {
def moduleDeps = Seq(bar)
Expand Down
4 changes: 2 additions & 2 deletions integration/thirdparty/ammonite/repo/build.sc
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ trait AmmDependenciesResourceFileModule extends JavaModule {
val deps0 = T.task {
compileIvyDeps().map(bindDependency()) ++ transitiveIvyDeps()
}()
val (_, res) = mill.modules.Jvm.resolveDependenciesMetadata(
val (_, res) = mill.util.Jvm.resolveDependenciesMetadata(
repositoriesTask(),
deps0.map(_.dep),
deps0.filter(_.force).map(_.dep),
Expand Down Expand Up @@ -206,7 +206,7 @@ class MainModule(val crossScalaVersion: String) extends AmmModule
externalSources()

def prependShellScript = T {
mill.modules.Jvm.launcherUniversalScript(
mill.scalalib.Jvm.launcherUniversalScript(
mainClass().get,
Agg("$0"),
Agg("%~dpnx0"),
Expand Down
2 changes: 1 addition & 1 deletion integration/thirdparty/caffeine/repo/build.sc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mill._
import mill.scalalib._
import coursier.MavenRepository
import mill.modules.Jvm
import mill.util.Jvm
import $file.deps
import deps.{
benchmarkLibraries,
Expand Down
2 changes: 1 addition & 1 deletion main/eval/test/src/mill/eval/JavaCompileJarTests.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package mill.eval

import mill.modules.Jvm
import mill.util.Jvm
import mill.api.Ctx.Dest
import mill.{Module, T}
import mill.util.{DummyLogger, TestEvaluator, TestUtil}
Expand Down
2 changes: 1 addition & 1 deletion main/src/mill/main/MainModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ trait MainModule extends mill.Module {

val allDocs =
for (a <- annots.distinct)
yield mill.modules.Util.cleanupScaladoc(a.value).map("\n " + _).mkString
yield mill.util.Util.cleanupScaladoc(a.value).map("\n " + _).mkString

pprint.Tree.Lazy(ctx =>
Iterator(
Expand Down
2 changes: 1 addition & 1 deletion main/src/mill/main/VisualizeModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import coursier.maven.MavenRepository
import mill.T
import mill.define.{Discover, ExternalModule}
import mill.api.{PathRef, Result}
import mill.modules.Util.millProjectModule
import mill.util.Util.millProjectModule

object VisualizeModule extends ExternalModule with VisualizeModule {
def repositories = Seq(
Expand Down
Loading