-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.sbt
179 lines (163 loc) · 7.58 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
import java.net.URL
import scala.xml.transform.{RewriteRule, RuleTransformer}
import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _}
// @formatter:off
//
// Environment variables used by the build:
// GRAPHVIZ_DOT_PATH - Full path to Graphviz dot utility. If not defined Scaladocs will be build without diagrams.
// JAR_BUILT_BY - Name to be added to Jar metadata field "Built-By" (defaults to System.getProperty("user.name")
//
val projectVersion = "0.3.3"
val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v." + projectVersion
val _scalaVersions = Seq("2.13.1", "2.12.10")
val _scalaVersion = _scalaVersions.head
val _scalaFXVersion = "12.0.2"
version := projectVersion
crossScalaVersions := _scalaVersions
scalaVersion := _scalaVersion
publishArtifact := false
skip in publish := true
sonatypeProfileName := "org.scalafx"
lazy val OSName = System.getProperty("os.name") match {
case n if n.startsWith("Linux") => "linux"
case n if n.startsWith("Mac") => "mac"
case n if n.startsWith("Windows") => "win"
case _ => throw new Exception("Unknown platform!")
}
lazy val JavaFXModuleNames = Seq("base", "controls", "fxml", "graphics", "media", "swing", "web")
lazy val JavaFXModuleLibsProvided: Seq[ModuleID] =
JavaFXModuleNames.map(m => "org.openjfx" % s"javafx-$m" % _scalaFXVersion % "provided" classifier OSName)
lazy val JavaFXModuleLibs: Seq[ModuleID] =
JavaFXModuleNames.map(m => "org.openjfx" % s"javafx-$m" % _scalaFXVersion classifier OSName)
def isScala2_13plus(scalaVersion: String): Boolean = {
CrossVersion.partialVersion(scalaVersion) match {
case Some((2, n)) if n >= 13 => true
case _ => false
}
}
// ScalaFX Extras project
lazy val scalaFXExtras = (project in file("scalafx-extras")).settings(
scalaFXExtrasSettings,
name := "scalafx-extras",
description := "The ScalaFX Extras",
scalacOptions in(Compile, doc) ++= Seq(
"-sourcepath", baseDirectory.value.toString,
"-doc-root-content", baseDirectory.value + "/src/main/scala/root-doc.creole",
"-doc-source-url", "https://github.com/SscalaFX-Extras/scalafx-extras/blob/" + versionTagDir + "/scalafx/€{FILE_PATH}.scala"
),
scalacOptions in(Compile, doc) ++= (
Option(System.getenv("GRAPHVIZ_DOT_PATH")) match {
case Some(path) => Seq("-diagrams", "-diagrams-dot-path", path)
case None => Seq.empty[String]
})
)
// ScalaFX Extras Demos project
lazy val scalaFXExtrasDemos = (project in file("scalafx-extras-demos")).settings(
scalaFXExtrasSettings,
name := "scalafx-extras-demos",
description := "The ScalaFX Extras demonstrations",
javaOptions ++= Seq(
"-Xmx512M",
"-Djavafx.verbose"
),
scalacOptions ++= Seq("-deprecation"),
libraryDependencies ++= JavaFXModuleLibs,
publishArtifact := false,
libraryDependencies ++= Seq(
"com.typesafe.scala-logging" %% "scala-logging" % "3.9.2",
"ch.qos.logback" % "logback-classic" % "1.2.3"
),
).dependsOn(scalaFXExtras % "compile;test->test")
// Resolvers
// Add snapshots to root project to enable compilation with Scala SNAPSHOT compiler,
// e.g., 2.11.0-SNAPSHOT
resolvers += Resolver.sonatypeRepo("snapshots")
// Common settings
lazy val scalaFXExtrasSettings = Seq(
organization := "org.scalafx",
version := projectVersion,
crossScalaVersions := _scalaVersions,
scalaVersion := _scalaVersion,
scalacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8", "-feature"),
scalacOptions in(Compile, doc) ++= Opts.doc.title("ScalaFX Extras API"),
scalacOptions in(Compile, doc) ++= Opts.doc.version(projectVersion),
scalacOptions in(Compile, doc) += s"-doc-external-doc:${scalaInstance.value.libraryJars.head}#http://www.scala-lang.org/api/${scalaVersion.value}/",
scalacOptions in(Compile, doc) ++= Seq("-doc-footer", s"ScalaFX Extras API v.$projectVersion"),
// If using Scala 2.13 or better, enable macro processing through compiler option
scalacOptions += (if (isScala2_13plus(scalaVersion.value)) "-Ymacro-annotations" else ""),
// If using Scala 2.12 or lower, enable macro processing through compiler plugin
libraryDependencies ++= (
if (!isScala2_13plus(scalaVersion.value))
Seq(compilerPlugin(
"org.scalamacros" % "paradise" % "2.1.1" cross CrossVersion.full))
else
Seq.empty[sbt.ModuleID]
),
javacOptions ++= Seq(
// "-target", "1.8",
// "-source", "1.8",
"-Xlint:deprecation"),
libraryDependencies ++= Seq(
"com.beachape" %% "enumeratum" % "1.5.15",
"org.scala-lang" % "scala-reflect" % scalaVersion.value,
"org.scalafx" %% "scalafx" % "12.0.2-R18",
"org.scalafx" %% "scalafxml-core-sfx8" % "0.5",
"org.scalatest" %% "scalatest" % "3.1.0" % "test"
) ++ JavaFXModuleLibsProvided,
// Use `pomPostProcess` to remove dependencies marked as "provided" from publishing in POM
// This is to avoid dependency on wrong OS version JavaFX libraries
// See also [https://stackoverflow.com/questions/27835740/sbt-exclude-certain-dependency-only-during-publish]
pomPostProcess := { node: XmlNode =>
new RuleTransformer(new RewriteRule {
override def transform(node: XmlNode): XmlNodeSeq = node match {
case e: Elem if e.label == "dependency" && e.child.exists(c => c.label == "scope" && c.text == "provided") =>
val organization = e.child.filter(_.label == "groupId").flatMap(_.text).mkString
val artifact = e.child.filter(_.label == "artifactId").flatMap(_.text).mkString
val version = e.child.filter(_.label == "version").flatMap(_.text).mkString
Comment(s"provided dependency $organization#$artifact;$version has been omitted")
case _ => node
}
}).transform(node).head
},
autoAPIMappings := true,
manifestSetting,
fork in run := true,
fork in Test := true,
parallelExecution in Test := false,
resolvers += Resolver.sonatypeRepo("snapshots"),
// print junit-style XML for CI
testOptions in Test += {
val t = (target in Test).value
Tests.Argument(TestFrameworks.ScalaTest, "-u", s"$t/junitxmldir")
},
shellPrompt in ThisBuild := { state => "sbt:" + Project.extract(state).currentRef.project + "> " }
) ++ mavenCentralSettings
lazy val manifestSetting = packageOptions += {
Package.ManifestAttributes(
"Created-By" -> "Simple Build Tool",
"Built-By" -> Option(System.getenv("JAR_BUILT_BY")).getOrElse(System.getProperty("user.name")),
"Build-Jdk" -> System.getProperty("java.version"),
"Specification-Title" -> name.value,
"Specification-Version" -> version.value,
"Specification-Vendor" -> organization.value,
"Implementation-Title" -> name.value,
"Implementation-Version" -> version.value,
"Implementation-Vendor-Id" -> organization.value,
"Implementation-Vendor" -> organization.value
)
}
import xerial.sbt.Sonatype._
// Metadata needed by Maven Central
// See also http://maven.apache.org/pom.html#Developers
lazy val mavenCentralSettings = Seq(
homepage := Some(new URL("http://www.scalafx.org/")),
startYear := Some(2016),
licenses := Seq(("BSD", new URL("https://github.com/scalafx/scalafx-extras/blob/master/LICENSE.txt"))),
sonatypeProfileName := "org.scalafx",
sonatypeProjectHosting := Some(GitHubHosting("org.scalafx", "scalafx-extras", "[email protected]")),
publishMavenStyle := true,
publishTo := sonatypePublishToBundle.value,
developers := List(
Developer(id="jpsacha", name="Jarek Sacha", email="[email protected]", url=url("https://github.com/jpsacha"))
)
)