-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathbuild.mill
120 lines (96 loc) · 3.68 KB
/
build.mill
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
package build
import mill._, scalalib._, scalajslib._, scalanativelib._, publish._
import mill.scalalib.api.ZincWorkerUtil.isScala3
import $ivy.`de.tototec::de.tobiasroeser.mill.vcs.version::0.4.0`
import $ivy.`com.github.lolgab::mill-mima::0.1.1`
import de.tobiasroeser.mill.vcs.version.VcsVersion
import com.github.lolgab.mill.mima._
val scala212 = "2.12.17"
val scala213 = "2.13.10"
val scala3 = "3.3.1"
val osLib = "0.10.3"
val acyclic = "0.3.12"
val githubOrg = "com-lihaoyi"
val githubRepo = "mainargs"
val projectUrl = s"https://github.com/${githubOrg}/${githubRepo}"
val changelogUrl = s"${projectUrl}#changelog"
val scalaVersions = List(scala212, scala213, scala3)
trait MainArgsPublishModule
extends PublishModule
with CrossScalaModule
with Mima
with PlatformScalaModule {
def publishVersion = VcsVersion.vcsState().format()
override def mimaPreviousVersions = Seq("0.6.0")
def mimaReportBinaryIssues() =
if (this.isInstanceOf[ScalaNativeModule] || this.isInstanceOf[ScalaJSModule]) T.command()
else super.mimaReportBinaryIssues()
override def versionScheme: T[Option[VersionScheme]] = T(Some(VersionScheme.EarlySemVer))
def publishProperties = super.publishProperties() ++ Map(
"info.releaseNotesURL" -> changelogUrl
)
def pomSettings = PomSettings(
description = "Main method argument parser for Scala",
organization = "com.lihaoyi",
url = projectUrl,
licenses = Seq(License.MIT),
versionControl = VersionControl.github(githubOrg, githubRepo),
developers = Seq(
Developer("lihaoyi", "Li Haoyi", "https://github.com/lihaoyi")
)
)
def scalacOptions =
super.scalacOptions() ++
Option.when(!isScala3(scalaVersion()))("-P:acyclic:force")
def scalacPluginIvyDeps =
super.scalacPluginIvyDeps() ++
Option.when(!isScala3(scalaVersion()))(ivy"com.lihaoyi:::acyclic:${acyclic}")
def compileIvyDeps =
super.compileIvyDeps() ++
Agg.when(!isScala3(crossScalaVersion))(
ivy"com.lihaoyi:::acyclic:${acyclic}",
ivy"org.scala-lang:scala-reflect:$crossScalaVersion"
)
def ivyDeps = Agg(
ivy"org.scala-lang.modules::scala-collection-compat::2.12.0"
)
}
def scalaMajor(scalaVersion: String) = if (isScala3(scalaVersion)) "3" else "2"
trait CommonTestModule extends ScalaModule with TestModule.Utest {
def ivyDeps = Agg(ivy"com.lihaoyi::utest::0.8.3")
}
object mainargs extends Module {
object jvm extends Cross[JvmMainArgsModule](scalaVersions)
trait JvmMainArgsModule extends MainArgsPublishModule {
object test extends ScalaTests with CommonTestModule {
def ivyDeps = super.ivyDeps() ++ Agg(ivy"com.lihaoyi::os-lib:${osLib}")
}
}
object js extends Cross[JSMainArgsModule](scalaVersions)
trait JSMainArgsModule extends MainArgsPublishModule with ScalaJSModule {
def scalaJSVersion = "1.12.0"
object test extends ScalaJSTests with CommonTestModule
}
object native extends Cross[NativeMainArgsModule](scalaVersions)
trait NativeMainArgsModule extends MainArgsPublishModule with ScalaNativeModule {
def scalaNativeVersion = "0.5.0"
object test extends ScalaNativeTests with CommonTestModule
}
}
trait ExampleModule extends ScalaModule {
def scalaVersion = scala213
def moduleDeps = Seq(mainargs.jvm(scala213))
}
object example extends Module {
object hello extends ExampleModule
object hello2 extends ExampleModule
object caseclass extends ExampleModule
object classarg extends ExampleModule
object optseq extends ExampleModule
object custom extends ExampleModule {
def ivyDeps = Agg(ivy"com.lihaoyi::os-lib:${osLib}")
}
object vararg extends ExampleModule
object vararg2 extends ExampleModule
object short extends ExampleModule
}