-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild.sbt
128 lines (117 loc) · 4.77 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
import ReleaseKeys._
import ReleaseTransformations._
Jvm.`1.8`.required
addCommandAlias("validate", cmdInAll("clean; test"))
inThisBuild(
Def.settings(
organization := "com.mediative",
scalaVersion := "2.12.3",
crossScalaVersions := Seq("2.11.11", "2.12.3"),
scalacOptions += "-Ywarn-unused-import",
publishArtifact in (Compile, packageDoc) := false,
publishArtifact in (Compile, packageSrc) := false,
watchSources ++= (((baseDirectory in ThisBuild).value / "samples") ** "*").get,
doctestTestFramework := DoctestTestFramework.ScalaTest
))
lazy val macroAnnotationSettings = Seq(
resolvers += Resolver.sonatypeRepo("releases"),
resolvers += Resolver.bintrayRepo("scalameta", "maven"),
addCompilerPlugin("org.scalameta" % "paradise" % "3.0.0-M10" cross CrossVersion.full),
scalacOptions += "-Xplugin-require:macroparadise",
scalacOptions in (Compile, console) ~= (_ filterNot (_ contains "paradise")) // macroparadise plugin doesn't work in repl yet.
)
lazy val root = Project(id = "sangria-codegen-root", base = file("."))
.enablePlugins(MediativeGitHubPlugin, MediativeReleasePlugin, SiteScaladocPlugin)
.aggregate(codegen, cli, sbtPlugin)
.settings(
noPublishSettings,
releaseCrossBuild := false,
releaseProcess := Seq[ReleaseStep](
checkSnapshotDependencies, { st: State =>
val v = sys.props.get("version").getOrElse {
st.log.error("No version specified, rerun with `-Dversion=x.y.z`")
sys.exit(1)
}
st.put(versions, (v, v))
},
runClean,
releaseStepCommandAndRemaining("validate"),
setReleaseVersion,
tagRelease,
releaseStepCommandAndRemaining(cmdInAll("publish")),
pushChanges
) ++ postReleaseSteps.value,
// Ignore the macro part when generating the API docs with sbt-unidoc
sources in (ScalaUnidoc, unidoc) ~= { _.filter(_.getName != "GraphQLDomain.scala") },
// Separate API docs for the sbt-plugin
unidocProjectFilter in (ScalaUnidoc, unidoc) := inAnyProject -- inProjects(sbtPlugin),
siteSubdirName in (sbtPlugin, SiteScaladoc) := "sbt-plugin",
addMappingsToSiteDir(
mappings in (sbtPlugin, Compile, packageDoc),
siteSubdirName in (sbtPlugin, SiteScaladoc)
)
)
val codegen = project("sangria-codegen")
.enablePlugins(MediativeBintrayPlugin)
.settings(
macroAnnotationSettings,
unmanagedSourceDirectories in Test += (baseDirectory in ThisBuild).value / "samples",
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.3" % Test,
"org.scalameta" %% "scalameta" % "1.8.0",
"org.sangria-graphql" %% "sangria" % "1.3.0",
"org.typelevel" %% "cats" % "0.9.0"
)
)
val cli = project("sangria-codegen-cli")
.enablePlugins(MediativeBintrayPlugin, BuildInfoPlugin)
.dependsOn(codegen)
.settings(
libraryDependencies ++= Seq(
"org.scalatest" %% "scalatest" % "3.0.3" % Test,
"com.github.alexarchambault" %% "case-app" % "1.2.0-M4",
"io.circe" %% "circe-jawn" % "0.8.0",
"org.sangria-graphql" %% "sangria-circe" % "1.1.0",
"org.scalaj" %% "scalaj-http" % "2.3.0"
),
fork in run := true,
baseDirectory in run := (baseDirectory in ThisBuild).value,
buildInfoKeys := Seq[BuildInfoKey](version),
buildInfoPackage := "com.mediative.sangria.codegen.cli"
)
val sbtPlugin = project("sbt-sangria-codegen")
.enablePlugins(MediativeBintrayPlugin, BuildInfoPlugin)
.settings(
test in Test := Def
.sequential(
test in Test,
scripted.toTask("")
)
.value,
scalaVersion := "2.10.6",
crossScalaVersions := Seq("2.10.6"),
scalacOptions ~= { _.filterNot(Set("-Ywarn-unused-import")) },
publishLocal := publishLocal
.dependsOn(publishLocal in codegen)
.dependsOn(publishLocal in cli)
.value,
sbt.Keys.sbtPlugin := true,
bintrayRepository := "sbt-plugins",
scriptedSettings,
// scriptedBufferLog := false,
scriptedLaunchOpts += "-Dproject.version=" + version.value,
scriptedLaunchOpts += "-Dsamples.dir=" + ((baseDirectory in ThisBuild).value / "samples"),
buildInfoKeys := Seq[BuildInfoKey](
version,
scalaVersion in ThisBuild,
scalaBinaryVersion in ThisBuild),
buildInfoPackage := "com.mediative.sangria.codegen.sbt"
)
def project(name: String) = Project(id = name, base = file(name))
def cmd(versions: String*)(projects: String*)(task: String): String =
(for (v <- versions; p <- projects)
yield
s""";project $p ;set scalaVersion := "$v" ;$task ;project sangria-codegen-root""").mkString
def cmdInAll(task: String) =
cmd("2.11.11", "2.12.3")("sangria-codegen", "sangria-codegen-cli")(task) +
cmd("2.10.6")("sbt-sangria-codegen")(task)