forked from com-lihaoyi/os-lib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sc
151 lines (128 loc) · 4.79 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
// plugins
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $ivy.`com.github.lolgab::mill-mima::0.1.0`
// imports
import mill._, scalalib._, scalanativelib._, publish._
import mill.scalalib.api.ZincWorkerUtil
import com.github.lolgab.mill.mima._
import de.tobiasroeser.mill.vcs.version.VcsVersion
val communityBuildDottyVersion = sys.props.get("dottyVersion").toList
val scala213Version = "2.13.14"
val scalaVersions = Seq(
"3.3.1",
"2.12.17",
scala213Version
) ++ communityBuildDottyVersion
object Deps {
val acyclic = ivy"com.lihaoyi:::acyclic:0.3.12"
val jna = ivy"net.java.dev.jna:jna:5.14.0"
val geny = ivy"com.lihaoyi::geny::1.1.0"
val sourcecode = ivy"com.lihaoyi::sourcecode::0.4.1"
val utest = ivy"com.lihaoyi::utest::0.8.3"
def scalaLibrary(version: String) = ivy"org.scala-lang:scala-library:${version}"
}
trait AcyclicModule extends ScalaModule {
def acyclicDep: T[Agg[Dep]] = T {
Agg.from(Option.when(!ZincWorkerUtil.isScala3(scalaVersion()))(Deps.acyclic))
}
def acyclicOptions: T[Seq[String]] = T {
Option.when(!ZincWorkerUtil.isScala3(scalaVersion()))("-P:acyclic:force").toSeq
}
def compileIvyDeps = acyclicDep
def scalacPluginIvyDeps = acyclicDep
def scalacOptions = super.scalacOptions() ++ acyclicOptions()
}
trait SafeDeps extends ScalaModule {
def mapDependencies: Task[coursier.Dependency => coursier.Dependency] = T.task {
val sd = Deps.scalaLibrary(scala213Version)
super.mapDependencies().andThen { d =>
// enforce up-to-date Scala 2.13.x version
if (d.module == sd.dep.module && d.version.startsWith("2.13.")) sd.dep
else d
}
}
}
trait MiMaChecks extends Mima {
def mimaPreviousVersions = Seq("0.9.0", "0.9.1", "0.9.2", "0.9.3", "0.10.0")
override def mimaBinaryIssueFilters: T[Seq[ProblemFilter]] = Seq(
ProblemFilter.exclude[ReversedMissingMethodProblem]("os.PathConvertible.isCustomFs")
)
}
object testJarWriter extends JavaModule
object testJarReader extends JavaModule
object testJarExit extends JavaModule
trait OsLibModule
extends CrossScalaModule
with PublishModule
with AcyclicModule
with SafeDeps
with PlatformScalaModule { outer =>
def publishVersion = VcsVersion.vcsState().format()
def pomSettings = PomSettings(
description = artifactName(),
organization = "com.lihaoyi",
url = "https://github.com/com-lihaoyi/os-lib",
licenses = Seq(License.MIT),
versionControl = VersionControl.github(
owner = "com-lihaoyi",
repo = "os-lib"
),
developers = Seq(
Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi")
)
)
trait OsLibTestModule extends ScalaModule with TestModule.Utest with SafeDeps {
def ivyDeps = Agg(Deps.utest, Deps.sourcecode)
// we check the textual output of system commands and expect it in english
def forkEnv = super.forkEnv() ++ Map(
"LC_ALL" -> "C",
"TEST_JAR_WRITER_ASSEMBLY" -> testJarWriter.assembly().path.toString,
"TEST_JAR_READER_ASSEMBLY" -> testJarReader.assembly().path.toString,
"TEST_JAR_EXIT_ASSEMBLY" -> testJarExit.assembly().path.toString,
"TEST_SUBPROCESS_ENV" -> "value"
)
}
}
trait OsModule extends OsLibModule { outer =>
def ivyDeps = Agg(Deps.geny)
def artifactName = "os-lib"
val scalaDocExternalMappings = Seq(
".*scala.*::scaladoc3::https://scala-lang.org/api/3.x/",
".*java.*::javadoc::https://docs.oracle.com/javase/8/docs/api/",
s".*geny.*::scaladoc3::https://javadoc.io/doc/com.lihaoyi/geny_3/${Deps.geny.dep.version}/"
).mkString(",")
def conditionalScalaDocOptions: T[Seq[String]] = T {
if (ZincWorkerUtil.isDottyOrScala3(scalaVersion()))
Seq(
s"-external-mappings:${scalaDocExternalMappings}"
)
else Seq()
}
def scalaDocOptions = super.scalaDocOptions() ++ conditionalScalaDocOptions()
}
object os extends Module {
object jvm extends Cross[OsJvmModule](scalaVersions)
trait OsJvmModule extends OsModule with MiMaChecks {
object test extends ScalaTests with OsLibTestModule
object nohometest extends ScalaTests with OsLibTestModule
}
object native extends Cross[OsNativeModule](scalaVersions)
trait OsNativeModule extends OsModule with ScalaNativeModule {
def scalaNativeVersion = "0.5.0"
object test extends ScalaNativeTests with OsLibTestModule {
def nativeLinkStubs = true
}
object nohometest extends ScalaNativeTests with OsLibTestModule
}
object watch extends Module {
object jvm extends Cross[WatchJvmModule](scalaVersions)
trait WatchJvmModule extends OsLibModule {
def artifactName = "os-lib-watch"
def moduleDeps = super.moduleDeps ++ Seq(os.jvm())
def ivyDeps = Agg(Deps.jna)
object test extends ScalaTests with OsLibTestModule {
def moduleDeps = super.moduleDeps ++ Seq(os.jvm().test)
}
}
}
}