@@ -10,55 +10,73 @@ import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _}
10
10
// JAR_BUILT_BY - Name to be added to Jar metadata field "Built-By" (defaults to System.getProperty("user.name")
11
11
//
12
12
13
- val projectVersion = " 0.3.6"
14
- val versionTagDir = if (projectVersion.endsWith(" SNAPSHOT" )) " master" else " v." + projectVersion
15
- val _scalaVersions = Seq (" 2.13.4 " , " 2.12.12 " )
16
- val _scalaVersion = _scalaVersions.head
17
- val _javaFXVersion = " 15.0.1 "
18
-
19
- version := projectVersion
20
- crossScalaVersions := _scalaVersions
21
- scalaVersion := _scalaVersion
22
- publishArtifact := false
23
- skip in publish := true
24
- sonatypeProfileName := " org.scalafx"
13
+ val projectVersion = " 0.3.6.1-SNAPSHOT "
14
+ val versionTagDir = if (projectVersion.endsWith(" SNAPSHOT" )) " master" else " v." + projectVersion
15
+ val _scalaVersions = Seq (" 2.13.7 " , " 2.12.15 " , " 3.0.2 " , " 3.1.0 " )
16
+ val _scalaVersion = _scalaVersions.head
17
+ val _javaFXVersion = " 16 "
18
+
19
+ ThisBuild / version := projectVersion
20
+ ThisBuild / crossScalaVersions := _scalaVersions
21
+ ThisBuild / scalaVersion := _scalaVersion
22
+ ThisBuild / publishArtifact := false
23
+ ThisBuild / publish / skip := true
24
+ ThisBuild / sonatypeProfileName := " org.scalafx"
25
25
26
26
lazy val OSName = System .getProperty(" os.name" ) match {
27
27
case n if n.startsWith(" Linux" ) => " linux"
28
28
case n if n.startsWith(" Mac" ) => " mac"
29
29
case n if n.startsWith(" Windows" ) => " win"
30
30
case _ => throw new Exception (" Unknown platform!" )
31
31
}
32
-
32
+
33
33
lazy val JavaFXModuleNames = Seq (" base" , " controls" , " fxml" , " graphics" , " media" , " swing" , " web" )
34
34
lazy val JavaFXModuleLibsProvided : Seq [ModuleID ] =
35
35
JavaFXModuleNames .map(m => " org.openjfx" % s " javafx- $m" % _javaFXVersion % " provided" classifier OSName )
36
36
lazy val JavaFXModuleLibs : Seq [ModuleID ] =
37
37
JavaFXModuleNames .map(m => " org.openjfx" % s " javafx- $m" % _javaFXVersion classifier OSName )
38
38
39
+ def isScala2 (scalaVersion : String ): Boolean = {
40
+ CrossVersion .partialVersion(scalaVersion) match {
41
+ case Some ((2 , _)) => true
42
+ case _ => false
43
+ }
44
+ }
39
45
40
- def isScala2_13plus (scalaVersion : String ): Boolean = {
46
+ def isScala2_12 (scalaVersion : String ): Boolean = {
41
47
CrossVersion .partialVersion(scalaVersion) match {
42
- case Some ((2 , n)) if n >= 13 => true
43
- case _ => false
48
+ case Some ((2 , 12 )) => true
49
+ case _ => false
44
50
}
45
51
}
46
52
53
+ def isScala2_13 (scalaVersion : String ): Boolean = {
54
+ CrossVersion .partialVersion(scalaVersion) match {
55
+ case Some ((2 , 13 )) => true
56
+ case _ => false
57
+ }
58
+ }
59
+
60
+ // Add src/main/scala-3- for Scala 2.13 and older
61
+ // and src/main/scala-3+ for Scala versions older than 3 and newer
62
+ def versionSubDir (scalaVersion : String ): String =
63
+ CrossVersion .partialVersion(scalaVersion) match {
64
+ case Some ((2 , _)) => " scala-2"
65
+ case Some ((3 , _)) => " scala-3"
66
+ case _ => throw new Exception (s " Unsupported scala version $scalaVersion" )
67
+ }
68
+
47
69
// ScalaFX Extras project
48
70
lazy val scalaFXExtras = (project in file(" scalafx-extras" )).settings(
49
71
scalaFXExtrasSettings,
50
72
name := " scalafx-extras" ,
51
73
description := " The ScalaFX Extras" ,
52
- scalacOptions in(Compile , doc) ++= Seq (
53
- " -sourcepath" , baseDirectory.value.toString,
54
- " -doc-root-content" , baseDirectory.value + " /src/main/scala/root-doc.creole" ,
55
- " -doc-source-url" , " https://github.com/SscalaFX-Extras/scalafx-extras/blob/" + versionTagDir + " /scalafx/€{FILE_PATH}.scala"
74
+ Compile / doc / scalacOptions ++= Seq (
75
+ " -sourcepath" ,
76
+ baseDirectory.value.toString,
77
+ " -doc-root-content" ,
78
+ baseDirectory.value + " /src/main/scala/root-doc.creole"
56
79
),
57
- scalacOptions in(Compile , doc) ++= (
58
- Option (System .getenv(" GRAPHVIZ_DOT_PATH" )) match {
59
- case Some (path) => Seq (" -diagrams" , " -diagrams-dot-path" , path)
60
- case None => Seq .empty[String ]
61
- })
62
80
)
63
81
64
82
// ScalaFX Extras Demos project
@@ -70,13 +88,12 @@ lazy val scalaFXExtrasDemos = (project in file("scalafx-extras-demos")).settings
70
88
" -Xmx512M" ,
71
89
" -Djavafx.verbose"
72
90
),
73
- scalacOptions ++= Seq (" -deprecation" ),
74
91
libraryDependencies ++= JavaFXModuleLibs ,
75
92
publishArtifact := false ,
76
93
libraryDependencies ++= Seq (
77
- " com.typesafe.scala-logging" %% " scala-logging" % " 3.9.2 " ,
78
- " ch.qos.logback" % " logback-classic" % " 1.2.3 "
79
- ),
94
+ " com.typesafe.scala-logging" %% " scala-logging" % " 3.9.4 " ,
95
+ " ch.qos.logback" % " logback-classic" % " 1.2.7 "
96
+ )
80
97
).dependsOn(scalaFXExtras % " compile;test->test" )
81
98
82
99
// Resolvers
@@ -89,33 +106,71 @@ lazy val scalaFXExtrasSettings = Seq(
89
106
organization := " org.scalafx" ,
90
107
version := projectVersion,
91
108
crossScalaVersions := _scalaVersions,
92
- scalaVersion := _scalaVersion,
93
- scalacOptions ++= Seq (" -unchecked" , " -deprecation" , " -Xcheckinit" , " -encoding" , " utf8" , " -feature" ),
94
- scalacOptions in(Compile , doc) ++= Opts .doc.title(" ScalaFX Extras API" ),
95
- scalacOptions in(Compile , doc) ++= Opts .doc.version(projectVersion),
96
- scalacOptions in(Compile , doc) += s " -doc-external-doc: ${scalaInstance.value.libraryJars.head}#http://www.scala-lang.org/api/ ${scalaVersion.value}/ " ,
97
- scalacOptions in(Compile , doc) ++= Seq (" -doc-footer" , s " ScalaFX Extras API v. $projectVersion" ),
109
+ scalaVersion := _scalaVersion,
110
+ // SAdd version specific directories
111
+ Compile / unmanagedSourceDirectories += (Compile / sourceDirectory).value / versionSubDir(scalaVersion.value),
112
+ Test / unmanagedSourceDirectories += (Test / sourceDirectory).value / versionSubDir(scalaVersion.value),
113
+ //
114
+ scalacOptions ++= Seq (
115
+ " -unchecked" ,
116
+ " -deprecation" ,
117
+ " -encoding" ,
118
+ " utf8" ,
119
+ " -feature"
120
+ ) ++
121
+ (
122
+ if (isScala2(scalaVersion.value))
123
+ Seq (" -Xcheckinit" )
124
+ else
125
+ Seq .empty[String ]
126
+ ),
127
+ Compile / doc / scalacOptions ++= Opts .doc.title(" ScalaFX Extras API" ),
128
+ Compile / doc / scalacOptions ++= Opts .doc.version(projectVersion),
129
+ Compile / doc / scalacOptions ++= Seq (" -doc-footer" , s " ScalaFX Extras API v. $projectVersion" ),
130
+ Compile / doc / scalacOptions ++= (
131
+ if (isScala2(scalaVersion.value))
132
+ Seq (
133
+ s " -doc-external-doc: ${scalaInstance.value.libraryJars.head}#http://www.scala-lang.org/api/ ${scalaVersion.value}/ " ,
134
+ " -doc-source-url" , " https://github.com/SscalaFX-Extras/scalafx-extras/blob/" + versionTagDir + " /scalafx/€{FILE_PATH}.scala"
135
+ ) ++ (
136
+ Option (System .getenv(" GRAPHVIZ_DOT_PATH" )) match {
137
+ case Some (path) => Seq (" -diagrams" , " -diagrams-dot-path" , path)
138
+ case None => Seq .empty[String ]
139
+ }
140
+ )
141
+ else
142
+ Seq .empty[String ]
143
+ ),
98
144
// If using Scala 2.13 or better, enable macro processing through compiler option
99
- scalacOptions += (if (isScala2_13plus (scalaVersion.value)) " -Ymacro-annotations" else " " ),
145
+ scalacOptions += (if (isScala2_13 (scalaVersion.value)) " -Ymacro-annotations" else " " ),
100
146
// If using Scala 2.12 or lower, enable macro processing through compiler plugin
101
147
libraryDependencies ++= (
102
- if (! isScala2_13plus (scalaVersion.value))
148
+ if (isScala2_12 (scalaVersion.value))
103
149
Seq (compilerPlugin(
104
- " org.scalamacros" % " paradise" % " 2.1.1" cross CrossVersion .full))
150
+ " org.scalamacros" % " paradise" % " 2.1.1" cross CrossVersion .full
151
+ ))
105
152
else
106
153
Seq .empty[sbt.ModuleID ]
107
- ),
154
+ ),
108
155
javacOptions ++= Seq (
109
156
// "-target", "1.8",
110
157
// "-source", "1.8",
111
- " -Xlint:deprecation" ),
158
+ " -Xlint:deprecation"
159
+ ),
112
160
libraryDependencies ++= Seq (
113
- " com.beachape" %% " enumeratum" % " 1.6.1" ,
114
- " org.scala-lang" % " scala-reflect" % scalaVersion.value,
115
- " org.scalafx" %% " scalafx" % " 15.0.1-R21" ,
116
- " org.scalafx" %% " scalafxml-core-sfx8" % " 0.5" ,
117
- " org.scalatest" %% " scalatest" % " 3.2.3" % " test"
161
+ " org.scalafx" %% " scalafx" % " 16.0.0-R25" ,
162
+ " org.scalatest" %% " scalatest" % " 3.2.10" % " test"
118
163
) ++ JavaFXModuleLibsProvided ,
164
+ libraryDependencies ++= (
165
+ if (isScala2(scalaVersion.value))
166
+ Seq (
167
+ " com.beachape" %% " enumeratum" % " 1.7.0" ,
168
+ " org.scala-lang" % " scala-reflect" % scalaVersion.value,
169
+ " org.scalafx" %% " scalafxml-core-sfx8" % " 0.5"
170
+ )
171
+ else
172
+ Seq .empty[sbt.ModuleID ]
173
+ ),
119
174
// Use `pomPostProcess` to remove dependencies marked as "provided" from publishing in POM
120
175
// This is to avoid dependency on wrong OS version JavaFX libraries
121
176
// See also [https://stackoverflow.com/questions/27835740/sbt-exclude-certain-dependency-only-during-publish]
@@ -124,30 +179,29 @@ lazy val scalaFXExtrasSettings = Seq(
124
179
override def transform (node : XmlNode ): XmlNodeSeq = node match {
125
180
case e : Elem if e.label == " dependency" && e.child.exists(c => c.label == " scope" && c.text == " provided" ) =>
126
181
val organization = e.child.filter(_.label == " groupId" ).flatMap(_.text).mkString
127
- val artifact = e.child.filter(_.label == " artifactId" ).flatMap(_.text).mkString
128
- val version = e.child.filter(_.label == " version" ).flatMap(_.text).mkString
182
+ val artifact = e.child.filter(_.label == " artifactId" ).flatMap(_.text).mkString
183
+ val version = e.child.filter(_.label == " version" ).flatMap(_.text).mkString
129
184
Comment (s " provided dependency $organization# $artifact; $version has been omitted " )
130
185
case _ => node
131
186
}
132
187
}).transform(node).head
133
188
},
134
189
autoAPIMappings := true ,
135
190
manifestSetting,
136
- fork in run := true ,
137
- fork in Test := true ,
138
- parallelExecution in Test := false ,
191
+ run / fork := true ,
192
+ Test / fork := true ,
193
+ Test / parallelExecution := false ,
139
194
resolvers += Resolver .sonatypeRepo(" snapshots" ),
140
195
// print junit-style XML for CI
141
- testOptions in Test += {
142
- val t = (target in Test ).value
196
+ Test / testOptions += {
197
+ val t = (Test / target ).value
143
198
Tests .Argument (TestFrameworks .ScalaTest , " -u" , s " $t/junitxmldir " )
144
- },
145
- shellPrompt in ThisBuild := { state => " sbt:" + Project .extract(state).currentRef.project + " > " }
199
+ }
146
200
) ++ mavenCentralSettings
147
201
148
202
lazy val manifestSetting = packageOptions += {
149
203
Package .ManifestAttributes (
150
- " Created-By" -> " Simple Build Tool" ,
204
+ " Created-By" -> " Simple Build Tool" ,
151
205
" Built-By" -> Option (System .getenv(" JAR_BUILT_BY" )).getOrElse(System .getProperty(" user.name" )),
152
206
" Build-Jdk" -> System .getProperty(" java.version" ),
153
207
" Specification-Title" -> name.value,
@@ -165,14 +219,19 @@ import xerial.sbt.Sonatype._
165
219
// Metadata needed by Maven Central
166
220
// See also http://maven.apache.org/pom.html#Developers
167
221
lazy val mavenCentralSettings = Seq (
168
- homepage := Some (new URL (" http://www.scalafx.org/" )),
169
- startYear := Some (2016 ),
170
- licenses := Seq ((" BSD" , new URL (" https://github.com/scalafx/scalafx-extras/blob/master/LICENSE.txt" ))),
171
- sonatypeProfileName := " org.scalafx" ,
222
+ homepage := Some (new URL (" http://www.scalafx.org/" )),
223
+ startYear := Some (2016 ),
224
+ licenses := Seq ((" BSD" , new URL (" https://github.com/scalafx/scalafx-extras/blob/master/LICENSE.txt" ))),
225
+ sonatypeProfileName := " org.scalafx" ,
172
226
sonatypeProjectHosting
:= Some (
GitHubHosting (
" org.scalafx" ,
" scalafx-extras" ,
" [email protected] " )),
173
- publishMavenStyle := true ,
174
- publishTo := sonatypePublishToBundle.value,
227
+ publishMavenStyle := true ,
228
+ publishTo := sonatypePublishToBundle.value,
175
229
developers := List (
176
- Developer (id
= " jpsacha" , name
= " Jarek Sacha" , email
= " [email protected] " , url
= url(
" https://github.com/jpsacha" ))
230
+ Developer (
231
+ id = " jpsacha" ,
232
+ name = " Jarek Sacha" ,
233
+
234
+ url = url(" https://github.com/jpsacha" )
235
+ )
177
236
)
178
237
)
0 commit comments