-
-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathbuild.mill
More file actions
161 lines (142 loc) · 5.79 KB
/
build.mill
File metadata and controls
161 lines (142 loc) · 5.79 KB
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
152
153
154
155
156
157
158
159
160
161
//| mill-opts: ["--jobs=0.5C"]
//| mvnDeps:
//| - com.github.lolgab::mill-mima_mill1:0.2.0
//| - com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION
package build
import mill._, scalalib._, scalajslib._, scalanativelib._, publish._
import mill.util.VcsVersion
import mill.contrib.buildinfo.BuildInfo
import com.github.lolgab.mill.mima._
val communityBuildDottyVersion = sys.props.get("dottyVersion").toList
val scalaVersions = "2.12.20" :: "2.13.16" :: "3.3.6" :: communityBuildDottyVersion
val scalaReflectVersion = "1.1.3"
trait MimaCheck extends Mima {
def mimaPreviousVersions = VcsVersion.vcsState().lastTag.toSeq
override def mimaBinaryIssueFilters: T[Seq[ProblemFilter]] = Seq(
// shaded internal thing not for public use
ProblemFilter.exclude[MissingClassProblem]("utest.shaded.app.tulz.diff.*")
)
}
trait UtestModule extends PublishModule with MimaCheck {
def artifactName = "utest"
def jvmVersion = "11"
def publishVersion = VcsVersion.vcsState().format()
def pomSettings = PomSettings(
description = artifactName(),
organization = "com.lihaoyi",
url = "https://github.com/com-lihaoyi/utest",
licenses = Seq(License.MIT),
versionControl = VersionControl.github(owner = "com-lihaoyi", repo = "utest"),
developers = Seq(
Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi")
)
)
}
trait UtestMainModule extends CrossScalaModule with UtestModule with PlatformScalaModule{
def resolveUnpackShade(filtered: Seq[PathRef])(implicit ctx: mill.api.TaskCtx) = {
for(jar <- filtered) os.unzip(jar.path, Task.dest)
for(file <- os.walk(Task.dest) if file.ext == "scala"){
val text = os.read(file)
if (!text.contains("package scala")){
os.write.over(
file,
"package utest.shaded\n" +
text.replace("assert(", "Predef.assert(")
.replace("_root_.pprint", "_root_.utest.shaded.pprint")
.replace("_root_.fansi", "_root_.utest.shaded.fansi")
)
}
}
Seq(PathRef(Task.dest))
}
def generatedSources = Task{
// Locally-build and shade versions of pprint and fansi to avoid classpath
// conflicts and circular dependencies between utest and those projects
// Note: stringdiff is vendored directly in utest/src/utest/shaded/stringdiff/
// with a fix for the pathological performance issue caused by View concatenation
resolveUnpackShade(
defaultResolver().classpath(
Seq(
mvn"com.lihaoyi::pprint:0.9.5",
mvn"com.lihaoyi::fansi:0.5.1"
),
sources = true
).filter(_.path.last match{
case s"fansi$versionSuffix.jar" => true
case s"pprint$versionSuffix.jar" => true
case _ => false
})
)
}
}
trait UtestTestModule extends BuildInfo with TestModule {
def scalaVersion: T[String]
def testFramework = "test.utest.CustomFramework"
val buildInfoPackageName = "test.utest"
def buildInfoMembers = Seq(BuildInfo.Value("scalaVersion", scalaVersion()))
}
object utest extends Module {
object jvm extends Cross[JvmUtestModule](scalaVersions)
trait JvmUtestModule
extends UtestMainModule {
def compileMvnDeps =
if (crossScalaVersion.startsWith("2")) Seq(
mvn"org.scala-lang:scala-reflect:${crossScalaVersion}",
mvn"org.scala-lang:scala-compiler:${crossScalaVersion}"
)
else Seq.empty[Dep]
def mvnDeps = Seq(
mvn"com.lihaoyi::sourcecode::0.4.3-M5",
mvn"org.scala-sbt:test-interface::1.0",
mvn"org.scala-lang.modules::scala-collection-compat::2.13.0",
) ++ (if (crossScalaVersion.startsWith("2")) Seq(
mvn"org.portable-scala::portable-scala-reflect::$scalaReflectVersion",
mvn"org.scala-lang:scala-reflect:$crossScalaVersion"
) else Seq())
object test extends ScalaTests with UtestTestModule{
def resources = super[UtestTestModule].resources() ++ super[ScalaTests].resources()
def scalacOptions = Seq("-Yrangepos")
}
}
object js extends Cross[JsUtestModule](scalaVersions)
trait JsUtestModule extends UtestMainModule with ScalaJSModule{
def compileMvnDeps =
if (crossScalaVersion.startsWith("2")) Seq(
mvn"org.scala-lang:scala-reflect:${crossScalaVersion}",
mvn"org.scala-lang:scala-compiler:${crossScalaVersion}"
)
else Seq.empty[Dep]
def mvnDeps = Seq(
mvn"com.lihaoyi::sourcecode::0.4.3-M5",
mvn"org.scala-js::scalajs-test-interface:${scalaJSVersion()}".withDottyCompat(crossScalaVersion),
mvn"org.portable-scala::portable-scala-reflect::$scalaReflectVersion".withDottyCompat(crossScalaVersion),
mvn"org.scala-lang.modules::scala-collection-compat::2.13.0",
) ++ (if(crossScalaVersion.startsWith("2")) Seq(
mvn"org.scala-lang:scala-reflect:$crossScalaVersion"
) else Seq())
def scalaJSVersion = "1.19.0"
object test extends ScalaJSTests with UtestTestModule{
def resources = super[UtestTestModule].resources() ++ super[ScalaJSTests].resources()
def scalacOptions = Seq("-Yrangepos")
}
}
object native extends Cross[NativeUtestModule](scalaVersions)
trait NativeUtestModule extends UtestMainModule with ScalaNativeModule {
def compileMvnDeps =
if (crossScalaVersion.startsWith("2")) Seq(
mvn"org.scala-lang:scala-reflect:${crossScalaVersion}",
mvn"org.scala-lang:scala-compiler:${crossScalaVersion}"
)
else Seq.empty[Dep]
def mvnDeps = Seq(
mvn"com.lihaoyi::sourcecode::0.4.3-M5",
mvn"org.scala-native::test-interface::${scalaNativeVersion()}",
mvn"org.scala-lang.modules::scala-collection-compat::2.13.0",
)
def scalaNativeVersion = "0.5.8"
object test extends ScalaNativeTests with UtestTestModule{
def resources = super[UtestTestModule].resources() ++ super[ScalaNativeTests].resources()
def scalacOptions = Seq("-Yrangepos")
}
}
}