forked from wix-incubator/accord
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
245 lines (217 loc) · 8.11 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
240
241
242
243
244
245
import com.typesafe.sbt.pgp.PgpKeys._
import Helpers._
lazy val publishSettings = Seq(
publishTo := {
val nexus = "https://oss.sonatype.org/"
if ( version.value.trim.endsWith( "SNAPSHOT" ) )
Some( "snapshots" at nexus + "content/repositories/snapshots" )
else
Some( "releases" at nexus + "service/local/staging/deploy/maven2" )
},
publishMavenStyle := true,
scmInfo := Some( ScmInfo( url( "https://github.com/wix/accord" ), "scm:git:[email protected]:wix/accord.git" ) ),
pomExtra in ThisBuild :=
<developers>
<developer>
<id>Holograph</id>
<name>Tomer Gabel</name>
<url>http://www.tomergabel.com</url>
</developer>
</developers>
)
lazy val releaseSettings = Seq(
releaseCrossBuild := true,
releasePublishArtifactsAction := publishSigned.value
)
def noFatalWarningsOn( task: sbt.TaskKey[_] = compile, configuration: sbt.Configuration = Compile ) =
task match {
case `compile` =>
scalacOptions in configuration ~= { _ filterNot { _ == "-Xfatal-warnings" } }
case _ =>
scalacOptions in ( configuration, task ) :=
( scalacOptions in ( Compile, compile ) ).value filterNot { _ == "-Xfatal-warnings" }
}
// Necessary to work around scala/scala-dev#275 (see wix/accord#84)
def providedScalaCompiler =
libraryDependencies += "org.scala-lang" % "scala-compiler" % scalaVersion.value % "provided"
def limitPackageSize( allowedSizeInKB: Int ) =
packageBin in Compile := {
val jar = ( packageBin in Compile ).value
val sizeKB = jar.length() / 1024
if ( sizeKB > allowedSizeInKB )
sys.error( s"Resulting package $jar (size=${sizeKB}KB) is larger than the allowed limit of ${allowedSizeInKB}KB" )
jar
}
lazy val compileOptions = Seq(
scalaVersion := "2.12.0",
crossScalaVersions := ( Helpers.javaVersion match {
case v if v >= 1.8 => Seq( "2.11.1", "2.12.0", "2.13.0-M2" )
case _ => Seq( "2.11.1" )
} ),
scalacOptions ++= Seq(
"-language:reflectiveCalls",
"-feature",
"-deprecation",
"-unchecked",
"-Xfatal-warnings"
),
noFatalWarningsOn( task = doc ) // Warnings aren't considered fatal on document generation
) ++ providedScalaCompiler
lazy val baseSettings =
publishSettings ++
releaseSettings ++
compileOptions ++
Seq(
organization := "com.wix",
homepage := Some( url( "https://github.com/wix/accord" ) ),
licenses := Seq( "Apache-2.0" -> url( "http://www.opensource.org/licenses/Apache-2.0" ) )
)
lazy val noPublish = Seq( publish := {}, publishLocal := {}, publishArtifact := false )
// Projects --
lazy val api =
crossProject
.crossType( CrossType.Pure )
.in( file( "api" ) )
.settings( Seq(
name := "accord-api",
description :=
"Accord is a validation library written in and for Scala. Its chief aim is to provide a composable, " +
"dead-simple and self-contained story for defining validation rules and executing them on object " +
"instances. Feedback, bug reports and improvements are welcome!",
libraryDependencies += "org.scalatest" %%% "scalatest" % "3.0.4" % "test",
noFatalWarningsOn( configuration = Test )
) ++ baseSettings :_* )
.jsSettings( limitPackageSize( 150 ) )
.jvmSettings( limitPackageSize( 90 ) )
lazy val apiJVM = api.jvm
lazy val apiJS = api.js
lazy val scalatest =
crossProject
.crossType( CrossType.Pure )
.in( file( "scalatest" ) )
.dependsOn( api )
.settings( baseSettings ++ Seq(
name := "accord-scalatest",
description := "ScalaTest matchers for the Accord validation library",
libraryDependencies += "org.scalatest" %%% "scalatest" % "3.0.4",
noFatalWarningsOn( configuration = Test )
) :_* )
.jsSettings( limitPackageSize( 100 ) )
.jvmSettings( limitPackageSize( 60 ) )
lazy val scalatestJVM = scalatest.jvm
lazy val scalatestJS = scalatest.js
lazy val specs2 =
crossProject
.crossType( CrossType.Pure )
.in( file( "specs2" ) )
.dependsOn( api )
.settings( baseSettings ++ Seq(
name := "accord-specs2",
noFatalWarningsOn( compile, Test )
) :_* )
.jsSettings(
limitPackageSize( 100 ),
libraryDependencies += "org.specs2" %%% "specs2-core" % "4.0.2"
)
.jvmSettings(
limitPackageSize( 80 ),
libraryDependencies += { scalaVersion.value match {
case v if v startsWith "2.13" => "org.specs2" %% "specs2-core" % "4.0.2"
case _ => "org.specs2" %% "specs2-core" % "3.8.6"
} }
)
lazy val specs2JVM = specs2.jvm
lazy val specs2JS = specs2.js
lazy val core =
crossProject
.crossType( CrossType.Pure )
.in( file( "core" ) )
.dependsOn( api, scalatest % "test->compile" )
.settings( Seq(
name := "accord-core",
libraryDependencies += "org.scalamacros" %% "resetallattrs" % "1.0.0",
libraryDependencies += "org.scala-lang" % "scala-reflect" % scalaVersion.value % "provided",
description :=
"Accord is a validation library written in and for Scala. Its chief aim is to provide a composable, " +
"dead-simple and self-contained story for defining validation rules and executing them on object " +
"instances. Feedback, bug reports and improvements are welcome!",
noFatalWarningsOn( compile, Test ) // Avoid failed test compilation due to deprecations // TODO remove
) ++ baseSettings :_* )
.jvmSettings( limitPackageSize( 500 ) )
.jsSettings( limitPackageSize( 800 ) )
lazy val coreJVM = core.jvm
lazy val coreJS = core.js
lazy val java8 =
crossProject
.crossType( CrossType.Pure )
.in( file( "java8" ) )
.dependsOn( api, core, scalatest % "test->compile" )
.settings( Seq(
name := "accord-java8",
description := "Adds native Accord combinators for Java 8 features",
limitPackageSize( 30 )
) ++ baseSettings :_* )
.jsSettings(
// This library is still not complete (e.g. LocalDateTime isn't implemented); Scala.js support
// for this module is consequently currently disabled.
libraryDependencies += "org.scala-js" %%% "scalajs-java-time" % "0.2.0"
)
lazy val java8JVM = java8.jvm
//lazy val java8JS = java8.js // Disabled until scalajs-java-time comes along. See comment above
lazy val joda =
project
.in( file( "joda" ) )
.settings( baseSettings :_* )
.settings(
name := "accord-joda",
libraryDependencies ++= Seq(
"joda-time" % "joda-time" % "2.9.7",
"org.joda" % "joda-convert" % "1.8.1" // Required for rendering constraints
),
description := "Adds native Accord combinators for Joda-Time",
limitPackageSize( 25 )
)
.dependsOn( apiJVM, coreJVM, scalatestJVM % "test->compile" )
lazy val spring3 =
project
.in( file ( "spring3" ) )
.settings( baseSettings :_* )
.settings( limitPackageSize( 25 ) )
.whenJavaVersion( _ >= 1.9 ) { _.settings(
libraryDependencies ++= Seq(
"javax.xml.bind" % "jaxb-api" % "2.3.0",
"javax.annotation" % "javax.annotation-api" % "1.3.1",
"org.apache.commons" % "commons-lang3" % "3.5"
)
) }
.dependsOn( apiJVM, scalatestJVM % "test->compile", coreJVM % "test->compile" )
lazy val examples =
project
.in( file( "examples" ) )
.settings( baseSettings :_* )
.settings( noPublish :_* )
.settings(
name := "accord-examples",
description := "Sample projects for the Accord validation library.",
noFatalWarningsOn( configuration = Compile )
)
.dependsOn( apiJVM, coreJVM, scalatestJVM % "test->compile", specs2JVM % "test->compile", spring3 )
// Roots --
lazy val jvmRoot =
project
.settings( baseSettings :_* )
.settings( noPublish :_* )
.aggregate( apiJVM, coreJVM, scalatestJVM, specs2JVM, specs2JS, spring3, joda, examples )
.whenJavaVersion( _ >= 1.8 ) { _.aggregate( java8JVM ) }
lazy val jsRoot =
project
.settings( baseSettings :_* )
.settings( noPublish :_* )
.aggregate( apiJS, coreJS, scalatestJS )
//.whenJavaVersion( _ >= 1.8 ) { _.aggregate( java8JS ) }
lazy val root =
project
.in( file( "." ) )
.settings( baseSettings :_* )
.settings( noPublish :_* )
.aggregate( jvmRoot, jsRoot )