-
Notifications
You must be signed in to change notification settings - Fork 156
/
build.sbt
159 lines (141 loc) · 5.27 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
import Dependencies._
val basicSettings = Seq(
shellPrompt := { s => Project.extract(s).currentProject.id + " > " },
version := "1.4.1",
scalaVersion := "2.13.15",
homepage := Some(url("http://parboiled.org")),
organization := "org.parboiled",
organizationHomepage := Some(url("http://parboiled.org")),
description := "Elegant parsing in Java and Scala - lightweight, easy-to-use, powerful",
startYear := Some(2009),
licenses := Seq("Apache 2" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
resolvers ++= resolutionRepos,
javacOptions ++= Seq(
"-deprecation",
"-target", "11",
"-source", "11",
"-encoding", "utf8",
"-Xlint:unchecked"
),
scalacOptions ++= Seq(
"-feature",
"-language:implicitConversions",
"-unchecked",
"-deprecation",
"-encoding",
"utf8"
),
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) =>
Seq("-Xsource:3")
case Some((2, 13)) =>
Seq("-Xsource:3-cross")
case _ =>
Nil
}
},
libraryDependencies ++= Dependencies.test(testNG),
// scaladoc settings
(doc / scalacOptions) ++= Seq("-doc-title", name.value, "-doc-version", version.value),
// publishing
crossScalaVersions := Seq("2.12.20", "2.13.15", "3.3.4"),
scalaBinaryVersion := {
if (CrossVersion.isScalaApiCompatible(scalaVersion.value)) CrossVersion.binaryScalaVersion(scalaVersion.value)
else scalaVersion.value
},
publishMavenStyle := true,
Test / publishArtifact := false,
pomIncludeRepository := { _ => false },
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")
},
pomExtra :=
<scm>
<url>[email protected]:sirthias/parboiled.git</url>
<connection>scm:git:[email protected]:sirthias/parboiled.git</connection>
</scm>
<developers>
<developer>
<id>sirthias</id>
<name>Mathias Doenitz</name>
</developer>
</developers>
)
val javaTestModulesSettings =
if (List("11", "17").exists(System.getProperty("java.version", "").startsWith))
Seq(
Test / fork := true,
Test / javaOptions += "--add-opens=java.base/java.lang=ALL-UNNAMED"
)
else Seq.empty
val noPublishing = Seq(
publishArtifact := false,
publishTo := Some(Resolver.file("Unused transient repository", file("target/unusedrepo"))),
publishConfiguration := publishConfiguration.value.withOverwrite(true)
)
def javaDoc = Seq(
(Compile / doc) := {
val cp = (Compile / doc / fullClasspath).value
val docTarget = (Compile / doc / target).value
val compileSrc = (Compile / javaSource).value
val s = streams.value
def replace(x: Any) = x.toString.replace("parboiled-java", "parboiled-core")
def docLink = name.value match {
case "parboiled-java" => " -linkoffline http://www.decodified.com/parboiled/api/core " + replace(docTarget)
case _ => ""
}
val cmd = "javadoc" +
" -sourcepath " + compileSrc +
" -classpath " + cp.map(_.data).mkString(":") +
" -d " + docTarget +
docLink +
" -encoding utf8" +
" -public" +
" -windowtitle " + name.value + "_" + version.value +
" -subpackages" +
" org.parboiled"
s.log.info(cmd)
sys.process.Process(cmd) ! s.log
docTarget
}
)
lazy val root = Project("root", file("."))
.aggregate(parboiledCore, parboiledJava, parboiledScala, examplesJava, examplesScala)
.settings(basicSettings: _*)
.settings(noPublishing: _*)
lazy val parboiledCore = Project("parboiled-core", file("parboiled-core"))
.settings(basicSettings: _*)
.settings(javaDoc: _*)
.settings(
crossPaths := false,
autoScalaLibrary := false
)
lazy val parboiledJava = Project("parboiled-java", file("parboiled-java"))
.dependsOn(parboiledCore % "compile->compile;test->test")
.settings(basicSettings: _*)
.settings(javaDoc: _*)
.settings(javaTestModulesSettings: _*)
.settings(
libraryDependencies ++= Dependencies.compile(asm, asmTree, asmAnalysis, asmUtil),
Test / javacOptions += "-g", // needed for bytecode rewriting
crossPaths := false,
autoScalaLibrary := false,
// java 17 patch module path by letting parboiled reflective access to java base package
Compile / packageBin / packageOptions += Package.ManifestAttributes("Add-Opens" -> "java.base/java.lang")
)
lazy val parboiledScala = Project("parboiled-scala", file("parboiled-scala"))
.dependsOn(parboiledCore)
.settings(basicSettings: _*)
lazy val examplesJava = Project("examples-java", file("examples-java"))
.dependsOn(parboiledJava % "compile->compile;test->test")
.settings(basicSettings: _*)
.settings(noPublishing: _*)
.settings(javaTestModulesSettings: _*)
.settings(javacOptions += "-g") // needed for bytecode rewriting
lazy val examplesScala = Project("examples-scala", file("examples-scala"))
.dependsOn(parboiledScala % "compile->compile;test->test")
.settings(basicSettings: _*)
.settings(noPublishing: _*)