@@ -8,6 +8,7 @@ import $ivy.`com.github.lolgab::mill-mima::0.1.0`
88
99import mill ._ , mill .scalalib ._ , mill .scalanativelib ._ , mill .scalanativelib .api ._
1010import mill .scalalib .publish ._
11+ import mill .util .Jvm
1112import com .goyeau .mill .scalafix .ScalafixModule
1213import io .kipp .mill .ci .release .CiReleaseModule
1314import mill .contrib .buildinfo .BuildInfo
@@ -38,7 +39,10 @@ object Common {
3839 def scalacOptions = super .scalacOptions() ++
3940 Seq (" -deprecation" )
4041 }
41- trait SharedNative extends Shared with ScalaNativeModule {
42+ trait Jvm extends Shared {
43+ def scalaVersion = Versions .scala3
44+ }
45+ trait Native extends Jvm with ScalaNativeModule {
4246 def scalaNativeVersion = versions.Versions .scalaNative
4347
4448 def baseTestConfig (binary : os.Path ) = {
@@ -64,17 +68,6 @@ object Common {
6468 }
6569
6670 }
67-
68- trait Scala3Only extends SharedNative {
69- def crossScalaVersion = Versions .scala3
70- def scalaVersion = crossScalaVersion
71- }
72- trait Scala3OnlyJvm extends Shared {
73- def crossScalaVersion = Versions .scala3
74- def scalaVersion = crossScalaVersion
75- }
76- trait Cross extends CrossScalaModule with SharedNative
77- trait CrossJvm extends CrossScalaModule with Shared
7871}
7972
8073trait Publish extends CiReleaseModule with Mima {
@@ -93,16 +86,14 @@ trait Publish extends CiReleaseModule with Mima {
9386 // Remove after first release with Scala Native 0.5
9487 def mimaPreviousArtifacts = Task { Seq .empty }
9588}
96- object snunit extends Cross [SNUnitModule ](scalaVersions)
97- trait SNUnitModule extends Common .Cross with Publish {
89+ object snunit extends Common .Native with Publish {
9890 object test extends ScalaNativeTests with TestModule .Utest {
9991 def ivyDeps = super .ivyDeps() ++ Agg (utest)
10092 }
10193}
10294
103- // object `snunit-async-cats-effect` extends Cross[SNUnitAsyncCatsEffectModule](scalaVersions)
104- // trait SNUnitAsyncCatsEffectModule extends Common.Cross with Publish {
105- // def moduleDeps = Seq(snunit())
95+ // object `snunit-async-cats-effect` extends Common.Native with Publish {
96+ // def moduleDeps = Seq(snunit)
10697
10798// def ivyDeps =
10899// Task {
@@ -112,33 +103,46 @@ trait SNUnitModule extends Common.Cross with Publish {
112103// }
113104// }
114105
115- object `snunit-undertow` extends Cross [SNUnitUndertow ](scalaVersions)
116- trait SNUnitUndertow extends Common .Cross with Publish {
117- def moduleDeps = Seq (snunit())
106+ object `snunit-undertow` extends Common .Native with Publish {
107+ def moduleDeps = Seq (snunit)
108+ def ivyDeps = super .ivyDeps() ++ Agg (undertow)
109+ // Remove class and tasty files
110+ override def jar = Task {
111+ Jvm .createJar(
112+ localClasspath().map(_.path).filter(os.exists),
113+ manifest(),
114+ (_, file) =>
115+ file.ext match {
116+ case " class" | " tasty" => false
117+ case _ => true
118+ }
119+ )
120+ }
121+ // Sometimes it gives problems compiling since our internal API is different
122+ // than the java API in the class files.
123+ def zincIncrementalCompilation = false
118124}
119125
120- object `snunit-tapir` extends Cross [SNUnitTapirModule ](scalaVersions)
121- trait SNUnitTapirModule extends Common .Cross with Publish {
122- def moduleDeps = Seq (snunit())
126+ object `snunit-tapir` extends Common .Native with Publish {
127+ def moduleDeps = Seq (snunit)
123128 def ivyDeps = super .ivyDeps() ++ Agg (ivy " com.softwaremill.sttp.tapir::tapir-server:: ${Versions .tapir}" )
124129}
125- // object `snunit-tapir-cats-effect` extends Cross[SNUnitTapirCatsEffect](scalaVersions)
126- // trait SNUnitTapirCatsEffect extends Common.Cross with Publish {
130+ // object `snunit-tapir-cats-effect` extends Common.Native with Publish {
127131// def moduleDeps = Seq(
128- // `snunit-tapir`() ,
129- // `snunit-async-cats-effect`()
132+ // `snunit-tapir`,
133+ // `snunit-async-cats-effect`
130134// )
131135// def ivyDeps = super.ivyDeps() ++ Agg(
132136// ivy"com.softwaremill.sttp.tapir::tapir-cats-effect::${Versions.tapir}"
133137// )
134138// }
135139
136- // object `snunit-http4s` extends Cross[SNUnitHttp4s](http4sAndScalaVersions)
137- // trait SNUnitHttp4s extends Common.Cross with Cross.Module2[String, String] with Publish {
138- // val http4sVersion = crossValue2
140+ // object `snunit-http4s` extends Cross[SNUnitHttp4s]
141+ // trait SNUnitHttp4s extends Common.Native with Cross.Module[ String] with Publish {
142+ // val http4sVersion = crossValue
139143// def moduleDeps = Seq(
140- // snunit() ,
141- // `snunit-async-cats-effect`()
144+ // snunit,
145+ // `snunit-async-cats-effect`
142146// )
143147// val http4sBinaryVersion = http4sVersion match {
144148// case s"0.23.$_" => "0.23"
@@ -165,14 +169,13 @@ def castorSources = Task {
165169 .call()
166170 PathRef (dest)
167171}
168- object `snunit-cask` extends Cross [SNUnitCaskModule ](scalaVersions)
169- trait SNUnitCaskModule extends Common .Cross with Publish {
172+ object `snunit-cask` extends Common .Native with Publish {
170173 override def generatedSources = Task {
171174 val cask = caskSources().path / " cask"
172175 val castor = castorSources().path / " castor"
173176 Seq (cask / " src" , cask / " util" / " src" , cask / " src-3" , castor / " src" , castor / " src-js-native" ).map(PathRef (_))
174177 }
175- def moduleDeps = Seq (`snunit-undertow`(crossScalaVersion) )
178+ def moduleDeps = Seq (`snunit-undertow`)
176179 def ivyDeps = super .ivyDeps() ++ Agg (
177180 upickle,
178181 ivy " io.github.cquiroz::scala-java-time:: ${Versions .scalaJavaTime}" ,
@@ -182,62 +185,61 @@ trait SNUnitCaskModule extends Common.Cross with Publish {
182185
183186object integration extends ScalaModule {
184187 object tests extends Module {
185- object `hello-world` extends Cross [HelloWorld ](scalaVersions)
186- trait HelloWorld extends Common .Cross {
187- def moduleDeps = Seq (snunit())
188+ object `hello-world` extends Common .Native {
189+ def moduleDeps = Seq (snunit)
188190 }
189- object `websocket-echo` extends Common .Scala3Only {
190- def moduleDeps = Seq (snunit(crossScalaVersion) )
191+ object `websocket-echo` extends Common .Native {
192+ def moduleDeps = Seq (snunit)
191193 }
192- object `multiple-handlers` extends Common .Scala3Only {
193- def moduleDeps = Seq (snunit(crossScalaVersion) )
194+ object `multiple-handlers` extends Common .Native {
195+ def moduleDeps = Seq (snunit)
194196 }
195197 object `undertow-helloworld` extends CrossPlatform {
196- object native extends CrossPlatformScalaModule with Common .Scala3Only {
197- def moduleDeps = Seq (`snunit-undertow`(crossScalaVersion) )
198+ object native extends CrossPlatformScalaModule with Common .Native {
199+ def moduleDeps = Seq (`snunit-undertow`)
198200 }
199- object jvm extends CrossPlatformScalaModule with Common .Scala3OnlyJvm {
201+ object jvm extends CrossPlatformScalaModule with Common .Jvm {
200202 def ivyDeps = super .ivyDeps() ++ Agg (undertow)
201203 }
202204 }
203205 object `cask-helloworld` extends CrossPlatform {
204- object jvm extends CrossPlatformScalaModule with Common .Scala3OnlyJvm {
206+ object jvm extends CrossPlatformScalaModule with Common .Jvm {
205207 def ivyDeps = super .ivyDeps() ++ Agg (
206208 ivy " com.lihaoyi::cask: ${Versions .cask}"
207209 )
208210 }
209- object native extends CrossPlatformScalaModule with Common .Scala3Only {
210- def moduleDeps = Seq (`snunit-cask`(crossScalaVersion) )
211+ object native extends CrossPlatformScalaModule with Common .Native {
212+ def moduleDeps = Seq (`snunit-cask`)
211213 }
212214 }
213- object `tapir-helloworld` extends Common .Scala3Only {
214- override def moduleDeps = Seq (`snunit-tapir`(crossScalaVersion) )
215+ object `tapir-helloworld` extends Common .Native {
216+ override def moduleDeps = Seq (`snunit-tapir`)
215217 }
216- // object `tapir-app` extends Common.Scala3Only {
217- // override def moduleDeps = Seq(`snunit-tapir-cats-effect`(crossScalaVersion) )
218+ // object `tapir-app` extends Common.Native {
219+ // override def moduleDeps = Seq(`snunit-tapir-cats-effect`)
218220 // }
219221 // object `http4s-helloworld` extends Cross[Http4sHelloWorldModule](http4sVersions)
220- // trait Http4sHelloWorldModule extends Common.Scala3Only with Cross.Module[String] {
222+ // trait Http4sHelloWorldModule extends Common.Native with Cross.Module[String] {
221223 // def http4sVersion = crossValue
222224 // def moduleDeps = Seq(
223- // `snunit-http4s`(crossScalaVersion, http4sVersion)
225+ // `snunit-http4s`(http4sVersion)
224226 // )
225227 // def ivyDeps = super.ivyDeps() ++ Agg(
226228 // ivy"org.http4s::http4s-dsl::$http4sVersion"
227229 // )
228230 // }
229- // object `http4s-app` extends Common.Scala3Only {
231+ // object `http4s-app` extends Common.Native {
230232 // val http4sVersion = Versions.http4s1
231233 // def moduleDeps = Seq(
232- // `snunit-http4s`(crossScalaVersion, http4sVersion)
234+ // `snunit-http4s`(http4sVersion)
233235 // )
234236 // def ivyDeps = super.ivyDeps() ++ Agg(
235237 // ivy"org.http4s::http4s-dsl::$http4sVersion"
236238 // )
237239 // }
238- // object `tapir-helloworld-cats-effect` extends Common.Scala3Only {
240+ // object `tapir-helloworld-cats-effect` extends Common.Native {
239241 // def moduleDeps = Seq(
240- // `snunit-tapir-cats-effect`(crossScalaVersion)
242+ // `snunit-tapir-cats-effect`
241243 // )
242244 // }
243245 }
@@ -288,7 +290,7 @@ object `snunit-mill-plugin` extends Common.Shared with Publish with BuildInfo {
288290 def mainClass = Some (" mill.runner.client.MillClientMain" )
289291 def resources = Task {
290292 // make sure snunit is published
291- snunit(versions. Versions .scala3) .publishLocal()()
293+ snunit.publishLocal()()
292294
293295 val p = Task .dest / " mill/local-test-overrides" / s " com.lihaoyi- ${`snunit-mill-plugin`.artifactId()}"
294296 os.write(p, `snunit-mill-plugin`.localClasspath().map(_.path).mkString(" \n " ), createFolders = true )
0 commit comments