@@ -10,55 +10,73 @@ import scala.xml.{Node => XmlNode, NodeSeq => XmlNodeSeq, _}
1010// JAR_BUILT_BY - Name to be added to Jar metadata field "Built-By" (defaults to System.getProperty("user.name")
1111//
1212
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"
2525
2626lazy val OSName = System .getProperty(" os.name" ) match {
2727 case n if n.startsWith(" Linux" ) => " linux"
2828 case n if n.startsWith(" Mac" ) => " mac"
2929 case n if n.startsWith(" Windows" ) => " win"
3030 case _ => throw new Exception (" Unknown platform!" )
3131}
32-
32+
3333lazy val JavaFXModuleNames = Seq (" base" , " controls" , " fxml" , " graphics" , " media" , " swing" , " web" )
3434lazy val JavaFXModuleLibsProvided : Seq [ModuleID ] =
3535 JavaFXModuleNames .map(m => " org.openjfx" % s " javafx- $m" % _javaFXVersion % " provided" classifier OSName )
3636lazy val JavaFXModuleLibs : Seq [ModuleID ] =
3737 JavaFXModuleNames .map(m => " org.openjfx" % s " javafx- $m" % _javaFXVersion classifier OSName )
3838
39+ def isScala2 (scalaVersion : String ): Boolean = {
40+ CrossVersion .partialVersion(scalaVersion) match {
41+ case Some ((2 , _)) => true
42+ case _ => false
43+ }
44+ }
3945
40- def isScala2_13plus (scalaVersion : String ): Boolean = {
46+ def isScala2_12 (scalaVersion : String ): Boolean = {
4147 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
4450 }
4551}
4652
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+
4769// ScalaFX Extras project
4870lazy val scalaFXExtras = (project in file(" scalafx-extras" )).settings(
4971 scalaFXExtrasSettings,
5072 name := " scalafx-extras" ,
5173 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"
5679 ),
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- })
6280)
6381
6482// ScalaFX Extras Demos project
@@ -70,13 +88,12 @@ lazy val scalaFXExtrasDemos = (project in file("scalafx-extras-demos")).settings
7088 " -Xmx512M" ,
7189 " -Djavafx.verbose"
7290 ),
73- scalacOptions ++= Seq (" -deprecation" ),
7491 libraryDependencies ++= JavaFXModuleLibs ,
7592 publishArtifact := false ,
7693 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+ )
8097).dependsOn(scalaFXExtras % " compile;test->test" )
8198
8299// Resolvers
@@ -89,33 +106,71 @@ lazy val scalaFXExtrasSettings = Seq(
89106 organization := " org.scalafx" ,
90107 version := projectVersion,
91108 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+ ),
98144 // 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 " " ),
100146 // If using Scala 2.12 or lower, enable macro processing through compiler plugin
101147 libraryDependencies ++= (
102- if (! isScala2_13plus (scalaVersion.value))
148+ if (isScala2_12 (scalaVersion.value))
103149 Seq (compilerPlugin(
104- " org.scalamacros" % " paradise" % " 2.1.1" cross CrossVersion .full))
150+ " org.scalamacros" % " paradise" % " 2.1.1" cross CrossVersion .full
151+ ))
105152 else
106153 Seq .empty[sbt.ModuleID ]
107- ),
154+ ),
108155 javacOptions ++= Seq (
109156 // "-target", "1.8",
110157 // "-source", "1.8",
111- " -Xlint:deprecation" ),
158+ " -Xlint:deprecation"
159+ ),
112160 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"
118163 ) ++ 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+ ),
119174 // Use `pomPostProcess` to remove dependencies marked as "provided" from publishing in POM
120175 // This is to avoid dependency on wrong OS version JavaFX libraries
121176 // See also [https://stackoverflow.com/questions/27835740/sbt-exclude-certain-dependency-only-during-publish]
@@ -124,30 +179,29 @@ lazy val scalaFXExtrasSettings = Seq(
124179 override def transform (node : XmlNode ): XmlNodeSeq = node match {
125180 case e : Elem if e.label == " dependency" && e.child.exists(c => c.label == " scope" && c.text == " provided" ) =>
126181 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
129184 Comment (s " provided dependency $organization# $artifact; $version has been omitted " )
130185 case _ => node
131186 }
132187 }).transform(node).head
133188 },
134189 autoAPIMappings := true ,
135190 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 ,
139194 resolvers += Resolver .sonatypeRepo(" snapshots" ),
140195 // 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
143198 Tests .Argument (TestFrameworks .ScalaTest , " -u" , s " $t/junitxmldir " )
144- },
145- shellPrompt in ThisBuild := { state => " sbt:" + Project .extract(state).currentRef.project + " > " }
199+ }
146200) ++ mavenCentralSettings
147201
148202lazy val manifestSetting = packageOptions += {
149203 Package .ManifestAttributes (
150- " Created-By" -> " Simple Build Tool" ,
204+ " Created-By" -> " Simple Build Tool" ,
151205 " Built-By" -> Option (System .getenv(" JAR_BUILT_BY" )).getOrElse(System .getProperty(" user.name" )),
152206 " Build-Jdk" -> System .getProperty(" java.version" ),
153207 " Specification-Title" -> name.value,
@@ -165,14 +219,19 @@ import xerial.sbt.Sonatype._
165219// Metadata needed by Maven Central
166220// See also http://maven.apache.org/pom.html#Developers
167221lazy 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" ,
172226 sonatypeProjectHosting
:= Some (
GitHubHosting (
" org.scalafx" ,
" scalafx-extras" ,
" [email protected] " )),
173- publishMavenStyle := true ,
174- publishTo := sonatypePublishToBundle.value,
227+ publishMavenStyle := true ,
228+ publishTo := sonatypePublishToBundle.value,
175229 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+ )
177236 )
178237)
0 commit comments