Last active
May 10, 2024 11:41
-
-
Save megri/7b8dc1bf02b15bf44990f04da2a6da6f to your computer and use it in GitHub Desktop.
Scala cli-style inline deps declarations for mill
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import mill._, scalalib._ | |
object MyModule extends ScalaModule { | |
def inlineIvyDeps = T { | |
def parseDep(usingDepClause: String): Dep = { | |
val part = usingDepClause.drop("//> using dep ".size) | |
if (part.startsWith("\"")) Dep.parse(part.tail.init.trim) | |
else Dep.parse(part.trim) | |
} | |
val deps = for { | |
sourceRoot <- geny.Generator(sources()).flatten | |
scalaFile <- os.walk.stream(sourceRoot.path).filter(path => os.isFile(path) && path.ext == "scala") | |
usingDep <- os.read.lines.stream(scalaFile).filter(line => line.startsWith("//> using dep")) | |
} yield parseDep(usingDep) | |
Agg.from(deps.toList) | |
} | |
def ivyDeps = inlineIvyDeps() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment