forked from alexander-myltsev/parboiled2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sbt
137 lines (122 loc) · 5.4 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
import com.typesafe.sbt.SbtScalariform.ScalariformKeys
import scalariform.formatter.preferences._
import scala.xml.transform._
import scala.xml.{Node => XNode, NodeSeq}
val commonSettings = Seq(
version := "2.1.0-SNAPSHOT",
scalaVersion := "2.11.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.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 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.4" % "provided"
val shapeless = "com.chuusai" %% "shapeless" % "2.0.0" % "compile"
val specs2Core = "org.specs2" %% "specs2-core" % "2.4.13" % "test"
val specs2ScalaCheck = "org.specs2" %% "specs2-scalacheck" % "2.4.13" % "test"
/////////////////////// PROJECTS /////////////////////////
lazy val root = project.in(file("."))
.aggregate(examples, jsonBenchmark, scalaParser, parboiled, parboiledCore)
.settings(noPublishingSettings: _*)
lazy val examples = project
.dependsOn(parboiled)
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(libraryDependencies ++= Seq(specs2Core, "io.spray" %% "spray-json" % "1.3.1"))
lazy val bench = inputKey[Unit]("Runs the JSON parser benchmark with a simple standard config")
lazy val jsonBenchmark = project
.dependsOn(examples)
.settings(commonSettings: _*)
.settings(jmhSettings: _*)
.settings(noPublishingSettings: _*)
.settings(
libraryDependencies ++= Seq(
"org.json4s" %% "json4s-native" % "3.2.10",
"org.json4s" %% "json4s-jackson" % "3.2.10",
"io.argonaut" %% "argonaut" % "6.0.4"),
bench := (run in Compile).partialInput(" -i 10 -wi 10 -f1 -t1").evaluated)
lazy val scalaParser = project
.dependsOn(parboiled)
.settings(commonSettings: _*)
.settings(noPublishingSettings: _*)
.settings(libraryDependencies ++= Seq(shapeless, specs2Core))
lazy val parboiled = project
.dependsOn(parboiledCore)
.settings(commonSettings: _*)
.settings(formattingSettings: _*)
.settings(publishingSettings: _*)
.settings(
libraryDependencies ++= Seq(scalaReflect, shapeless, specs2Core),
mappings in (Compile, packageBin) ++= (mappings in (parboiledCore.project, Compile, packageBin)).value,
mappings in (Compile, packageSrc) ++= (mappings in (parboiledCore.project, Compile, packageSrc)).value,
mappings in (Compile, packageDoc) ++= (mappings in (parboiledCore.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
}
)
lazy val generateActionOps = taskKey[Seq[File]]("Generates the ActionOps boilerplate source file")
lazy val parboiledCore = project.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
)