diff --git a/contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBModule.scala b/contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBModule.scala index 9cc26aca5bb..85b978d1725 100644 --- a/contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBModule.scala +++ b/contrib/scalapblib/src/mill/contrib/scalapblib/ScalaPBModule.scala @@ -52,7 +52,7 @@ trait ScalaPBModule extends ScalaModule { def scalaPBProtocPath: T[Option[String]] = T { None } - def scalaPBSources: Sources = T.sources { + def scalaPBSources: T[Seq[PathRef]] = T.sources { millSourcePath / "protobuf" } diff --git a/contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala b/contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala index 96988026c95..a760ad7097c 100644 --- a/contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala +++ b/contrib/scalapblib/test/src/mill/contrib/scalapblib/TutorialTests.scala @@ -46,7 +46,7 @@ object TutorialTests extends TestSuite { object TutorialWithSpecificSources extends TutorialBase { object core extends TutorialModule { - override def scalaPBSources: Sources = T.sources { + override def scalaPBSources: T[Seq[PathRef]] = T.sources { millSourcePath / "protobuf" / "tutorial" / "Tutorial.proto" } diff --git a/contrib/scoverage/src/mill/contrib/scoverage/ScoverageModule.scala b/contrib/scoverage/src/mill/contrib/scoverage/ScoverageModule.scala index 19010ada4ca..af34bb5a576 100644 --- a/contrib/scoverage/src/mill/contrib/scoverage/ScoverageModule.scala +++ b/contrib/scoverage/src/mill/contrib/scoverage/ScoverageModule.scala @@ -186,7 +186,7 @@ trait ScoverageModule extends ScalaModule { outer: ScalaModule => * The persistent data dir used to store scoverage coverage data. * Use to store coverage data at compile-time and by the various report targets. */ - def data: Persistent[PathRef] = T.persistent { + def data: T[PathRef] = T.persistent { // via the persistent target, we ensure, the dest dir doesn't get cleared PathRef(T.dest) } @@ -195,14 +195,14 @@ trait ScoverageModule extends ScalaModule { outer: ScalaModule => override def allSources: Target[Seq[PathRef]] = T { outer.allSources() } override def moduleDeps: Seq[JavaModule] = outer.moduleDeps override def compileModuleDeps: Seq[JavaModule] = outer.compileModuleDeps - override def sources: Sources = T.sources { outer.sources() } - override def resources: Sources = T.sources { outer.resources() } + override def sources: T[Seq[PathRef]] = T.sources { outer.sources() } + override def resources: T[Seq[PathRef]] = T.sources { outer.resources() } override def scalaVersion = T { outer.scalaVersion() } override def repositoriesTask: Task[Seq[Repository]] = T.task { outer.repositoriesTask() } - override def compileIvyDeps: Target[Loose.Agg[Dep]] = T { outer.compileIvyDeps() } - override def ivyDeps: Target[Loose.Agg[Dep]] = + override def compileIvyDeps: Target[Agg[Dep]] = T { outer.compileIvyDeps() } + override def ivyDeps: Target[Agg[Dep]] = T { outer.ivyDeps() ++ outer.scoverageRuntimeDeps() } - override def unmanagedClasspath: Target[Loose.Agg[PathRef]] = T { outer.unmanagedClasspath() } + override def unmanagedClasspath: Target[Agg[PathRef]] = T { outer.unmanagedClasspath() } /** Add the scoverage scalac plugin. */ override def scalacPluginIvyDeps: Target[Loose.Agg[Dep]] = diff --git a/contrib/twirllib/src/mill/twirllib/TwirlModule.scala b/contrib/twirllib/src/mill/twirllib/TwirlModule.scala index 5822b468fbb..367cccc5e61 100644 --- a/contrib/twirllib/src/mill/twirllib/TwirlModule.scala +++ b/contrib/twirllib/src/mill/twirllib/TwirlModule.scala @@ -19,7 +19,7 @@ trait TwirlModule extends mill.Module { twirlModule => */ def twirlScalaVersion: T[String] - def twirlSources: Sources = T.sources { + def twirlSources: T[Seq[PathRef]] = T.sources { millSourcePath / "views" } diff --git a/contrib/versionfile/src/mill/contrib/versionfile/VersionFileModule.scala b/contrib/versionfile/src/mill/contrib/versionfile/VersionFileModule.scala index 07bb4805a6b..e157fb193fa 100644 --- a/contrib/versionfile/src/mill/contrib/versionfile/VersionFileModule.scala +++ b/contrib/versionfile/src/mill/contrib/versionfile/VersionFileModule.scala @@ -5,33 +5,33 @@ import mill._, scalalib._ trait VersionFileModule extends Module { /** The file containing the current version. */ - def versionFile: Source = T.source(millSourcePath / "version") + def versionFile: T[PathRef] = T.source(millSourcePath / "version") /** The current version. */ def currentVersion: T[Version] = T { Version.of(os.read(versionFile().path).trim) } /** The release version. */ - def releaseVersion = T { currentVersion().asRelease } + def releaseVersion: T[Version] = T { currentVersion().asRelease } /** The next snapshot version. */ - def nextVersion(bump: String) = T.command { currentVersion().asSnapshot.bump(bump) } + def nextVersion(bump: String): Task[Version] = T.task { currentVersion().asSnapshot.bump(bump) } /** Writes the release version to file. */ - def setReleaseVersion = T { + def setReleaseVersion(): Command[Unit] = T.command { setVersionTask(releaseVersion)() } /** Writes the next snapshot version to file. */ - def setNextVersion(bump: String) = T.command { + def setNextVersion(bump: String): Command[Unit] = T.command { setVersionTask(nextVersion(bump))() } /** Writes the given version to file. */ - def setVersion(version: Version) = T.command { - setVersionTask(T.task { version })() + def setVersion(version: Task[Version]): Command[Unit] = T.command { + setVersionTask(version)() } - protected def setVersionTask(version: T[Version]) = T.task { + protected def setVersionTask(version: Task[Version]) = T.task { T.log.info(generateCommitMessage(version())) writeVersionToFile(versionFile(), version()) } diff --git a/contrib/versionfile/test/src/mill/contrib/versionfile/VersionFileModuleTests.scala b/contrib/versionfile/test/src/mill/contrib/versionfile/VersionFileModuleTests.scala index 84dc6df837a..f7a72d3887d 100644 --- a/contrib/versionfile/test/src/mill/contrib/versionfile/VersionFileModuleTests.scala +++ b/contrib/versionfile/test/src/mill/contrib/versionfile/VersionFileModuleTests.scala @@ -1,5 +1,6 @@ package mill.contrib.versionfile +import mill.T import mill.api.Result import mill.util.{TestEvaluator, TestUtil} import utest.{TestSuite, Tests, assert, assertMatch, intercept, test} @@ -114,7 +115,7 @@ object VersionFileModuleTests extends TestSuite { test("setReleaseVersion") - workspaceTest(versions: _*) { eval => val expected = eval(TestModule.versionFile.releaseVersion) - val write = eval(TestModule.versionFile.setReleaseVersion) + val write = eval(TestModule.versionFile.setReleaseVersion()) val actual = eval(TestModule.versionFile.currentVersion) assert(expected.value == actual.value) } @@ -129,7 +130,7 @@ object VersionFileModuleTests extends TestSuite { test("setVersion") - workspaceTest(versions: _*) { eval => val expected = Version.Release(1, 2, 4) - val write = eval(TestModule.versionFile.setVersion(expected)) + val write = eval(TestModule.versionFile.setVersion(T.task(expected))) val actual = eval(TestModule.versionFile.currentVersion) assert(actual.value == Right(expected)) } diff --git a/integration/feature/gen-idea/repo/extended/build.sc b/integration/feature/gen-idea/repo/extended/build.sc index c16e441f758..a97df418fe3 100644 --- a/integration/feature/gen-idea/repo/extended/build.sc +++ b/integration/feature/gen-idea/repo/extended/build.sc @@ -1,8 +1,8 @@ import $ivy.`org.scalameta::munit:0.7.29` +import mill._ import mill.api.PathRef import mill.scalalib -import mill.define.Command import mill.scalalib.GenIdeaModule._ import mill.scalalib.TestModule @@ -18,8 +18,8 @@ trait HelloWorldModule extends scalalib.ScalaModule { override def scalaVersion = "3.0.2" } - def ideaJavaModuleFacets(ideaConfigVersion: Int): Command[Seq[JavaFacet]] = - T.command { + def ideaJavaModuleFacets(ideaConfigVersion: Int): Task[Seq[JavaFacet]] = + T.task { ideaConfigVersion match { case 4 => Seq( @@ -47,7 +47,7 @@ trait HelloWorldModule extends scalalib.ScalaModule { override def ideaConfigFiles( ideaConfigVersion: Int - ): Command[Seq[IdeaConfigFile]] = T.command { + ): Task[Seq[IdeaConfigFile]] = T.task { ideaConfigVersion match { case 4 => Seq( @@ -59,7 +59,7 @@ trait HelloWorldModule extends scalalib.ScalaModule { ), // components in project file IdeaConfigFile( - name = "compiler.xml", + os.sub / "compiler.xml", component = "AjcSettings", config = Seq( Element( @@ -69,7 +69,7 @@ trait HelloWorldModule extends scalalib.ScalaModule { ) ), IdeaConfigFile( - name = "compiler.xml", + os.sub / "compiler.xml", component = "CompilerConfiguration", config = Seq( Element( diff --git a/main/resolve/src/mill/resolve/ParseArgs.scala b/main/resolve/src/mill/resolve/ParseArgs.scala index 75f069a735e..c6659b649eb 100644 --- a/main/resolve/src/mill/resolve/ParseArgs.scala +++ b/main/resolve/src/mill/resolve/ParseArgs.scala @@ -7,16 +7,6 @@ import mill.util.EitherOps import scala.annotation.tailrec -sealed trait SelectMode -object SelectMode { - - /** All args are treated as targets or commands. If a `--` is detected, subsequent args are parameters to all commands. */ - object Multi extends SelectMode - - /** Like a combination of [[Single]] and [[Multi]], behaving like [[Single]] but using a special separator (`++`) to start parsing another target/command. */ - object Separated extends SelectMode -} - object ParseArgs { type TargetsWithParams = (Seq[(Option[Segments], Segments)], Seq[String]) diff --git a/main/resolve/src/mill/resolve/SelectMode.scala b/main/resolve/src/mill/resolve/SelectMode.scala new file mode 100644 index 00000000000..03e43a97ace --- /dev/null +++ b/main/resolve/src/mill/resolve/SelectMode.scala @@ -0,0 +1,12 @@ +package mill.resolve + +sealed trait SelectMode + +object SelectMode { + + /** All args are treated as targets or commands. If a `--` is detected, subsequent args are parameters to all commands. */ + object Multi extends SelectMode + + /** Like a combination of [[Single]] and [[Multi]], behaving like [[Single]] but using a special separator (`++`) to start parsing another target/command. */ + object Separated extends SelectMode +} diff --git a/runner/src/mill/runner/MillBuildBootstrap.scala b/runner/src/mill/runner/MillBuildBootstrap.scala index d08c3c3f97f..69ca83030b6 100644 --- a/runner/src/mill/runner/MillBuildBootstrap.scala +++ b/runner/src/mill/runner/MillBuildBootstrap.scala @@ -5,7 +5,6 @@ import mill.api.{PathRef, Val, internal} import mill.eval.Evaluator import mill.main.{RootModule, RunScript} import mill.resolve.SelectMode -import mill.main.TokenReaders._ import mill.define.{Discover, Segments} import java.net.URLClassLoader @@ -292,7 +291,7 @@ object MillBuildBootstrap { // Copy the current location of the enclosing classes to `mill-launcher.jar` // if it has the wrong file extension, because the Zinc incremental compiler // doesn't recognize classpath entries without the proper file extension - val millLauncherOpt = + val millLauncherOpt: Option[os.Path] = if ( os.isFile(selfClassLocation) && !Set("zip", "jar", "class").contains(selfClassLocation.ext) diff --git a/runner/src/mill/runner/MillBuildRootModule.scala b/runner/src/mill/runner/MillBuildRootModule.scala index 314d4216fd0..7d4d94dbf1f 100644 --- a/runner/src/mill/runner/MillBuildRootModule.scala +++ b/runner/src/mill/runner/MillBuildRootModule.scala @@ -4,9 +4,9 @@ import coursier.Repository import mill._ import mill.api.{Loose, PathRef, Result, internal} import mill.define.{Caller, Discover, Target, Task} +import mill.scalalib.{BoundDep, Dep, DepSyntax, Lib, ScalaModule} import mill.util.CoursierSupport import mill.util.Util.millProjectModule -import mill.scalalib.{BoundDep, DepSyntax, Lib, ScalaModule} import mill.scalalib.api.Versions import os.{Path, rel} import pprint.Util.literalize @@ -55,7 +55,7 @@ class MillBuildRootModule()(implicit } } - override def scalaVersion = "2.13.10" + override def scalaVersion: T[String] = "2.13.10" def scriptSources = T.sources { MillBuildRootModule @@ -152,7 +152,7 @@ class MillBuildRootModule()(implicit enclosingClasspath() ++ lineNumberPluginClasspath() } - override def scalacPluginIvyDeps = Agg( + override def scalacPluginIvyDeps: T[Agg[Dep]] = Agg( ivy"com.lihaoyi:::scalac-mill-moduledefs-plugin:${Versions.millModuledefsVersion}" ) @@ -222,7 +222,7 @@ object MillBuildRootModule { enclosingClasspath: Seq[os.Path], millTopLevelProjectRoot: os.Path, cliImports: Seq[String] - ) = { + ): Unit = { for (scriptSource <- scriptSources) { val relative = scriptSource.path.relativeTo(base) val dest = targetDest / FileImportGraph.fileImportToSegments(base, scriptSource.path, false) @@ -253,8 +253,7 @@ object MillBuildRootModule { millTopLevelProjectRoot: os.Path, originalFilePath: os.Path, cliImports: Seq[String] - ) = { - + ): String = { val superClass = if (pkg.size <= 1 && name == "build") "_root_.mill.main.RootModule" else { diff --git a/scalalib/src/mill/scalalib/Dependency.scala b/scalalib/src/mill/scalalib/Dependency.scala index 9efaf0d4e9b..dc29606c623 100644 --- a/scalalib/src/mill/scalalib/Dependency.scala +++ b/scalalib/src/mill/scalalib/Dependency.scala @@ -1,15 +1,19 @@ package mill.scalalib import mill.T -import mill.define.{Discover, ExternalModule} +import mill.define.{Command, Discover, ExternalModule} import mill.eval.Evaluator import mill.main.EvaluatorTokenReader import mill.scalalib.dependency.DependencyUpdatesImpl +import mill.scalalib.dependency.updates.ModuleDependenciesUpdates object Dependency extends ExternalModule { /** Calculate possible dependency updates. */ - def updates(ev: Evaluator, allowPreRelease: Boolean = false) = + def updates( + ev: Evaluator, + allowPreRelease: Boolean = false + ): Command[Seq[ModuleDependenciesUpdates]] = T.command { DependencyUpdatesImpl( ev, @@ -21,7 +25,7 @@ object Dependency extends ExternalModule { } /** Show possible dependency updates. */ - def showUpdates(ev: Evaluator, allowPreRelease: Boolean = false) = T.command { + def showUpdates(ev: Evaluator, allowPreRelease: Boolean = false): Command[Unit] = T.command { DependencyUpdatesImpl.showAllUpdates(updates(ev, allowPreRelease)()) } diff --git a/scalalib/src/mill/scalalib/GenIdeaImpl.scala b/scalalib/src/mill/scalalib/GenIdeaImpl.scala index 3da9c67745c..1c1fac29a8f 100755 --- a/scalalib/src/mill/scalalib/GenIdeaImpl.scala +++ b/scalalib/src/mill/scalalib/GenIdeaImpl.scala @@ -236,7 +236,7 @@ case class GenIdeaImpl( os.sub / wf._1 -> ideaConfigElementTemplate(wf._2) } - type FileComponent = (SubPath, String) + type FileComponent = (SubPath, Option[String]) /** Ensure, the additional configs don't collide. */ def collisionFreeExtraConfigs( @@ -262,7 +262,7 @@ case class GenIdeaImpl( ) } val msg = - s"Config collision in file `${conf.name}` and component `${conf.component}`: ${details( + s"Config collision in file `${conf.subPath}` and component `${conf.component}`: ${details( conf.config )} vs. ${details(existing)}" ctx.map(_.log.error(msg)) @@ -274,7 +274,7 @@ case class GenIdeaImpl( val fileComponentContributions: Seq[(SubPath, Elem)] = collisionFreeExtraConfigs(configFileContributions).toSeq.map { case (file, configs) => - val map: Map[String, Seq[GenIdeaModule.Element]] = + val map: Map[Option[String], Seq[GenIdeaModule.Element]] = configs .groupBy(_.component) .view @@ -626,12 +626,12 @@ case class GenIdeaImpl( } def ideaConfigFileTemplate( - components: Map[String, Seq[GenIdeaModule.Element]] + components: Map[Option[String], Seq[GenIdeaModule.Element]] ): Elem = { { components.toSeq.map { case (name, config) => - {config.map(ideaConfigElementTemplate)} + {config.map(ideaConfigElementTemplate)} } } diff --git a/scalalib/src/mill/scalalib/GenIdeaModule.scala b/scalalib/src/mill/scalalib/GenIdeaModule.scala index 879dd62f186..699c0516632 100644 --- a/scalalib/src/mill/scalalib/GenIdeaModule.scala +++ b/scalalib/src/mill/scalalib/GenIdeaModule.scala @@ -1,6 +1,6 @@ package mill.scalalib -import mill.define.Command +import mill.define.Task import mill.{Module, PathRef, T} import os.SubPath @@ -22,14 +22,14 @@ trait GenIdeaModule extends Module { * @param ideaConfigVersion The IDEA configuration version in use. Probably `4`. * @return */ - def ideaJavaModuleFacets(ideaConfigVersion: Int): Command[Seq[JavaFacet]] = - T.command { Seq[JavaFacet]() } + def ideaJavaModuleFacets(ideaConfigVersion: Int): Task[Seq[JavaFacet]] = + T.task { Seq[JavaFacet]() } /** * Contribute components to idea config files. */ - def ideaConfigFiles(ideaConfigVersion: Int): Command[Seq[IdeaConfigFile]] = - T.command { Seq[IdeaConfigFile]() } + def ideaConfigFiles(ideaConfigVersion: Int): Task[Seq[IdeaConfigFile]] = + T.task { Seq[IdeaConfigFile]() } def ideaCompileOutput: T[PathRef] = T.persistent { PathRef(T.dest / "classes") @@ -62,24 +62,21 @@ object GenIdeaModule { /** * A Idea config file contribution - * @param name The target config file name (can be also a sub-path) + * @param subPath The sub-path of the config file, relative to the Idea config directory (`.idea`) * @param component The Idea component * @param config The actual (XML) configuration, encoded as [[Element]]s * * Note: the `name` fields is deprecated in favour of `subPath`, but kept for backward compatibility. */ final case class IdeaConfigFile( - name: String, - component: String, + subPath: SubPath, + component: Option[String], config: Seq[Element] ) { - // This also works as requirement check - /** The sub-path of the config file, relative to the Idea config directory (`.idea`). */ - val subPath: SubPath = SubPath(name) // An empty component name meas we contribute a whole file // If we have a fill file, we only accept a single root xml node. require( - component.nonEmpty || config.size == 1, + component.forall(_.nonEmpty) && (component.nonEmpty || config.size == 1), "Files contributions must have exactly one root element." ) @@ -90,13 +87,15 @@ object GenIdeaModule { } object IdeaConfigFile { - /** Alternative creator accepting a sub-path as config file name. */ + /** Alternative creator accepting a component string. */ def apply( subPath: SubPath, - component: Option[String], + component: String, config: Seq[Element] - ): IdeaConfigFile = IdeaConfigFile(subPath.toString(), component.getOrElse(""), config) + ): IdeaConfigFile = + IdeaConfigFile(subPath, if (component == "") None else Option(component), config) + implicit def subPathRw: ReadWriter[SubPath] = readwriter[String].bimap(_.toString(), SubPath(_)) implicit def rw: ReadWriter[IdeaConfigFile] = macroRW } diff --git a/scalalib/src/mill/scalalib/JavaModule.scala b/scalalib/src/mill/scalalib/JavaModule.scala index 128c47c649d..c0b71cc633b 100644 --- a/scalalib/src/mill/scalalib/JavaModule.scala +++ b/scalalib/src/mill/scalalib/JavaModule.scala @@ -44,7 +44,7 @@ trait JavaModule } trait Tests extends JavaModuleTests - def defaultCommandName() = "run" + def defaultCommandName(): String = "run" def resolvePublishDependency: Task[Dep => publish.Dependency] = T.task { Artifact.fromDepJava(_: Dep) } @@ -103,7 +103,7 @@ trait JavaModule * macro-related dependencies like `scala-reflect` that doesn't need to be * present at runtime */ - def compileIvyDeps = T { Agg.empty[Dep] } + def compileIvyDeps: T[Agg[Dep]] = T { Agg.empty[Dep] } /** * Additional dependencies, only present at runtime. Useful for e.g. @@ -270,20 +270,20 @@ trait JavaModule /** * The folders where the source files for this module live */ - def sources = T.sources { millSourcePath / "src" } + def sources: T[Seq[PathRef]] = T.sources { millSourcePath / "src" } /** * The folders where the resource files for this module live. * If you need resources to be seen by the compiler, use [[compileResources]]. */ - def resources: Sources = T.sources { millSourcePath / "resources" } + def resources: T[Seq[PathRef]] = T.sources { millSourcePath / "resources" } /** * The folders where the compile time resource files for this module live. * If your resources files do not necessarily need to be seen by the compiler, * you should use [[resources]] instead. */ - def compileResources: Sources = T.sources { millSourcePath / "compile-resources" } + def compileResources: T[Seq[PathRef]] = T.sources { millSourcePath / "compile-resources" } /** * Folders containing source files that are generated rather than @@ -484,7 +484,7 @@ trait JavaModule * Typically includes the source files to generate documentation from. * @see [[docResources]] */ - def docSources: Sources = T.sources(allSources()) + def docSources: T[Seq[PathRef]] = T.sources(allSources()) /** * Extra directories to be copied into the documentation. @@ -493,7 +493,7 @@ trait JavaModule * on the doc tool that is actually used. * @see [[docSources]] */ - def docResources: Sources = T.sources(millSourcePath / "docs") + def docResources: T[Seq[PathRef]] = T.sources(millSourcePath / "docs") /** * Control whether `docJar`-target should use a file to pass command line arguments to the javadoc tool. diff --git a/scalalib/src/mill/scalalib/ScalaModule.scala b/scalalib/src/mill/scalalib/ScalaModule.scala index 15a193df530..dd75fd93590 100644 --- a/scalalib/src/mill/scalalib/ScalaModule.scala +++ b/scalalib/src/mill/scalalib/ScalaModule.scala @@ -251,7 +251,7 @@ trait ScalaModule extends JavaModule { outer => } } - override def docSources: Sources = T.sources { + override def docSources: T[Seq[PathRef]] = T.sources { if ( ZincWorkerUtil.isScala3(scalaVersion()) && !ZincWorkerUtil.isScala3Milestone(scalaVersion()) ) Seq(compile().classes) diff --git a/scalalib/src/mill/scalalib/SemanticDbJavaModule.scala b/scalalib/src/mill/scalalib/SemanticDbJavaModule.scala index bee1589850c..d1474f63ba2 100644 --- a/scalalib/src/mill/scalalib/SemanticDbJavaModule.scala +++ b/scalalib/src/mill/scalalib/SemanticDbJavaModule.scala @@ -4,14 +4,14 @@ import mill.api.{PathRef, Result, experimental} import mill.define.{Target, Task} import mill.scalalib.api.{Versions, ZincWorkerUtil} import mill.util.Version -import mill.{Agg, BuildInfo, Input, T} +import mill.{Agg, BuildInfo, T} import scala.util.Properties @experimental trait SemanticDbJavaModule extends CoursierModule { hostModule: JavaModule => - def semanticDbVersion: Input[String] = T.input { + def semanticDbVersion: T[String] = T.input { val builtin = SemanticDbJavaModule.buildTimeSemanticDbVersion val requested = T.env.getOrElse[String]( "SEMANTICDB_VERSION", @@ -20,7 +20,7 @@ trait SemanticDbJavaModule extends CoursierModule { hostModule: JavaModule => Version.chooseNewest(requested, builtin)(Version.IgnoreQualifierOrdering) } - def semanticDbJavaVersion: Input[String] = T.input { + def semanticDbJavaVersion: T[String] = T.input { val builtin = SemanticDbJavaModule.buildTimeJavaSemanticDbVersion val requested = T.env.getOrElse[String]( "JAVASEMANTICDB_VERSION", @@ -29,12 +29,12 @@ trait SemanticDbJavaModule extends CoursierModule { hostModule: JavaModule => Version.chooseNewest(requested, builtin)(Version.IgnoreQualifierOrdering) } - def semanticDbScalaVersion = hostModule match { + def semanticDbScalaVersion: T[String] = hostModule match { case m: ScalaModule => T { m.scalaVersion } case _ => T { BuildInfo.scalaVersion } } - private def semanticDbPluginIvyDeps: Target[Agg[Dep]] = T { + private def semanticDbPluginIvyDeps: T[Agg[Dep]] = T { val sv = semanticDbScalaVersion() val semDbVersion = semanticDbVersion() if (!ZincWorkerUtil.isScala3(sv) && semDbVersion.isEmpty) { @@ -54,7 +54,7 @@ trait SemanticDbJavaModule extends CoursierModule { hostModule: JavaModule => } } - private def semanticDbJavaPluginIvyDeps: Target[Agg[Dep]] = T { + private def semanticDbJavaPluginIvyDeps: T[Agg[Dep]] = T { val sv = semanticDbJavaVersion() if (sv.isEmpty) { val msg = @@ -74,7 +74,7 @@ trait SemanticDbJavaModule extends CoursierModule { hostModule: JavaModule => /** * Scalac options to activate the compiler plugins. */ - private def semanticDbEnablePluginScalacOptions: Target[Seq[String]] = T { + private def semanticDbEnablePluginScalacOptions: T[Seq[String]] = T { val resolvedJars = resolveDeps(T.task { val bind = bindDependency() semanticDbPluginIvyDeps().map(_.exclude("*" -> "*")).map(bind) @@ -97,7 +97,7 @@ trait SemanticDbJavaModule extends CoursierModule { hostModule: JavaModule => } } - private def resolvedSemanticDbJavaPluginIvyDeps: Target[Agg[PathRef]] = T { + private def resolvedSemanticDbJavaPluginIvyDeps: T[Agg[PathRef]] = T { resolveDeps(T.task { semanticDbJavaPluginIvyDeps().map(bindDependency()) })() } diff --git a/scalalib/src/mill/scalalib/ZincWorkerModule.scala b/scalalib/src/mill/scalalib/ZincWorkerModule.scala index f0526e7db5c..b6c5da3d415 100644 --- a/scalalib/src/mill/scalalib/ZincWorkerModule.scala +++ b/scalalib/src/mill/scalalib/ZincWorkerModule.scala @@ -24,15 +24,15 @@ object ZincWorkerModule extends ExternalModule with ZincWorkerModule with Coursi */ trait ZincWorkerModule extends mill.Module with OfflineSupportModule { self: CoursierModule => - def classpath: Target[Agg[PathRef]] = T { + def classpath: T[Agg[PathRef]] = T { millProjectModule("mill-scalalib-worker", repositoriesTask()) } - def scalalibClasspath: Target[Agg[PathRef]] = T { + def scalalibClasspath: T[Agg[PathRef]] = T { millProjectModule("mill-scalalib", repositoriesTask()) } - def backgroundWrapperClasspath: Target[Agg[PathRef]] = T { + def backgroundWrapperClasspath: T[Agg[PathRef]] = T { millProjectModule( "mill-scalalib-backgroundwrapper", repositoriesTask(), @@ -40,7 +40,7 @@ trait ZincWorkerModule extends mill.Module with OfflineSupportModule { self: Cou ) } - def zincLogDebug: Input[Boolean] = T.input(T.ctx().log.debugEnabled) + def zincLogDebug: T[Boolean] = T.input(T.ctx().log.debugEnabled) def worker: Worker[ZincWorkerApi] = T.worker { val ctx = T.ctx() diff --git a/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala b/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala index 7b79a652ed8..75839e0fdfa 100644 --- a/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala +++ b/scalalib/src/mill/scalalib/scalafmt/ScalafmtModule.scala @@ -25,7 +25,7 @@ trait ScalafmtModule extends JavaModule { ) } - def scalafmtConfig: Sources = T.sources(T.workspace / ".scalafmt.conf") + def scalafmtConfig: T[Seq[PathRef]] = T.sources(T.workspace / ".scalafmt.conf") // TODO: Do we want provide some defaults or write a default file? private[ScalafmtModule] def resolvedScalafmtConfig: Task[PathRef] = T.task { diff --git a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala index fb191ffed96..d51ed75c114 100644 --- a/scalalib/test/src/mill/scalalib/HelloWorldTests.scala +++ b/scalalib/test/src/mill/scalalib/HelloWorldTests.scala @@ -32,7 +32,7 @@ object HelloWorldTests extends TestSuite { trait HelloWorldModule extends scalalib.ScalaModule { def scalaVersion = scala212Version - override def semanticDbVersion: Input[String] = T.input { + override def semanticDbVersion: T[String] = T { // The latest semanticDB release for Scala 2.12.6 "4.1.9" } diff --git a/scalalib/test/src/mill/scalalib/scalafmt/ScalafmtTests.scala b/scalalib/test/src/mill/scalalib/scalafmt/ScalafmtTests.scala index 586a9ebe891..700b08c739d 100644 --- a/scalalib/test/src/mill/scalalib/scalafmt/ScalafmtTests.scala +++ b/scalalib/test/src/mill/scalalib/scalafmt/ScalafmtTests.scala @@ -12,19 +12,19 @@ object ScalafmtTests extends TestSuite { val scalafmtTestVersion = mill.scalalib.api.Versions.scalafmtVersion trait TestBase extends TestUtil.BaseModule { - def millSourcePath = + override def millSourcePath: os.Path = TestUtil.getSrcPathBase() / millOuterCtx.enclosing.split('.') } trait BuildSrcModule { - def buildSources: Sources + def buildSources: T[Seq[PathRef]] } object ScalafmtTestModule extends TestBase { object core extends ScalaModule with ScalafmtModule with BuildSrcModule { - def scalaVersion = sys.props.getOrElse("TEST_SCALA_2_12_VERSION", ???) + def scalaVersion: T[String] = sys.props.getOrElse("TEST_SCALA_2_12_VERSION", ???) - def buildSources: Sources = T.sources { + def buildSources: T[Seq[PathRef]] = T.sources { millSourcePath / "util.sc" }