@@ -3,14 +3,14 @@ import scalalib._
3
3
import scalajslib ._
4
4
import scalanativelib ._
5
5
import publish ._
6
- import mill .eval .Result
6
+ import mill .api .Result
7
7
import mill .modules .Jvm .createJar
8
8
9
- import mill .scalalib .api .Util .isScala3
10
- import $ivy .`de.tototec::de.tobiasroeser.mill.vcs.version::0.3.0`
9
+ import mill .scalalib .api .ZincWorkerUtil .isScala3
10
+ import $ivy .`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
11
+ import $ivy .`com.github.lolgab::mill-mima::0.0.23`
11
12
12
13
import de .tobiasroeser .mill .vcs .version .VcsVersion
13
- import $ivy .`com.github.lolgab::mill-mima::0.0.13`
14
14
import com .github .lolgab .mill .mima ._
15
15
16
16
val scala31 = " 3.2.2"
@@ -20,24 +20,16 @@ val scala211 = "2.11.12"
20
20
val scalaJS1 = " 1.12.0"
21
21
val scalaNative04 = " 0.4.9"
22
22
val crossVersions = Seq (scala31, scala213, scala212, scala211)
23
- val crossJsVersions = Seq (scala31 -> scalaJS1, scala213 -> scalaJS1, scala212 -> scalaJS1, scala211 -> scalaJS1)
24
- val crossNativeVersions = Seq (scala31 -> scalaNative04, scala213 -> scalaNative04, scala212 -> scalaNative04, scala211 -> scalaNative04)
25
-
26
23
27
24
object fastparse extends Module {
28
- object jvm extends Cross [fastparseJvmModule](crossVersions:_* )
29
- class fastparseJvmModule (val crossScalaVersion : String ) extends FastparseModule {
30
- def platformSegment = " jvm"
31
- object test extends Tests with CommonTestModule {
32
- def platformSegment = " jvm"
33
- }
25
+ object jvm extends Cross [fastparseJvmModule](crossVersions)
26
+ trait fastparseJvmModule extends FastparseModule {
27
+ object test extends ScalaModuleTests with CommonTestModule
34
28
}
35
29
36
- object js extends Cross [fastparseJsModule](crossJsVersions:_* )
37
- class fastparseJsModule (val crossScalaVersion : String , crossScalaJsVersion : String ) extends FastparseModule with ScalaJSModule {
38
- def platformSegment = " js"
39
- def millSourcePath = super .millSourcePath / os.up
40
- def scalaJSVersion = crossScalaJsVersion
30
+ object js extends Cross [fastparseJsModule](crossVersions)
31
+ trait fastparseJsModule extends FastparseModule with ScalaJSModule {
32
+ def scalaJSVersion = scalaJS1
41
33
private def sourceMapOptions = T .task {
42
34
val vcsState = VcsVersion .vcsState()
43
35
vcsState.lastTag.collect {
@@ -47,21 +39,17 @@ object fastparse extends Module{
47
39
s " $sourcesOptionName: ${T .workspace.toIO.toURI}-> $baseUrl/ $tag/ "
48
40
}
49
41
}
42
+
50
43
override def scalacOptions = super .scalacOptions() ++ sourceMapOptions()
51
- object test extends Tests with CommonTestModule {
52
- def platformSegment = " js"
53
- }
44
+
45
+ object test extends ScalaJSModuleTests with CommonTestModule
54
46
}
55
47
56
- object native extends Cross [fastparseNativeModule](crossNativeVersions:_* )
57
- class fastparseNativeModule (val crossScalaVersion : String , crossScalaNativeVersion : String ) extends FastparseModule with ScalaNativeModule {
58
- def platformSegment = " native"
59
- def millSourcePath = super .millSourcePath / os.up
60
- def scalaNativeVersion = crossScalaNativeVersion
48
+ object native extends Cross [fastparseNativeModule](crossVersions)
49
+ trait fastparseNativeModule extends FastparseModule with ScalaNativeModule {
50
+ def scalaNativeVersion = scalaNative04
61
51
62
- object test extends Tests with CommonTestModule {
63
- def platformSegment = " native"
64
- }
52
+ object test extends ScalaNativeModuleTests with CommonTestModule
65
53
}
66
54
}
67
55
@@ -70,6 +58,7 @@ trait FastparseModule extends CommonCrossModule with Mima{
70
58
ivy " com.lihaoyi::sourcecode::0.3.0 " ,
71
59
ivy " com.lihaoyi::geny::1.0.0 "
72
60
)
61
+
73
62
def compileIvyDeps =
74
63
if (isScala3(crossScalaVersion)) Agg .empty[Dep ]
75
64
else Agg (ivy " org.scala-lang:scala-reflect: $crossScalaVersion" )
@@ -114,87 +103,77 @@ trait FastparseModule extends CommonCrossModule with Mima{
114
103
.getOrElse(throw new Exception (" Missing last tag" ))
115
104
)
116
105
117
- def mimaPreviousArtifacts = if (isScala3(crossScalaVersion)) Agg .empty[Dep ] else super .mimaPreviousArtifacts()
106
+ def mimaPreviousArtifacts =
107
+ if (isScala3(crossScalaVersion)) Agg .empty[Dep ]
108
+ else super .mimaPreviousArtifacts()
118
109
119
110
def mimaBinaryIssueFilters = super .mimaBinaryIssueFilters() ++ Seq (
120
111
ProblemFilter .exclude[IncompatibleResultTypeProblem ](" fastparse.Parsed#Failure.unapply" )
121
112
)
122
113
}
123
114
124
115
object scalaparse extends Module {
125
- object js extends Cross [ScalaParseJsModule ](crossJsVersions :_* )
126
- class ScalaParseJsModule ( val crossScalaVersion : String , val crossScalaJsVersion : String ) extends ExampleParseJsModule
116
+ object js extends Cross [ScalaParseJsModule ](crossVersions )
117
+ trait ScalaParseJsModule extends ExampleParseJsModule
127
118
128
- object jvm extends Cross [ScalaParseJvmModule ](crossVersions:_* )
129
- class ScalaParseJvmModule ( val crossScalaVersion : String ) extends ExampleParseJvmModule
119
+ object jvm extends Cross [ScalaParseJvmModule ](crossVersions)
120
+ trait ScalaParseJvmModule extends ExampleParseJvmModule
130
121
131
- object native extends Cross [ScalaParseNativeModule ](crossNativeVersions :_* )
132
- class ScalaParseNativeModule ( val crossScalaVersion : String , val crossScalaNativeVersion : String ) extends ExampleParseNativeModule
122
+ object native extends Cross [ScalaParseNativeModule ](crossVersions )
123
+ trait ScalaParseNativeModule extends ExampleParseNativeModule
133
124
}
134
125
135
126
object cssparse extends Module {
136
- object js extends Cross [CssParseJsModule ](crossJsVersions :_* )
137
- class CssParseJsModule ( val crossScalaVersion : String , val crossScalaJsVersion : String ) extends ExampleParseJsModule
127
+ object js extends Cross [CssParseJsModule ](crossVersions )
128
+ trait CssParseJsModule extends ExampleParseJsModule
138
129
139
- object jvm extends Cross [CssParseJvmModule ](crossVersions:_* )
140
- class CssParseJvmModule ( val crossScalaVersion : String ) extends ExampleParseJvmModule
130
+ object jvm extends Cross [CssParseJvmModule ](crossVersions)
131
+ trait CssParseJvmModule extends ExampleParseJvmModule
141
132
142
- object native extends Cross [CssParseNativeModule ](crossNativeVersions :_* )
143
- class CssParseNativeModule ( val crossScalaVersion : String , val crossScalaNativeVersion : String ) extends ExampleParseNativeModule
133
+ object native extends Cross [CssParseNativeModule ](crossVersions )
134
+ trait CssParseNativeModule extends ExampleParseNativeModule
144
135
}
145
136
146
137
object pythonparse extends Module {
147
- object js extends Cross [PythonParseJsModule ](crossJsVersions :_* )
148
- class PythonParseJsModule ( val crossScalaVersion : String , val crossScalaJsVersion : String ) extends ExampleParseJsModule
138
+ object js extends Cross [PythonParseJsModule ](crossVersions )
139
+ trait PythonParseJsModule extends ExampleParseJsModule
149
140
150
- object jvm extends Cross [PythonParseJvmModule ](crossVersions:_* )
151
- class PythonParseJvmModule ( val crossScalaVersion : String ) extends ExampleParseJvmModule
141
+ object jvm extends Cross [PythonParseJvmModule ](crossVersions)
142
+ trait PythonParseJvmModule extends ExampleParseJvmModule
152
143
153
- object native extends Cross [PythonParseNativeModule ](crossNativeVersions :_* )
154
- class PythonParseNativeModule ( val crossScalaVersion : String , val crossScalaNativeVersion : String ) extends ExampleParseNativeModule
144
+ object native extends Cross [PythonParseNativeModule ](crossVersions )
145
+ trait PythonParseNativeModule extends ExampleParseNativeModule
155
146
}
156
147
157
148
trait ExampleParseJsModule extends CommonCrossModule with ScalaJSModule {
158
- def moduleDeps = Seq (fastparse.js(crossScalaVersion, crossScalaJsVersion))
159
- def crossScalaJsVersion : String
160
- def scalaJSVersion = crossScalaJsVersion
161
- def platformSegment = " js"
162
- def millSourcePath = super .millSourcePath / os.up
163
- object test extends Tests with CommonTestModule {
164
- def platformSegment = " js"
165
- }
166
- }
149
+ def moduleDeps = Seq (fastparse.js())
150
+ def scalaJSVersion = scalaJS1
167
151
152
+ object test extends ScalaJSModuleTests with CommonTestModule
153
+ }
168
154
169
155
trait ExampleParseJvmModule extends CommonCrossModule {
170
156
def moduleDeps = Seq (fastparse.jvm())
171
- def platformSegment = " jvm"
172
- object test extends Tests with CommonTestModule {
173
- def platformSegment = " jvm"
157
+
158
+ object test extends ScalaModuleTests with CommonTestModule {
174
159
def ivyDeps = super .ivyDeps() ++ Agg (
175
160
ivy " net.sourceforge.cssparser:cssparser:0.9.18 " ,
176
- ) ++ (if (isScala3(crossScalaVersion)) Agg .empty[Dep ] else Agg (ivy " org.scala-lang:scala-compiler: $crossScalaVersion" ))
161
+ ) ++ Agg .when(! isScala3(crossScalaVersion))(
162
+ ivy " org.scala-lang:scala-compiler: $crossScalaVersion"
163
+ )
177
164
}
178
165
}
179
166
180
167
trait ExampleParseNativeModule extends CommonCrossModule with ScalaNativeModule {
181
- def platformSegment = " native"
182
- def crossScalaNativeVersion : String
183
- def scalaNativeVersion = crossScalaNativeVersion
184
- def millSourcePath = super .millSourcePath / os.up
185
- def moduleDeps = Seq (fastparse.native(crossScalaVersion, crossScalaNativeVersion))
186
- object test extends Tests with CommonTestModule {
187
- def platformSegment = " native"
188
- }
189
- }
168
+ def scalaNativeVersion = scalaNative04
169
+ def moduleDeps = Seq (fastparse.native())
190
170
171
+ object test extends ScalaNativeModuleTests with CommonTestModule
172
+ }
191
173
192
-
193
- trait CommonCrossModule extends CrossScalaModule with PublishModule {
194
-
174
+ trait CommonCrossModule extends CrossScalaModule with PublishModule with PlatformScalaModule {
195
175
def publishVersion = VcsVersion .vcsState().format()
196
176
197
- def artifactName = millModuleSegments.parts.dropRight(2 ).mkString(" -" ).stripSuffix(s " - $platformSegment" )
198
177
def pomSettings = PomSettings (
199
178
description = artifactName(),
200
179
organization = " com.lihaoyi" ,
@@ -210,42 +189,25 @@ trait CommonCrossModule extends CrossScalaModule with PublishModule {
210
189
)
211
190
212
191
def scalaDocPluginClasspath = T { Agg [PathRef ]() }
213
- // def scalacOptions = T{ if (scalaVersion() == "2.12.10") Seq("-opt:l:method") else Nil }
214
192
215
- def platformSegment : String
216
- def millSourcePath = super .millSourcePath / os.up
217
193
def sources = T .sources {
218
- super .sources()
219
- .flatMap{p => Seq (p, PathRef (p.path / os.up / s " ${p.path.last}- $platformSegment" )) } ++
220
- (if (scalaVersion() != scala211) {
221
- Seq (PathRef (millSourcePath / " src-2.12+" ))
222
- } else Seq ())
194
+ super .sources() ++
195
+ Agg .when(scalaVersion() != scala211)(PathRef (millSourcePath / " src-2.12+" ))
223
196
}
224
197
}
225
- trait CommonTestModule extends ScalaModule with TestModule .Utest {
226
198
227
- def platformSegment : String
228
- def ivyDeps = Agg (
229
- ivy " com.lihaoyi::utest::0.8.1 " ,
230
- )
231
- override def scalacOptions = super .scalacOptions() ++
232
- (if (scalaVersion() == scala213) Seq (" -Xfatal-warnings" , " -Wconf:cat=feature:s,cat=deprecation:s" ) else Nil )
199
+ trait CommonTestModule extends ScalaModule with TestModule .Utest {
200
+ def ivyDeps = Agg (ivy " com.lihaoyi::utest::0.8.1 " )
233
201
234
- def sources = T .sources {
235
- super .sources().flatMap { p => Seq (p, PathRef (p.path / os.up / s " ${p.path.last}- $platformSegment" )) }
236
- }
202
+ override def scalacOptions =
203
+ super .scalacOptions() ++
204
+ Agg .when(scalaVersion() == scala213)(
205
+ " -Xfatal-warnings" ,
206
+ " -Wconf:cat=feature:s,cat=deprecation:s"
207
+ )
237
208
}
238
209
239
210
object perftests extends Module {
240
- object bench1 extends PerfTestModule {
241
- def scalaVersion0 = scala213
242
- def ivyDeps = super .ivyDeps() ++ Agg (
243
- ivy " com.lihaoyi::scalaparse:1.0.0 " ,
244
- ivy " com.lihaoyi::pythonparse:1.0.0 " ,
245
- ivy " com.lihaoyi::cssparse:1.0.0 " ,
246
- )
247
- }
248
-
249
211
object bench2 extends PerfTestModule {
250
212
def scalaVersion0 = scala213
251
213
def moduleDeps = Seq (
@@ -254,7 +216,6 @@ object perftests extends Module{
254
216
cssparse.jvm(scala213).test,
255
217
fastparse.jvm(scala213).test,
256
218
)
257
-
258
219
}
259
220
260
221
object benchScala3 extends PerfTestModule {
@@ -266,17 +227,16 @@ object perftests extends Module{
266
227
cssparse.jvm(scala31).test,
267
228
fastparse.jvm(scala31).test,
268
229
)
269
-
270
230
}
271
231
272
-
273
232
object compare extends PerfTestModule {
274
- def scalaVersion0 = scala213
233
+ def scalaVersion0 = scala212
275
234
def moduleDeps = Seq (
276
235
fastparse.jvm(scala212).test,
277
236
scalaparse.jvm(scala212).test,
278
237
pythonparse.jvm(scala212).test
279
238
)
239
+
280
240
def ivyDeps = super .ivyDeps() ++ Agg (
281
241
ivy " org.json4s::json4s-ast:3.6.0 " ,
282
242
ivy " org.json4s::json4s-native:3.6.0 " ,
@@ -299,22 +259,21 @@ object perftests extends Module{
299
259
Seq (PathRef (perftests.millSourcePath / " resources" )) ++
300
260
fastparse.jvm(scalaVersion0).test.resources()
301
261
}
302
- def ivyDeps = Agg (
303
- ivy " com.lihaoyi::utest::0.8.1 " ,
304
- // ivy"org.scala-lang:scala-compiler:${scalaVersion()}"
305
- )
262
+
263
+ def ivyDeps = Agg (ivy " com.lihaoyi::utest::0.8.1 " )
306
264
}
307
265
}
308
266
309
267
object demo extends ScalaJSModule {
310
268
def scalaJSVersion = scalaJS1
311
269
def scalaVersion = scala213
312
270
def moduleDeps = Seq (
313
- scalaparse.js(scala213, scalaJS1 ),
314
- cssparse.js(scala213, scalaJS1 ),
315
- pythonparse.js(scala213, scalaJS1 ),
316
- fastparse.js(scala213, scalaJS1 ).test,
271
+ scalaparse.js(scala213),
272
+ cssparse.js(scala213),
273
+ pythonparse.js(scala213),
274
+ fastparse.js(scala213).test,
317
275
)
276
+
318
277
def ivyDeps = Agg (
319
278
ivy " org.scala-js::scalajs-dom::0.9.8 " ,
320
279
ivy " com.lihaoyi::scalatags::0.9.3 "
0 commit comments