1+ import $ivy .`com.goyeau::mill-scalafix::0.2.10`
2+ import com .goyeau .mill .scalafix .ScalafixModule
13import mill ._ , scalalib ._ , scalafmt ._
24import mill .scalalib .publish ._
35
46val Scala12 = " 2.12.16"
57val Scala13 = " 2.13.8"
68
7- trait CommonModule extends CrossScalaModule with ScalafmtModule with PublishModule {
8- def publishVersion = " 0.1.0 "
9+ val CatsCore = ivy " org.typelevel::cats-core:2.7.0 "
10+ val CatsParse = ivy " org.typelevel::cats-parse:0.3.7 "
911
10- def pomSettings = PomSettings (
11- description = " Scala Commons - common utilities for Scala projects" ,
12- organization = " com.github.morgen-peschke" ,
13- url = " https://github.com/morgen-peschke/scala-commons" ,
14- licenses = Seq (License .MIT ),
15- versionControl = VersionControl .github(" morgen-peschke" , " scala-commons" ),
16- developers = Seq (
17- Developer (" morgen-peschke" , " Morgen Peschke" , " https://github.com/morgen-peschke" )
18- )
19- )
12+ val SuperTagged = ivy " org.rudogma::supertagged:2.0-RC2 "
2013
21- def crossScalaVersion : String
14+ val ScalaCheck = ivy " org.scalacheck::scalacheck:1.16.0 "
15+ val ScalaTest = ivy " org.scalatest::scalatest:3.2.13 "
16+ val WordSpec = Set (ScalaTest , ivy " org.scalatest::scalatest-wordspec:3.2.13 " )
17+ val PropSpec = Set (
18+ ScalaTest ,
19+ ivy " org.scalatest::scalatest-propspec:3.2.13 " ,
20+ ivy " org.scalatestplus::scalacheck-1-16:3.2.12.0 "
21+ )
22+
23+ trait StyleModule extends ScalafmtModule with ScalafixModule {
24+ override def scalafixIvyDeps = super .scalafixIvyDeps() ++ Agg (ivy " com.github.liancheng::organize-imports:0.6.0 " )
2225
2326 def commonScalacOptions = Seq (
2427 " -encoding" ,
@@ -34,96 +37,121 @@ trait CommonModule extends CrossScalaModule with ScalafmtModule with PublishModu
3437 )
3538
3639 def versionSpecificOptions (version : String ) = version match {
37- case Scala12 => Seq (
38- " -Ywarn-adapted-args" ,
39- " -Ywarn-inaccessible" ,
40- " -Ywarn-unused-import" ,
41- " -Ypartial-unification"
42- )
40+ case Scala12 =>
41+ Seq (
42+ " -Ywarn-adapted-args" ,
43+ " -Ywarn-inaccessible" ,
44+ " -Ywarn-unused-import" ,
45+ " -Ypartial-unification"
46+ )
4347 case _ => Seq ()
4448 }
4549
46- def scalacOptions = commonScalacOptions ++ versionSpecificOptions(crossScalaVersion)
50+ def crossScalaVersion : String
51+
52+ override def scalacOptions =
53+ super .scalacOptions() ++ commonScalacOptions ++ versionSpecificOptions(crossScalaVersion)
4754
48- def scalaDocOptions = Seq (" -no-link-warnings" )
55+ override def scalaDocOptions = super .scalaDocOptions() ++ Seq (" -no-link-warnings" )
56+
57+ override def scalacPluginIvyDeps = super .scalacPluginIvyDeps() ++ Agg (
58+ ivy " com.olegpy::better-monadic-for:0.3.1 " ,
59+ ivy " org.typelevel:::kind-projector:0.13.2 "
60+ )
4961}
5062
51- object core extends Cross [CoreModule ](Scala12 , Scala13 )
52- class CoreModule (val crossScalaVersion : String )
53- extends CommonModule {
63+ trait CommonModule
64+ extends CrossScalaModule
65+ with StyleModule
66+ with PublishModule {
67+
68+ override def artifactName : T [String ] = T { s " commons- ${super .artifactName()}" }
5469
55- override def artifactName = " commons-core "
70+ def publishVersion : T [ String ] = " 0.1.0 "
5671
57- override def ivyDeps = Agg (
58- ivy " org.typelevel::cats-core:2.7.0 " ,
59- ivy " org.rudogma::supertagged:2.0-RC2 " ,
60- ivy " org.typelevel::cats-parse:0.3.7 "
72+ override def pomSettings : T [PomSettings ] = PomSettings (
73+ description = " Scala Commons - common utilities for Scala projects" ,
74+ organization = " com.github.morgen-peschke" ,
75+ url = " https://github.com/morgen-peschke/scala-commons" ,
76+ licenses = Seq (License .MIT ),
77+ versionControl = VersionControl .github(" morgen-peschke" , " scala-commons" ),
78+ developers = Seq (
79+ Developer (
80+ " morgen-peschke" ,
81+ " Morgen Peschke" ,
82+ " https://github.com/morgen-peschke"
83+ )
84+ )
6185 )
6286
63- object test extends Tests with TestModule .ScalaTest {
87+ protected def outerCrossScalaVersion : String = crossScalaVersion
88+ }
89+
90+ trait CommonTestModule extends TestModule .ScalaTest with StyleModule
91+
92+ object core extends Cross [CoreModule ](Scala12 , Scala13 )
93+ class CoreModule (val crossScalaVersion : String ) extends CommonModule {
94+ override def ivyDeps = Agg (CatsCore , CatsParse , SuperTagged )
6495
65- override def moduleDeps = super .moduleDeps ++ Seq (scalacheck(crossScalaVersion))
96+ object test extends Tests with CommonTestModule {
97+ override def moduleDeps : Seq [JavaModule ] =
98+ super .moduleDeps ++ Seq (scalacheck(crossScalaVersion))
6699
67- override def ivyDeps = Agg (
68- ivy " org.scalacheck::scalacheck:1.16.0 " ,
69- ivy " org.scalatest::scalatest:3.2.13 " ,
70- ivy " org.scalatest::scalatest-wordspec:3.2.13 " ,
71- ivy " org.scalatest::scalatest-propspec:3.2.13 " ,
72- ivy " org.scalatestplus::scalacheck-1-16:3.2.12.0 " ,
73- ivy " org.python:jython-slim:2.7.2 "
100+ override def ivyDeps : T [Agg [Dep ]] = super .ivyDeps() ++ Agg .from(
101+ WordSpec ++ PropSpec + ivy " org.python:jython-slim:2.7.2 "
74102 )
103+
104+ override def crossScalaVersion : String = outerCrossScalaVersion
75105 }
76106}
77107
78108object collections extends Cross [CollectionsModule ](Scala12 , Scala13 )
79- class CollectionsModule (val crossScalaVersion : String )
80- extends CommonModule {
81-
82- override def artifactName = " commons-collections"
109+ class CollectionsModule (val crossScalaVersion : String ) extends CommonModule {
110+ override def ivyDeps : T [Agg [Dep ]] = super .ivyDeps() ++ Agg (CatsCore )
83111
84- object test extends Tests with TestModule .ScalaTest {
112+ object test extends Tests with CommonTestModule {
113+ override def moduleDeps : Seq [JavaModule ] =
114+ super .moduleDeps ++ Seq (scalacheck(crossScalaVersion))
85115
86- override def moduleDeps = super .moduleDeps ++ Seq (scalacheck(crossScalaVersion))
116+ override def crossScalaVersion : String = outerCrossScalaVersion
87117
88- override def ivyDeps = Agg (
89- ivy " org.scalacheck::scalacheck:1.16.0 " ,
90- ivy " org.scalatest::scalatest:3.2.13 " ,
91- ivy " org.scalatest::scalatest-wordspec:3.2.13 " ,
92- ivy " org.scalatest::scalatest-propspec:3.2.13 " ,
93- ivy " org.scalatestplus::scalacheck-1-16:3.2.12.0 " ,
94- ivy " org.python:jython-slim:2.7.2 "
95- )
118+ override def ivyDeps : T [Agg [Dep ]] = super .ivyDeps() ++ Agg .from(WordSpec ++ PropSpec )
96119 }
97120}
98121
99122object scalacheck extends Cross [ScalaCheckModule ](Scala12 , Scala13 )
100- class ScalaCheckModule (val crossScalaVersion : String )
101- extends CommonModule {
102-
103- override def artifactName = " commons-scalacheck"
123+ class ScalaCheckModule (val crossScalaVersion : String ) extends CommonModule {
124+ override def ivyDeps : T [Agg [Dep ]] = super .ivyDeps() ++ Agg (ScalaCheck )
104125
105- override def ivyDeps = Agg (
106- ivy " org.typelevel::cats- core:2.7.0 " ,
107- ivy " org.scalacheck::scalacheck:1.16.0 "
126+ override def moduleDeps : Seq [ PublishModule ] = super .moduleDeps ++ Seq (
127+ core(crossScalaVersion) ,
128+ collections(crossScalaVersion)
108129 )
109130
110- object test extends Tests with TestModule .ScalaTest {
111- override def ivyDeps = Agg (
112- ivy " org.scalacheck::scalacheck:1.16.0 " ,
113- ivy " org.scalatest::scalatest:3.2.13 " ,
114- ivy " org.scalatest::scalatest-propspec:3.2.13 " ,
115- ivy " org.scalatestplus::scalacheck-1-16:3.2.12.0 "
116- )
131+ object test extends Tests with CommonTestModule {
132+ override def crossScalaVersion : String = outerCrossScalaVersion
133+
134+ override def ivyDeps : T [Agg [Dep ]] = super .ivyDeps() ++ Agg .from(PropSpec )
117135 }
118136}
119137
120138object decline extends Cross [DeclineModule ](Scala12 , Scala13 )
121- class DeclineModule (val crossScalaVersion : String )
122- extends CommonModule {
139+ class DeclineModule (val crossScalaVersion : String ) extends CommonModule {
140+ override def moduleDeps : Seq [ PublishModule ] = super .moduleDeps ++ Seq (core(crossScalaVersion))
123141
124- override def artifactName = " commons-decline"
142+ override def ivyDeps : T [Agg [Dep ]] = super .ivyDeps() ++ Agg (
143+ CatsCore ,
144+ ivy " com.monovore::decline:2.3.0 "
145+ )
146+ }
147+
148+ object shims extends Cross [ShimsModule ](Scala12 , Scala13 )
149+ class ShimsModule (val crossScalaVersion : String ) extends CommonModule {
150+ override def moduleDeps : Seq [PublishModule ] = super .moduleDeps ++ Seq (core(crossScalaVersion))
125151
126- override def moduleDeps = super .moduleDeps ++ Seq (core(crossScalaVersion))
152+ object test extends Tests with CommonTestModule {
153+ override def crossScalaVersion : String = outerCrossScalaVersion
127154
128- override def ivyDeps = Agg (ivy " com.monovore::decline:2.3.0 " )
129- }
155+ override def ivyDeps : T [Agg [Dep ]] = super .ivyDeps() ++ Agg .from(WordSpec )
156+ }
157+ }
0 commit comments