forked from lqhuang/scala-native-http
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.mill
More file actions
153 lines (117 loc) · 4.38 KB
/
Copy pathbuild.mill
File metadata and controls
153 lines (117 loc) · 4.38 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
//| mill-version: 1.1.6
//| mill-jvm-version: zulu:25
//| mill-jvm-opts:
//| - -XX:MaxInlineLevel=20
//| - -XX:+UseZGC
//| - -XX:ZUncommitDelay=30
//| - -XX:ZCollectionInterval=5
//| - -XX:+IgnoreUnrecognizedVMOptions
//| mvnDeps:
//| - com.goyeau::mill-scalafix::0.6.0
//| - com.github.lolgab::mill-mima_mill1:0.2.0
//| - com.lihaoyi::mill-contrib-buildinfo:$MILL_VERSION
package build
import scala.util.Properties
import mill.{scalalib, scalanativelib}
import mill.api.{Module, Task, PathRef}
import mill.util.VcsVersion
import scalalib.DepSyntax // for `mvn` string interpolator
import scalalib.{ScalaModule, TestModule, PublishModule}
import scalalib.publish.{Developer, License, PomSettings, VersionControl}
import scalalib.scalafmt.ScalafmtModule
import scalanativelib.ScalaNativeModule
import com.goyeau.mill.scalafix.ScalafixModule
// import com.github.lolgab.mill.mima.*
// import com.indoorvivants.vcpkg.millplugin.native.VcpkgNativeModule // not work yet
val scalaNextVersion = Properties.propOrNone("scalaNextVersion")
val scalaVersion = if scalaNextVersion.isEmpty then "3.3.7" else scalaNextVersion.get
val scalaNativeVersion = "0.5.12"
// def format = ScalafmtModule
trait CommonPublishModule extends PublishModule {
def publishVersion = VcsVersion.vcsState().format()
def pomSettings = PomSettings(
description = "Scala Native HTTP Client",
organization = "io.lqhuang",
url = "https://github.com/lqhuang/scala-native-http",
licenses = Seq(License.`Apache-2.0`),
versionControl = VersionControl.github("lqhuang", "scala-native-http"),
developers = Seq(Developer("lqhuang", "Lanqing Huang", "https://github.com/lqhuang")),
)
}
trait UTestModule extends TestModule.Utest {
def utestVersion = "0.9.5"
def testParallelism = true
}
trait CommonModule extends ScalaNativeModule with CommonPublishModule with ScalafixModule {
override def jvmVersion = Properties.envOrElse("SNHTTP_DEV_JVM_VERSION", super.jvmVersion())
def scalaVersion = build.scalaVersion
def scalaNativeVersion = build.scalaNativeVersion
def scalacOptions = super.scalacOptions() ++ Seq(
"-Wvalue-discard",
"-Wnonunit-statement",
"-Wconf:msg=(discarded.*value|pure.*statement):error",
"-P:scalanative:genStaticForwardersForNonTopLevelObjects",
// "-explain",
)
def nativeIncrementalCompilation = true
def nativeLinkingOptions = super.nativeLinkingOptions() ++ Seq("-v")
def scalafixIvyDeps = Seq(
mvn"com.github.xuwei-k::scalafix-rules:0.6.17",
)
/// Define common trait for test module
trait CommonTestModule extends ScalaNativeTests with UTestModule
}
/**
* Integration tests for Scala Native HTTP Client
*
* We clone the source code of `requests-scala` and run tests on it to ensure the compatibility of
* our java shim with the `requests-scala` library.
*/
object `integration-test-requests` extends Module:
def `requests-repo` = Task {
val dest = Task.dest
if (!os.exists(dest) || !os.exists(dest / ".git")) {
os.proc(
"git",
"clone",
"--branch",
"0.9.3",
"--depth",
"1",
"https://github.com/com-lihaoyi/requests-scala.git",
dest,
).call()
}
PathRef(dest)
}
trait RequestsModule extends ScalaModule {
def scalaVersion = build.scalaVersion
override def sources = Task {
Seq(PathRef(`requests-repo`().path / "requests" / "src"))
}
def mvnDeps = Seq(mvn"com.lihaoyi::geny::1.1.1")
trait RequestsTestModule extends ScalaTests with UTestModule {
def resources = Task {
Seq(PathRef(`requests-repo`().path / "requests" / "test" / "resources"))
}
def sources = Task {
Seq(PathRef(`requests-repo`().path / "requests" / "test" / "src"))
}
def mvnDeps = Seq(
mvn"com.lihaoyi::utest::0.9.5",
mvn"com.lihaoyi::ujson::4.4.3",
)
def forkArgs = Seq(
"--add-opens",
"java.net.http/jdk.internal.net.http=ALL-UNNAMED",
)
}
}
// object jvm extends JVM
// trait JVM extends RequestsModule:
// object test extends ScalaTests with RequestsTestModule
// object native extends Native
// trait Native extends RequestsModule with ScalaNativeModule:
// def scalaNativeVersion = build.scalaNativeVersion
// def moduleDeps = super.moduleDeps ++ Seq(build.modules.`java-http-client`)
// object test extends ScalaNativeTests with RequestsTestModule