forked from sirthias/parboiled2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
153 lines (135 loc) · 6.09 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
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import scalariform.formatter.preferences._
import scala.xml.transform._
import scala.xml.{Node => XNode, NodeSeq}
import com.typesafe.sbt.osgi.SbtOsgi._
import org.scalajs.sbtplugin.cross.{CrossProject, CrossType}
val commonSettings = Seq(
version := "2.1.2",
scalaVersion := "2.11.7",
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.6",
"-target", "1.6",
"-Xlint:unchecked",
"-Xlint:deprecation"),
scalacOptions ++= List(
"-encoding", "UTF-8",
"-feature",
"-unchecked",
"-deprecation",
"-Xlint",
"-language:_",
"-target:jvm-1.6",
"-Xlog-reflective-calls"))
val formattingSettings = scalariformSettings ++ Seq(
ScalariformKeys.preferences := ScalariformKeys.preferences.value
.setPreference(RewriteArrowSymbols, true)
.setPreference(AlignParameters, true)
.setPreference(AlignSingleLineCaseStatements, true)
.setPreference(DoubleIndentClassDeclaration, true)
.setPreference(PreserveDanglingCloseParenthesis, true))
val pbOsgiSettings = osgiSettings ++ Seq(
packageBin in Runtime <<= OsgiKeys.bundle,
OsgiKeys.exportPackage := Seq("org.parboiled2;-split-package:=merge-first", "org.parboiled2.*;-split-package:=merge-first"))
val publishingSettings = Seq(
publishMavenStyle := true,
useGpg := true,
publishTo <<= version { v: String =>
val nexus = "https://oss.sonatype.org/"
if (v.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 /////////////////////////
val scalaReflect = "org.scala-lang" % "scala-reflect" % "2.11.7" % "provided"
val shapeless = "com.chuusai" %% "shapeless" % "2.3.0" % "compile"
val specs2Core = "org.specs2" %% "specs2-core" % "2.4.17" % "test"
val specs2ScalaCheck = "org.specs2" %% "specs2-scalacheck" % "2.4.17" % "test"
/////////////////////// PROJECTS /////////////////////////
lazy val root = project.in(file("."))
.aggregate(examples, jsonBenchmark, scalaParser)
.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.2"))
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.3.0",
"org.json4s" %% "json4s-jackson" % "3.3.0",
"io.argonaut" %% "argonaut" % "6.1"),
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))
.settings(pbOsgiSettings: _*)
lazy val parboiled = crossProject.crossType(CrossType.Pure)
.dependsOn(parboiledCore)
.settings(commonSettings: _*)
.settings(formattingSettings: _*)
.settings(publishingSettings: _*)
.settings(
libraryDependencies ++= Seq(scalaReflect, shapeless, specs2Core),
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,
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
}
)
.settings(pbOsgiSettings: _*)
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.crossType(CrossType.Pure).in(file("parboiled-core"))
.settings(commonSettings: _*)
.settings(formattingSettings: _*)
.settings(noPublishingSettings: _*)
.settings(
libraryDependencies ++= Seq(scalaReflect, shapeless, specs2Core, specs2ScalaCheck),
generateActionOps := ActionOpsBoilerplate((sourceManaged in Compile).value, streams.value),
(sourceGenerators in Compile) += generateActionOps.taskValue)
.settings(pbOsgiSettings: _*)
lazy val parboiledCoreJVM = parboiledCore.jvm
lazy val parboiledCoreJS = parboiledCore.js