forked from swagger-api/swagger-play
-
Notifications
You must be signed in to change notification settings - Fork 4
/
build.sbt
239 lines (224 loc) · 8.48 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
ThisBuild / organization := "com.github.dwickern"
lazy val play27 = ConfigAxis("play27", "play2.7")
lazy val play28 = ConfigAxis("play28", "play2.8")
lazy val play29 = ConfigAxis("play29", "play2.9")
lazy val play30 = ConfigAxis("play30", "play3.0")
lazy val scala212 = "2.12.13"
lazy val scala213 = "2.13.4"
lazy val scala3 = "3.3.1"
// for running tests with a specific release; see testPlayVersionCommand
val playVersion = SettingKey[String]("play-version")
lazy val root = (project in file("."))
.aggregate(swagger.projectRefs: _*)
.settings(
// for IntelliJ import: pick one project from the matrix to use
swagger.finder(play28, VirtualAxis.jvm)(scala213).settings,
target := baseDirectory.value / "target",
ideSkipProject := false,
compile / skip := true,
publish / skip := true,
commands ++= Seq(
testPlayVersionCommand,
publishSignedJdk8,
publishSignedJdk11,
publishJdk8,
publishJdk11,
)
)
lazy val swagger = (projectMatrix in file("."))
.settings(
name := "swagger-play",
libraryDependencies ++= Seq(
"org.specs2" %% "specs2-core" % "4.20.2" % Test,
),
scalacOptions -= "-Xfatal-warnings",
(Test / scalacOptions) --= Seq(
"-Wunused:implicits",
"-Wunused:explicits",
"-Wunused:params",
),
Test / scalacOptions ~= filterConsoleScalacOptions,
Test / parallelExecution := false, // Swagger uses global state which breaks parallel tests
Test / publishArtifact := false,
ideSkipProject := true,
)
.customRow(
scalaVersions = Seq(scala213, scala212),
axisValues = Seq(play27, VirtualAxis.jvm),
_.settings(
moduleName := name.value + "2.7",
playVersion := "2.7.3",
libraryDependencies ++= Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.3",
"com.typesafe.play" %% "play" % playVersion.value,
"com.typesafe.play" %% "routes-compiler" % playVersion.value,
"com.typesafe.play" %% "play-test" % playVersion.value % Test,
"com.typesafe.play" %% "play-specs2" % playVersion.value % Test,
"com.typesafe.play" %% "play-ebean" % "5.0.2" % Test,
"io.swagger" % "swagger-core" % "1.5.24",
"io.swagger" %% "swagger-scala-module" % "1.0.6",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.9.10",
)
)
)
.customRow(
scalaVersions = Seq(scala213, scala212),
axisValues = Seq(play28, VirtualAxis.jvm),
_.settings(
moduleName := name.value + "2.8",
playVersion := "2.8.0",
libraryDependencies ++= {
/** Extra dependencies needed for Play 2.8.8 */
val play288extras = if (VersionNumber(playVersion.value).matchesSemVer(SemanticSelector(">=2.8.8"))) {
Seq(
"io.swagger" % "swagger-core" % "1.6.2" % Provided,
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.11.1" % Provided
)
} else Seq.empty
Seq(
"org.scala-lang.modules" %% "scala-collection-compat" % "2.1.3",
"com.typesafe.play" %% "play" % playVersion.value,
"com.typesafe.play" %% "routes-compiler" % playVersion.value,
"com.typesafe.play" %% "play-test" % playVersion.value % Test,
"com.typesafe.play" %% "play-specs2" % playVersion.value % Test,
"com.typesafe.play" %% "play-ebean" % "6.0.0" % Test,
"io.swagger" % "swagger-core" % "1.6.1",
"io.swagger" %% "swagger-scala-module" % "1.0.6", // FIXME: no version supports jackson 2.10
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.10.5",
) ++ play288extras
}
)
)
.customRow(
scalaVersions = Seq(scala3, scala213),
axisValues = Seq(play29, VirtualAxis.jvm),
_.settings(
moduleName := name.value + "2.9",
playVersion := "2.9.0",
libraryDependencies ++= Seq(
"com.typesafe.play" %% "play" % playVersion.value,
"com.typesafe.play" %% "play-routes-compiler" % playVersion.value,
"com.typesafe.play" %% "play-test" % playVersion.value % Test,
"com.typesafe.play" %% "play-specs2" % playVersion.value % Test,
"com.typesafe.play" %% "play-ebean" % "7.0.0-RC2" % Test,
"io.swagger" % "swagger-core" % "1.6.11",
("io.swagger" %% "swagger-scala-module" % "1.0.6")
.cross(CrossVersion.for3Use2_13)
.exclude("com.fasterxml.jackson.module", "jackson-module-scala_2.13"),
"javax.xml.bind" % "jaxb-api" % "2.3.1",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.14.2",
)
)
)
.customRow(
scalaVersions = Seq(scala3, scala213),
axisValues = Seq(play30, VirtualAxis.jvm),
_.settings(
moduleName := name.value + "3.0",
playVersion := "3.0.0",
libraryDependencies ++= Seq(
"org.playframework" %% "play" % playVersion.value,
"org.playframework" %% "play-routes-compiler" % playVersion.value,
"org.playframework" %% "play-test" % playVersion.value % Test,
"org.playframework" %% "play-specs2" % playVersion.value % Test,
"org.playframework" %% "play-ebean" % "8.0.0-M1" % Test,
"io.swagger" % "swagger-core" % "1.6.11",
("io.swagger" %% "swagger-scala-module" % "1.0.6")
.cross(CrossVersion.for3Use2_13)
.exclude("com.fasterxml.jackson.module", "jackson-module-scala_2.13"),
"javax.xml.bind" % "jaxb-api" % "2.3.1",
"com.fasterxml.jackson.module" %% "jackson-module-scala" % "2.14.2",
)
)
)
/**
* Run tests using a specific Play version
*
* Usage:
* sbt "testPlayVersion 2.8.8"
*/
lazy val testPlayVersionCommand = Command.single("testPlayVersion") { case (state, version) =>
val matrix = Map(
SemanticSelector("2.7.x") -> play27,
SemanticSelector("2.8.x") -> play28,
SemanticSelector("2.9.x") -> play29,
SemanticSelector("3.0.x") -> play30,
)
val projectAxis = matrix
.collectFirst { case (sel, axis) if VersionNumber(version).matchesSemVer(sel) => axis }
.getOrElse { throw new Exception(s"Unsupported Play version: $version") }
swagger.finder(projectAxis, VirtualAxis.jvm).get.foldLeft(state) { case (state, project) =>
val newState = Project.extract(state).appendWithoutSession(Seq(
project / playVersion := version
), state)
Project.extract(newState).runAggregated(project / Test / test, newState)
}
}
lazy val publishSignedJdk8 = Command.command("publishSignedJdk8") { state =>
requireJdkVersion("1.8.x")
publishCommands("publishSigned", play27, play28) ::: state
}
lazy val publishSignedJdk11 = Command.command("publishSignedJdk11") { state =>
requireJdkVersion("11.x")
publishCommands("publishSigned", play29, play30) ::: state
}
lazy val publishJdk8 = Command.command("publishJdk8") { state =>
requireJdkVersion("1.8.x")
publishCommands("publish", play27, play28) ::: state
}
lazy val publishJdk11 = Command.command("publishJdk11") { state =>
requireJdkVersion("11.x")
publishCommands("publish", play29, play30) ::: state
}
def requireJdkVersion(semver: String): Unit = {
val version = VersionNumber(sys.props("java.specification.version"))
if (!version.matchesSemVer(SemanticSelector(semver))) {
sys.error(s"This build requires JDK $semver but found $version")
}
}
def publishCommands(publishTask: String, versions: ConfigAxis*): List[String] = {
val projects = versions.toList.flatMap(ver => swagger.finder(ver).get)
projects.map(proj => s"+${proj.id}/$publishTask")
}
Global / excludeLintKeys += ideSkipProject
ThisBuild / homepage := scmInfo.value.map(_.browseUrl)
ThisBuild / licenses := Seq(License.Apache2)
ThisBuild / pomExtra := {
<developers>
<developer>
<id>fehguy</id>
<name>Tony Tam</name>
<email>[email protected]</email>
</developer>
<developer>
<id>ayush</id>
<name>Ayush Gupta</name>
<email>[email protected]</email>
</developer>
<developer>
<id>rayyildiz</id>
<name>Ramazan AYYILDIZ</name>
<email>[email protected]</email>
</developer>
<developer>
<id>benmccann</id>
<name>Ben McCann</name>
<url>http://www.benmccann.com/</url>
</developer>
<developer>
<id>frantuma</id>
<name>Francesco Tumanischvili</name>
<url>http://www.ft-software.net/</url>
</developer>
<developer>
<id>gmethvin</id>
<name>Greg Methvin</name>
<url>https://methvin.net/</url>
</developer>
<developer>
<id>dwickern</id>
<name>Derek Wickern</name>
<email>[email protected]</email>
</developer>
</developers>
}