forked from ScalablyTyped/Converter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
163 lines (146 loc) · 5.44 KB
/
build.sbt
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
import scala.sys.process.stringToProcess
lazy val latestTag = "git tag -l --sort=committerdate".!!.linesIterator.toVector.last.drop( /* 'v' */ 1)
// BSP setup to use with bloop
Global / bloopExportJarClassifiers := Some(Set("sources"))
// bloop hasn't upgraded to scala-xml 2 yet
ThisBuild / libraryDependencySchemes ++= Seq("org.scala-lang.modules" %% "scala-xml" % VersionScheme.Always)
lazy val core = project
.configure(baseSettings)
.settings(libraryDependencies ++= Seq(Deps.ammoniteOps, Deps.osLib, Deps.sourcecode) ++ Deps.circe)
lazy val logging = project
.configure(baseSettings)
.settings(libraryDependencies ++= Seq(Deps.sourcecode, Deps.fansi))
lazy val ts = project
.configure(baseSettings, optimize)
.dependsOn(core, logging)
.settings(libraryDependencies += Deps.parserCombinators)
lazy val docs = project
.in(file("converter-docs"))
.settings(
mdocVariables := Map("VERSION" -> latestTag),
moduleName := "converter-docs",
publish / skip := true,
)
.enablePlugins(MdocPlugin, DocusaurusPlugin)
lazy val scalajs = project
.dependsOn(core, logging)
.configure(baseSettings, optimize)
.settings(libraryDependencies ++= Seq(Deps.scalaXml))
lazy val phases = project
.dependsOn(core, logging)
.configure(baseSettings, optimize)
lazy val `importer-portable` = project
.configure(baseSettings, optimize)
.dependsOn(ts, scalajs, phases)
.enablePlugins(BuildInfoPlugin)
.settings(
buildInfoPackage := "org.scalablytyped.converter.internal",
buildInfoKeys := Seq[BuildInfoKey](
"gitSha" -> "git rev-parse -1 HEAD".!!.split("\n").last.trim,
"version" -> version.value,
),
)
lazy val importer = project
.dependsOn(`importer-portable`)
.configure(baseSettings, optimize)
.settings(
libraryDependencies ++= Seq(
Deps.bloop,
Deps.coursier,
Deps.scalatest % Test,
),
Test / fork := true,
assembly / test := {},
assembly / mainClass := Some("org.scalablytyped.converter.Main"),
/* meh meh meh */
assembly / assemblyMergeStrategy := {
case foo if foo.contains("io/github/soc/directories/") => MergeStrategy.first
case foo if foo.contains("reflect.properties") => MergeStrategy.first
case foo if foo.contains("scala-collection-compat.properties") => MergeStrategy.first
case foo if foo.endsWith("module-info.class") => MergeStrategy.discard
case foo if foo.contains("org/fusesource") => MergeStrategy.first
case foo if foo.contains("META-INF/native/") => MergeStrategy.first
case foo if foo.contains("scala/annotation") => MergeStrategy.last
case foo if foo.contains("META-INF/sisu/javax.inject.Named") => MergeStrategy.discard
case other => (assembly / assemblyMergeStrategy).value(other)
},
Test / testOptions += Tests.Argument("-P4"),
)
lazy val cli = project
.dependsOn(importer)
.configure(baseSettings)
.settings(
libraryDependencies += Deps.scopt,
)
lazy val `sbt-converter` = project
.dependsOn(`importer-portable`)
.enablePlugins(ScriptedPlugin)
.configure(baseSettings)
.settings(
name := "sbt-converter",
addSbtPlugin("ch.epfl.scala" % "sbt-scalajs-bundler" % "0.21.1"),
addSbtPlugin("org.scala-js" % "sbt-scalajs" % "1.15.0"),
sbtPlugin := true,
// set up 'scripted; sbt plugin for testing sbt plugins
scriptedBufferLog := false,
scriptedLaunchOpts ++= Seq("-Xmx2048M", "-Dplugin.version=" + version.value),
watchSources ++= {
(sourceDirectory.value ** "*").get
},
libraryDependencies ++= Seq(Deps.awssdkS3),
)
lazy val `import-scalajs-definitions` = project
.configure(baseSettings)
.dependsOn(importer)
.settings(
libraryDependencies ++= List("org.scala-lang" % "scalap" % scalaVersion.value),
publish / skip := true,
)
lazy val root = project
.in(file("."))
.settings(
name := "converter-root",
publish / skip := true,
)
.configure(baseSettings)
.aggregate(logging, core, phases, ts, scalajs, `importer-portable`, `sbt-converter`, importer, cli)
lazy val baseSettings: Project => Project =
_.settings(
sonatypeCredentialHost := Sonatype.sonatype01,
sonatypeProfileName := "org.scalablytyped",
organization := "org.scalablytyped.converter",
licenses += ("GPL-3.0", url("https://opensource.org/licenses/GPL-3.0")),
homepage := Some(url("https://github.com/ScalablyTyped/Converter")),
developers := List(
Developer(
"oyvindberg",
"Øyvind Raddum Berg",
"elacin@gmail.com",
url("https://github.com/oyvindberg"),
),
),
pgpSigningKey := Some("763825CAF9034C05E56A042EF5BAF6416BD9F936"),
scalaVersion := "2.12.18",
scalacOptions ~= (_.filterNot(Set("-Ywarn-unused:imports", "-Ywarn-unused:params", "-Xfatal-warnings"))),
/* disable scaladoc */
Compile / doc / sources := Nil,
)
lazy val optimize: Project => Project =
_.settings(
scalacOptions ++= {
if (insideCI.value || !isSnapshot.value)
Seq(
"-opt:l:inline",
"-opt:l:method",
"-opt:simplify-jumps",
"-opt:compact-locals",
"-opt:copy-propagation",
"-opt:redundant-casts",
"-opt:box-unbox",
"-opt:nullness-tracking",
"-opt-inline-from:org.scalablytyped.converter.internal.**",
"-opt-warnings",
)
else Nil
},
)