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

Deprecated T.command(task) for removal in Mill 0.13 #3524

Merged
merged 4 commits into from
Sep 12, 2024
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 contrib/playlib/src/mill/playlib/PlayModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ trait PlayApiModule extends Dependencies with Router with Server {
override def sources = T.sources { millSourcePath }
}

def start(args: Task[Args] = T.task(Args())) = T.command { run(args) }
def start(args: Task[Args] = T.task(Args())) = T.command { run(args)() }

}
trait PlayModule extends PlayApiModule with Static with Twirl {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,10 @@ trait ScoverageModule extends ScalaModule { outer: ScalaModule =>
outer.scalacOptions() ++ extras
}

def htmlReport(): Command[Unit] = T.command { doReport(ReportType.Html) }
def xmlReport(): Command[Unit] = T.command { doReport(ReportType.Xml) }
def xmlCoberturaReport(): Command[Unit] = T.command { doReport(ReportType.XmlCobertura) }
def consoleReport(): Command[Unit] = T.command { doReport(ReportType.Console) }
def htmlReport(): Command[Unit] = T.command { doReport(ReportType.Html)() }
def xmlReport(): Command[Unit] = T.command { doReport(ReportType.Xml)() }
def xmlCoberturaReport(): Command[Unit] = T.command { doReport(ReportType.XmlCobertura)() }
def consoleReport(): Command[Unit] = T.command { doReport(ReportType.Console)() }

override def skipIdea = true
}
Expand Down
12 changes: 12 additions & 0 deletions main/define/src/mill/define/Task.scala
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
implicit def apply[T](t: Result[T])(implicit rw: RW[T], ctx: mill.define.Ctx): Target[T] =
macro Internal.targetResultImpl[T]

@deprecated(
"Creating a target from a task is deprecated. You most likely forgot a parenthesis pair `()`",
"Mill after 0.12.0-RC1"
)
def apply[T](t: Task[T])(implicit rw: RW[T], ctx: mill.define.Ctx): Target[T] =
macro Internal.targetTaskImpl[T]

Expand Down Expand Up @@ -278,6 +282,10 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
* take arguments that are automatically converted to command-line
* arguments, as long as an implicit [[mainargs.TokensReader]] is available.
*/
@deprecated(
"Creating a command from a task is deprecated. You most likely forgot a parenthesis pair `()`",
"Mill after 0.12.0-RC1"
)
def command[T](t: Task[T])(implicit
ctx: mill.define.Ctx,
w: W[T],
Expand All @@ -304,6 +312,10 @@ object Target extends Applicative.Applyer[Task, Task, Result, mill.api.Ctx] {
* responsibility of ensuring the implementation is idempotent regardless of
* what in-memory state the worker may have.
*/
@deprecated(
"Creating a worker from a task is deprecated. You most likely forgot a parenthesis pair `()`",
"Mill after 0.12.0-RC1"
)
def worker[T](t: Task[T])(implicit ctx: mill.define.Ctx): Worker[T] =
macro Internal.workerImpl1[T]

Expand Down
5 changes: 3 additions & 2 deletions scalajslib/src/mill/scalajslib/ScalaJSModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ trait ScalaJSModule extends scalalib.ScalaModule { outer =>
)
}

override def runLocal(args: Task[Args] = T.task(Args())): Command[Unit] = T.command { run(args) }
override def runLocal(args: Task[Args] = T.task(Args())): Command[Unit] =
T.command { run(args)() }

override def run(args: Task[Args] = T.task(Args())): Command[Unit] = T.command {
if (args().value.nonEmpty) {
Expand Down Expand Up @@ -374,7 +375,7 @@ trait TestScalaJSModule extends ScalaJSModule with TestModule {
}

override def testLocal(args: String*): Command[(String, Seq[TestResult])] =
T.command { test(args: _*) }
T.command { test(args: _*)() }

override protected def testTask(
args: Task[Seq[String]],
Expand Down
10 changes: 5 additions & 5 deletions scalalib/src/mill/scalalib/JavaModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -872,23 +872,23 @@ trait JavaModule
transitiveCompileIvyDeps() ++ runIvyDeps().map(bindDependency())
},
validModules
)
)()
}
case (Flag(true), Flag(false)) =>
T.command {
printDepsTree(args.inverse.value, transitiveCompileIvyDeps, validModules)
printDepsTree(args.inverse.value, transitiveCompileIvyDeps, validModules)()
}
case (Flag(false), Flag(true)) =>
T.command {
printDepsTree(
args.inverse.value,
T.task { runIvyDeps().map(bindDependency()) },
validModules
)
)()
}
case _ =>
T.command {
printDepsTree(args.inverse.value, T.task { Agg.empty[BoundDep] }, validModules)
printDepsTree(args.inverse.value, T.task { Agg.empty[BoundDep] }, validModules)()
}
}
} else {
Expand Down Expand Up @@ -958,7 +958,7 @@ trait JavaModule
*/
def runBackground(args: String*): Command[Unit] = {
val task = runBackgroundTask(finalMainClass, T.task { Args(args) })
T.command { task }
T.command { task() }
}

/**
Expand Down
10 changes: 5 additions & 5 deletions scalalib/src/mill/scalalib/RunModule.scala
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ trait RunModule extends WithZincWorker {
* Runs this module's code in a subprocess and waits for it to finish
*/
def run(args: Task[Args] = T.task(Args())): Command[Unit] = T.command {
runForkedTask(finalMainClass, args)
runForkedTask(finalMainClass, args)()
}

/**
Expand All @@ -89,31 +89,31 @@ trait RunModule extends WithZincWorker {
* in a bad state.
*/
def runLocal(args: Task[Args] = T.task(Args())): Command[Unit] = T.command {
runLocalTask(finalMainClass, args)
runLocalTask(finalMainClass, args)()
}

/**
* Same as `run`, but lets you specify a main class to run
*/
def runMain(@arg(positional = true) mainClass: String, args: String*): Command[Unit] = {
val task = runForkedTask(T.task { mainClass }, T.task { Args(args) })
T.command { task }
T.command { task() }
}

/**
* Same as `runBackground`, but lets you specify a main class to run
*/
def runMainBackground(@arg(positional = true) mainClass: String, args: String*): Command[Unit] = {
val task = runBackgroundTask(T.task { mainClass }, T.task { Args(args) })
T.command { task }
T.command { task() }
}

/**
* Same as `runLocal`, but lets you specify a main class to run
*/
def runMainLocal(@arg(positional = true) mainClass: String, args: String*): Command[Unit] = {
val task = runLocalTask(T.task { mainClass }, T.task { Args(args) })
T.command { task }
T.command { task() }
}

/**
Expand Down
2 changes: 1 addition & 1 deletion scalalib/test/src/mill/scalalib/PublishModuleTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ object PublishModuleTests extends TestSuite {
override def versionScheme = Some(VersionScheme.EarlySemVer)

def checkSonatypeCreds(sonatypeCreds: String) = T.command {
PublishModule.checkSonatypeCreds(sonatypeCreds)
PublishModule.checkSonatypeCreds(sonatypeCreds)()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ trait ScalaNativeModule extends ScalaModule { outer =>

trait TestScalaNativeModule extends ScalaNativeModule with TestModule {
override def resources: T[Seq[PathRef]] = super[ScalaNativeModule].resources
override def testLocal(args: String*) = T.command { test(args: _*) }
override def testLocal(args: String*) = T.command { test(args: _*)() }
override protected def testTask(
args: Task[Seq[String]],
globSeletors: Task[Seq[String]]
Expand Down
Loading