forked from sirthias/parboiled2
-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.sbt
160 lines (142 loc) · 6.45 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
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import scalariform.formatter.preferences._
import scala.xml.transform._
import scala.xml.{Node => XNode, NodeSeq}
import sbtcrossproject.CrossPlugin.autoImport.{crossProject, CrossType}
lazy val commonSettings = formattingSettings ++ Seq(
version := "2.1.5-SNAPSHOT",
scalaVersion := "2.11.8",
crossScalaVersions := Seq("2.11.8", "2.12.4"),
organization := "org.parboiled",
homepage := Some(new URL("http://parboiled.org")),
description := "Fast and elegant PEG parsing in Scala - lightweight, easy-to-use, powerful",
startYear := Some(2009),
licenses := Seq("Apache-2.0" -> new URL("http://www.apache.org/licenses/LICENSE-2.0.txt")),
javacOptions ++= Seq(
"-encoding", "UTF-8",
"-source", "1.8",
"-target", "1.8",
"-Xlint:unchecked",
"-Xlint:deprecation"),
scalacOptions ++= List(
"-encoding", "UTF-8",
"-feature",
"-unchecked",
"-deprecation",
"-Xlint",
"-language:_",
"-target:jvm-1.8",
"-Xlog-reflective-calls"))
lazy val formattingSettings = Seq(
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(RewriteArrowSymbols, true)
.setPreference(AlignParameters, true)
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(DoubleIndentConstructorArguments, true)
.setPreference(DanglingCloseParenthesis, Preserve)
)
val publishingSettings = Seq(
publishMavenStyle := true,
useGpg := true,
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")
},
pomIncludeRepository := { _ => false },
pomExtra :=
<scm>
<url>[email protected]:sirthias/parboiled2.git</url>
<connection>scm:git:[email protected]:sirthias/parboiled2.git</connection>
</scm>
<developers>
<developer>
<id>sirthias</id>
<name>Mathias Doenitz</name>
</developer>
<developer>
<id>alexander-myltsev</id>
<name>Alexander Myltsev</name>
<url>http://www.linkedin.com/in/alexandermyltsev</url>
</developer>
</developers>)
val noPublishingSettings = Seq(
publishArtifact := false,
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo"))))
/////////////////////// DEPENDENCIES /////////////////////////
def scalaReflect(v: String) = "org.scala-lang" % "scala-reflect" % v % "provided"
val shapeless = "com.chuusai" %% "shapeless" % "2.3.3" % "compile"
val specs2Core = "org.specs2" %% "specs2-core" % "4.2.0" % "test"
val specs2ScalaCheck = "org.specs2" %% "specs2-scalacheck" % "4.2.0" % "test"
/////////////////////// PROJECTS /////////////////////////
lazy val `parboiled-root` = project.in(file("."))
.aggregate(examples, jsonBenchmark)
.aggregate(parboiledJVM, parboiledJS)
.aggregate(parboiledCoreJVM, parboiledCoreJS)
.settings(noPublishingSettings: _*)
lazy val examples = project
.dependsOn(parboiledJVM)
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(libraryDependencies ++= Seq(specs2Core, "io.spray" %% "spray-json" % "1.3.4"))
lazy val bench = inputKey[Unit]("Runs the JSON parser benchmark with a simple standard config")
lazy val jsonBenchmark = project
.dependsOn(examples)
.enablePlugins(JmhPlugin)
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(
libraryDependencies ++= Seq(
"org.json4s" %% "json4s-native" % "3.5.4",
"org.json4s" %% "json4s-jackson" % "3.5.4",
"io.argonaut" %% "argonaut" % "6.2.2"),
bench := (run in Compile).partialInput(" -i 10 -wi 10 -f1 -t1").evaluated)
lazy val scalaParser = project
.dependsOn(parboiledJVM)
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(libraryDependencies ++= Seq(shapeless, specs2Core))
lazy val parboiledOsgiSettings = osgiSettings ++ Seq(
OsgiKeys.exportPackage := Seq("org.parboiled2.*;version=${Bundle-Version}"),
OsgiKeys.privatePackage := Seq()
)
lazy val parboiled = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure)
.dependsOn(parboiledCore)
.settings(commonSettings: _*)
.settings(publishingSettings: _*)
.jvmSettings(
mappings in (Compile, packageBin) ++= (mappings in (parboiledCoreJVM.project, Compile, packageBin)).value,
mappings in (Compile, packageSrc) ++= (mappings in (parboiledCoreJVM.project, Compile, packageSrc)).value,
mappings in (Compile, packageDoc) ++= (mappings in (parboiledCoreJVM.project, Compile, packageDoc)).value
)
.jsSettings(
mappings in (Compile, packageBin) ++= (mappings in (parboiledCoreJS.project, Compile, packageBin)).value,
mappings in (Compile, packageSrc) ++= (mappings in (parboiledCoreJS.project, Compile, packageSrc)).value,
mappings in (Compile, packageDoc) ++= (mappings in (parboiledCoreJS.project, Compile, packageDoc)).value
)
.settings(
libraryDependencies ++= Seq(scalaReflect(scalaVersion.value), shapeless, specs2Core),
mappings in (Compile, packageBin) ~= (_.groupBy(_._2).toSeq.map(_._2.head)), // filter duplicate outputs
mappings in (Compile, packageDoc) ~= (_.groupBy(_._2).toSeq.map(_._2.head)), // filter duplicate outputs
pomPostProcess := { // we need to remove the dependency onto the parboiledCore module from the POM
val filter = new RewriteRule {
override def transform(n: XNode) = if ((n \ "artifactId").text.startsWith("parboiledcore")) NodeSeq.Empty else n
}
new RuleTransformer(filter).transform(_).head
}
).
enablePlugins(SbtOsgi).settings(parboiledOsgiSettings:_*)
lazy val parboiledJVM = parboiled.jvm
lazy val parboiledJS = parboiled.js
lazy val generateActionOps = taskKey[Seq[File]]("Generates the ActionOps boilerplate source file")
lazy val parboiledCore = crossProject(JSPlatform, JVMPlatform)
.crossType(CrossType.Pure).in(file("parboiled-core"))
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(
libraryDependencies ++= Seq(scalaReflect(scalaVersion.value), shapeless, specs2Core, specs2ScalaCheck),
generateActionOps := ActionOpsBoilerplate((sourceManaged in Compile).value, streams.value),
(sourceGenerators in Compile) += generateActionOps.taskValue)
lazy val parboiledCoreJVM = parboiledCore.jvm
lazy val parboiledCoreJS = parboiledCore.js