Skip to content

How to get the name of the current task? #3559

Answered by jk-1
jk-1 asked this question in Q&A
Discussion options

You must be logged in to vote
import mill._, scalalib._
import upickle.default._
import upickle.default.{ReadWriter => RW, macroRW}
implicit val nameRW: RW[sourcecode.Name] = macroRW
implicit val fullNameRW: RW[sourcecode.FullName] = macroRW

object foo extends RootModule with ScalaModule {
  def scalaVersion = "2.13.11"
  def ivyDeps = Agg(
    ivy"com.lihaoyi::scalatags:0.12.0",
    ivy"com.lihaoyi::mainargs:0.6.2"
  )

  def getName = T { 
    println(implicitly[sourcecode.FullName].value.split("\\.").toSeq.reverse.tail.head)
    println(T.dest.segments.toSeq.reverse.tail.head)
    T.dest.segments.toSeq.reverse.tail.head
  }

  object test extends ScalaTests {
    def ivyDeps = Agg(ivy"com.lihaoyi::utest:0.8.4")
  …

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@jk-1
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by jk-1
# for free to join this conversation on GitHub. Already have an account? # to comment
Category
Q&A
Labels
None yet
2 participants