11import java .net .URL
22
3+ import scala .xml .transform .{RewriteRule , RuleTransformer }
4+ import scala .xml .{Node => XmlNode , NodeSeq => XmlNodeSeq , _ }
5+
36// @formatter:off
47
58//
@@ -8,9 +11,9 @@ import java.net.URL
811// JAR_BUILT_BY - Name to be added to Jar metadata field "Built-By" (defaults to System.getProperty("user.name")
912//
1013
11- val projectVersion = " 0.3.0 "
14+ val projectVersion = " 0.3.1-SNAPSHOT "
1215val versionTagDir = if (projectVersion.endsWith(" SNAPSHOT" )) " master" else " v" + projectVersion
13- val _scalaVersions = Seq (" 2.12.7 " )
16+ val _scalaVersions = Seq (" 2.13.0 " , " 2. 12.9 " )
1417val _scalaVersion = _scalaVersions.head
1518
1619crossScalaVersions := _scalaVersions
@@ -24,8 +27,15 @@ lazy val OSName = System.getProperty("os.name") match {
2427}
2528
2629lazy val JavaFXModuleNames = Seq (" base" , " controls" , " fxml" , " graphics" , " media" , " swing" , " web" )
27- lazy val JavaFXModuleLibs : Seq [ModuleID ] =
28- JavaFXModuleNames .map(m => " org.openjfx" % s " javafx- $m" % " 11" classifier OSName )
30+ lazy val JavaFXModuleLibs : Seq [ModuleID ] =
31+ JavaFXModuleNames .map(m => " org.openjfx" % s " javafx- $m" % " 12.0.2" classifier OSName )
32+
33+ def isScala2_13plus (scalaVersion : String ): Boolean = {
34+ CrossVersion .partialVersion(scalaVersion) match {
35+ case Some ((2 , n)) if n >= 13 => true
36+ case _ => false
37+ }
38+ }
2939
3040// ScalaFX Extras project
3141lazy val scalaFXExtras = (project in file(" scalafx-extras" )).settings(
@@ -39,7 +49,7 @@ lazy val scalaFXExtras = (project in file("scalafx-extras")).settings(
3949 ) ++ (Option (System .getenv(" GRAPHVIZ_DOT_PATH" )) match {
4050 case Some (path) => Seq (" -diagrams" , " -diagrams-dot-path" , path)
4151 case None => Seq .empty[String ]
42- }) ++ ( if (_scalaVersion.startsWith( " 2.11 " )) Seq ( " -Xexperimental " ) else Seq .empty[ String ])
52+ })
4353)
4454
4555// ScalaFX Extras Demos project
@@ -51,10 +61,10 @@ lazy val scalaFXExtrasDemos = (project in file("scalafx-extras-demos")).settings
5161 " -Xmx512M" ,
5262 " -Djavafx.verbose"
5363 ),
54- addCompilerPlugin( " org.scalamacros " % " paradise " % " 2.1.1 " cross CrossVersion .full ),
64+ scalacOptions ++= Seq ( " -deprecation " ),
5565 publishArtifact := false ,
5666 libraryDependencies ++= Seq (
57- " com.typesafe.scala-logging" %% " scala-logging" % " 3.9.0 " ,
67+ " com.typesafe.scala-logging" %% " scala-logging" % " 3.9.2 " ,
5868 " ch.qos.logback" % " logback-classic" % " 1.2.3"
5969 )
6070).dependsOn(scalaFXExtras % " compile;test->test" )
@@ -76,20 +86,45 @@ lazy val scalaFXExtrasSettings = Seq(
7686 scalacOptions in(Compile , doc) ++= Opts .doc.version(projectVersion),
7787 scalacOptions in(Compile , doc) += s " -doc-external-doc: ${scalaInstance.value.libraryJar}#http://www.scala-lang.org/api/ ${scalaVersion.value}/ " ,
7888 scalacOptions in(Compile , doc) ++= Seq (" -doc-footer" , s " ScalaFX Extras API v. $projectVersion" ),
89+ // If using Scala 2.13 or better, enable macro processing through compiler option
90+ scalacOptions += (if (isScala2_13plus(scalaVersion.value)) " -Ymacro-annotations" else " " ),
91+ // If using Scala 2.12 or lower, enable macro processing through compiler plugin
92+ libraryDependencies ++= (
93+ if (! isScala2_13plus(scalaVersion.value))
94+ Seq (compilerPlugin(
95+ " org.scalamacros" % " paradise" % " 2.1.1" cross CrossVersion .full))
96+ else
97+ Seq .empty[sbt.ModuleID ]
98+ ),
7999 javacOptions ++= Seq (
80100 // "-target", "1.8",
81101 // "-source", "1.8",
82102 " -Xlint:deprecation" ),
83103 libraryDependencies ++= Seq (
84104 " com.beachape" %% " enumeratum" % " 1.5.13" ,
85105 " org.scala-lang" % " scala-reflect" % scalaVersion.value,
86- " org.scalafx" %% " scalafx" % " 11-R16 " ,
87- " org.scalafx" %% " scalafxml-core-sfx8" % " 0.4 " ,
88- " org.scalatest" %% " scalatest" % " 3.0.5 " % " test"
106+ " org.scalafx" %% " scalafx" % " 12.0.2-R18 " ,
107+ " org.scalafx" %% " scalafxml-core-sfx8" % " 0.5 " ,
108+ " org.scalatest" %% " scalatest" % " 3.0.8 " % " test"
89109 ) ++ JavaFXModuleLibs ,
110+ // Use `pomPostProcess` to remove dependencies marked as "provided" from publishing in POM
111+ // This is to avoid dependency on wrong OS version JavaFX libraries
112+ // See also [https://stackoverflow.com/questions/27835740/sbt-exclude-certain-dependency-only-during-publish]
113+ pomPostProcess := { node : XmlNode =>
114+ new RuleTransformer (new RewriteRule {
115+ override def transform (node : XmlNode ): XmlNodeSeq = node match {
116+ case e : Elem if e.label == " dependency" && e.child.exists(c => c.label == " scope" && c.text == " provided" ) =>
117+ val organization = e.child.filter(_.label == " groupId" ).flatMap(_.text).mkString
118+ val artifact = e.child.filter(_.label == " artifactId" ).flatMap(_.text).mkString
119+ val version = e.child.filter(_.label == " version" ).flatMap(_.text).mkString
120+ Comment (s " provided dependency $organization# $artifact; $version has been omitted " )
121+ case _ => node
122+ }
123+ }).transform(node).head
124+ },
90125 autoAPIMappings := true ,
91126 manifestSetting,
92- publishSetting ,
127+ publishTo := sonatypePublishToBundle.value ,
93128 fork in run := true ,
94129 fork in Test := true ,
95130 parallelExecution in Test := false ,
@@ -117,14 +152,6 @@ lazy val manifestSetting = packageOptions += {
117152 )
118153}
119154
120- lazy val publishSetting = publishTo := {
121- val nexus = " https://oss.sonatype.org/"
122- if (isSnapshot.value)
123- Some (" snapshots" at nexus + " content/repositories/snapshots" )
124- else
125- Some (" releases" at nexus + " service/local/staging/deploy/maven2" )
126- }
127-
128155// Metadata needed by Maven Central
129156// See also http://maven.apache.org/pom.html#Developers
130157lazy val mavenCentralSettings = Seq (
0 commit comments