-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sc
72 lines (59 loc) · 2.18 KB
/
build.sc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import $meta._
import mill._
//import mill.define._
import mill.scalalib._
import mill.define.Source
import mill.util.Jvm
import mill.api.Result
import $ivy.`com.mchange::untemplate-mill:0.1.4-SNAPSHOT`
import untemplate.mill._
// NOTE: Documentation-visible untemplate version is defined in common.scala (package untemplatedoc)!
object untemplatedoc extends UntemplateModule {
override def scalaVersion = "3.3.3"
override def untemplateIndexNameFullyQualified : Option[String] = Some("untemplatedoc.Untemplates")
override def untemplateSelectCustomizer: untemplate.Customizer.Selector = { key =>
var out = untemplate.Customizer.empty
if (key.inferredPackage.startsWith("untemplatedoc.readme")) {
key.inferredFunctionName match {
case s"content_${whatever}" =>
out = out.copy(extraImports = Seq("untemplatedoc.*", "java.nio.file.Files", "com.mchange.codegenutil.*"))
if (whatever.endsWith("_md"))
out = out.copy(mbDefaultOutputTransformer = Some("readme.subsection_content_transformer_md"))
case _ => /* ignore */
}
}
out
}
def installDir = millSourcePath / os.up
def exampleDir = installDir / "example"
def scalagenDir = exampleDir / "scalagen"
def regenerate = T {
val scalagenSrc = untemplateGenerateScala().path
val installFile = (installDir / "README.md").toString
println(s">>>> installFile: ${installFile}")
os.makeDir.all(scalagenDir)
os.copy.over(scalagenSrc, scalagenDir)
// literally copied from JavaModule.run()
// there must be a better way
try Result.Success(
Jvm.runSubprocess(
finalMainClass(),
runClasspath().map(_.path),
forkArgs(),
forkEnv(),
Seq(installFile),
workingDir = forkWorkingDir(),
useCpPassingJar = runUseArgsFile()
)
)
catch {
case e: Exception =>
Result.Failure("subprocess failed")
}
// super.run(Seq(installFile) :_*)
// ()
}
// abortive attempts to address terminal / mill untemplatedoc.console problems
// import $ivy.`org.fusesource.jansi:jansi:2.4.0`
// override def ivyDeps = T{ super.ivyDeps() ++ Agg(ivy"org.fusesource.jansi:jansi:2.4.0") }
}