11import mill ._ , scalalib ._ , scalajslib ._ , scalanativelib ._ , publish ._
22import mill .scalalib .api .ZincWorkerUtil .isScala3
3- import scalalib . _
4- import $ivy .`de.tototec::de.tobiasroeser. mill.vcs.version ::0.3.1 `
3+ import $ivy . `de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
4+ import $ivy .`com.github.lolgab:: mill-mima ::0.0.23 `
55import de .tobiasroeser .mill .vcs .version .VcsVersion
6- import $ivy . `com.github.lolgab::mill-mima::0.0.22`
6+
77import com .github .lolgab .mill .mima ._
88
99val scala212 = " 2.12.17"
@@ -15,21 +15,19 @@ val acyclic = "0.3.8"
1515
1616val scalaVersions = List (scala212, scala213, scala3)
1717
18- val scalaJSVersions = scalaVersions.map((_, " 1.10.1" ))
19- val scalaNativeVersions = scalaVersions.map((_, " 0.4.7" ))
18+ trait MainArgsPublishModule
19+ extends PublishModule
20+ with CrossScalaModule
21+ with Mima
22+ with PlatformScalaModule {
2023
21- trait MainArgsPublishModule extends PublishModule with CrossScalaModule with Mima {
2224 def publishVersion = VcsVersion .vcsState().format()
23- override def mimaPreviousVersions =
24- Seq (" 0.5.0" )
2525
26- override def mimaPreviousArtifacts : T [Agg [Dep ]] = T {
27- if (mimaPreviousVersions().isEmpty) Agg .empty[Dep ] else super .mimaPreviousArtifacts()
28- }
26+ override def mimaPreviousVersions = Seq (" 0.5.0" )
27+
2928
3029 override def versionScheme : T [Option [VersionScheme ]] = T (Some (VersionScheme .EarlySemVer ))
3130
32- override def artifactName = " mainargs"
3331 def pomSettings = PomSettings (
3432 description = " Main method argument parser for Scala" ,
3533 organization = " com.lihaoyi" ,
@@ -41,21 +39,20 @@ trait MainArgsPublishModule extends PublishModule with CrossScalaModule with Mim
4139 )
4240 )
4341
44- def scalacOptions = super .scalacOptions() ++ ( if ( ! isScala3(crossScalaVersion))
45- Seq ( " -P:acyclic:force " )
46- else Seq .empty )
42+ def scalacOptions =
43+ super .scalacOptions() ++
44+ Option .when( ! isScala3(scalaVersion()))( " -P:acyclic:force " )
4745
4846 def scalacPluginIvyDeps =
49- super .scalacPluginIvyDeps() ++ (if (! isScala3(crossScalaVersion))
50- Agg (ivy " com.lihaoyi:::acyclic: ${acyclic}" )
51- else Agg .empty)
47+ super .scalacPluginIvyDeps() ++
48+ Option .when(! isScala3(scalaVersion()))(ivy " com.lihaoyi:::acyclic: ${acyclic}" )
5249
5350 def compileIvyDeps =
54- super .compileIvyDeps() ++ ( if ( ! isScala3(crossScalaVersion)) Agg (
55- ivy " com.lihaoyi:::acyclic: ${acyclic} " ,
56- ivy " org.scala-lang:scala-reflect: $crossScalaVersion "
57- )
58- else Agg .empty )
51+ super .compileIvyDeps() ++
52+ Agg .when( ! isScala3(crossScalaVersion))(
53+ ivy " com.lihaoyi:::acyclic: ${acyclic} " ,
54+ ivy " org.scala-lang:scala-reflect: $crossScalaVersion "
55+ )
5956
6057 def ivyDeps = Agg (
6158 ivy " org.scala-lang.modules::scala-collection-compat::2.8.1 "
@@ -64,64 +61,36 @@ trait MainArgsPublishModule extends PublishModule with CrossScalaModule with Mim
6461
6562def scalaMajor (scalaVersion : String ) = if (isScala3(scalaVersion)) " 3" else " 2"
6663
67- trait Common extends CrossScalaModule {
68- def millSourcePath = build.millSourcePath / " mainargs"
69- def sources = T .sources(
70- millSourcePath / " src" ,
71- millSourcePath / s " src- $platform" ,
72- millSourcePath / s " src- ${scalaMajor(scalaVersion())}" ,
73- millSourcePath / s " src- ${platform}- ${scalaMajor(scalaVersion())}"
74- )
75- def platform : String
76- }
77-
7864trait CommonTestModule extends ScalaModule with TestModule .Utest {
7965 def ivyDeps = Agg (ivy " com.lihaoyi::utest::0.8.1 " )
80- def sources = T .sources(
81- millSourcePath / " src" ,
82- millSourcePath / s " src- $platform" ,
83- millSourcePath / s " src- ${scalaMajor(scalaVersion())}" ,
84- millSourcePath / s " src- ${platform}- ${scalaMajor(scalaVersion())}"
85- )
86- def platform : String
8766}
8867
8968object mainargs extends Module {
90- object jvm extends Cross [JvmMainArgsModule ](scalaVersions : _* )
91- class JvmMainArgsModule (val crossScalaVersion : String )
92- extends Common with ScalaModule with MainArgsPublishModule {
93- def platform = " jvm"
94- object test extends Tests with CommonTestModule {
95- def platform = " jvm"
69+ object jvm extends Cross [JvmMainArgsModule ](scalaVersions)
70+ trait JvmMainArgsModule extends MainArgsPublishModule {
71+ object test extends ScalaTests with CommonTestModule {
9672 def ivyDeps = super .ivyDeps() ++ Agg (ivy " com.lihaoyi::os-lib: ${osLib}" )
9773 }
9874 }
9975
100- object js extends Cross [JSMainArgsModule ](scalaJSVersions : _* )
101- class JSMainArgsModule (val crossScalaVersion : String , crossJSVersion : String )
102- extends Common with MainArgsPublishModule with ScalaJSModule {
103- def platform = " js"
104- def scalaJSVersion = crossJSVersion
105- object test extends Tests with CommonTestModule {
106- def platform = " js"
107- }
76+ object js extends Cross [JSMainArgsModule ](scalaVersions)
77+ trait JSMainArgsModule extends MainArgsPublishModule with ScalaJSModule {
78+ def scalaJSVersion = " 1.10.1"
79+ object test extends ScalaJSTests with CommonTestModule
10880 }
10981
110- object native extends Cross [NativeMainArgsModule ](scalaNativeVersions : _* )
111- class NativeMainArgsModule (val crossScalaVersion : String , crossScalaNativeVersion : String )
112- extends Common with MainArgsPublishModule with ScalaNativeModule {
113- def scalaNativeVersion = crossScalaNativeVersion
114- def platform = " native"
115- object test extends Tests with CommonTestModule {
116- def platform = " native"
117- }
82+ object native extends Cross [NativeMainArgsModule ](scalaVersions)
83+ trait NativeMainArgsModule extends MainArgsPublishModule with ScalaNativeModule {
84+ def scalaNativeVersion = " 0.4.7"
85+ object test extends ScalaNativeTests with CommonTestModule
11886 }
11987}
12088
12189trait ExampleModule extends ScalaModule {
12290 def scalaVersion = scala213
12391 def moduleDeps = Seq (mainargs.jvm(scala213))
12492}
93+
12594object example {
12695 object hello extends ExampleModule
12796 object hello2 extends ExampleModule
0 commit comments