|
| 1 | +import java.net.URL |
| 2 | + |
| 3 | +import scala.xml._ |
| 4 | + |
| 5 | +// @formatter:off |
| 6 | + |
| 7 | +// |
| 8 | +// Environment variables used by the build: |
| 9 | +// GRAPHVIZ_DOT_PATH - Full path to Graphviz dot utility. If not defined Scaladocs will be build without diagrams. |
| 10 | +// JAR_BUILT_BY - Name to be added to Jar metadata field "Built-By" (defaults to System.getProperty("user.name") |
| 11 | +// |
| 12 | + |
| 13 | +val projectVersion = "0.1.0-SNAPSHOT" |
| 14 | +val versionTagDir = if (projectVersion.endsWith("SNAPSHOT")) "master" else "v" + projectVersion |
| 15 | + |
| 16 | +// ScalaFX project |
| 17 | +lazy val scalaFXExtrasProject = Project( |
| 18 | + id = "scalafx-extras", |
| 19 | + base = file("scalafx-extras"), |
| 20 | + settings = scalaFXExtrasSettings ++ Seq( |
| 21 | + description := "The ScalaFX Extras", |
| 22 | + fork in run := true, |
| 23 | + scalacOptions in(Compile, doc) ++= Seq( |
| 24 | + "-sourcepath", baseDirectory.value.toString, |
| 25 | + "-doc-root-content", baseDirectory.value + "/src/main/scala/root-doc.creole", |
| 26 | + "-doc-source-url", "https://github.com/SscalaFX-Extras/scalafx-extras/blob/" + versionTagDir + "/scalafx/€{FILE_PATH}.scala" |
| 27 | + ) ++ (Option(System.getenv("GRAPHVIZ_DOT_PATH")) match { |
| 28 | + case Some(path) => Seq("-diagrams", "-diagrams-dot-path", path) |
| 29 | + case None => Seq.empty[String] |
| 30 | + }) |
| 31 | + ) |
| 32 | +) |
| 33 | + |
| 34 | +// ScalaFX Demos project |
| 35 | +lazy val scalaFXExtrasDemosProject = Project( |
| 36 | + id = "scalafx-extras-demos", |
| 37 | + base = file("scalafx-extras-demos"), |
| 38 | + settings = scalaFXExtrasSettings ++ Seq( |
| 39 | + description := "The ScalaFX Extras demonstrations", |
| 40 | + fork in run := true, |
| 41 | + javaOptions ++= Seq( |
| 42 | + "-Xmx512M", |
| 43 | + "-Djavafx.verbose" |
| 44 | + ), |
| 45 | + addCompilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full), |
| 46 | + publishArtifact := false |
| 47 | + ) |
| 48 | +) dependsOn (scalaFXExtrasProject % "compile;test->test") |
| 49 | + |
| 50 | +// Resolvers |
| 51 | +lazy val sonatypeNexusSnapshots = "Sonatype Nexus Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots" |
| 52 | +lazy val sonatypeNexusStaging = "Sonatype Nexus Staging" at "https://oss.sonatype.org/service/local/staging/deploy/maven2" |
| 53 | + |
| 54 | +// Add snapshots to root project to enable compilation with Scala SNAPSHOT compiler, |
| 55 | +// e.g., 2.11.0-SNAPSHOT |
| 56 | +resolvers += sonatypeNexusSnapshots |
| 57 | + |
| 58 | +// Common settings |
| 59 | +lazy val scalaFXExtrasSettings = Seq( |
| 60 | + organization := "org.scalafx", |
| 61 | + version := projectVersion, |
| 62 | + crossScalaVersions := Seq("2.10.6", "2.11.8", "2.12.1"), |
| 63 | + scalaVersion <<= crossScalaVersions { versions => versions.head }, |
| 64 | + scalacOptions ++= Seq("-unchecked", "-deprecation", "-Xcheckinit", "-encoding", "utf8", "-feature"), |
| 65 | + scalacOptions in(Compile, doc) ++= Opts.doc.title("ScalaFX Extras API"), |
| 66 | + scalacOptions in(Compile, doc) ++= Opts.doc.version(projectVersion), |
| 67 | + scalacOptions in(Compile, doc) += s"-doc-external-doc:${scalaInstance.value.libraryJar}#http://www.scala-lang.org/api/${scalaVersion.value}/", |
| 68 | + scalacOptions in(Compile, doc) ++= Seq("-doc-footer", s"ScalaFX Extras API v.$projectVersion"), |
| 69 | + javacOptions ++= Seq( |
| 70 | + "-target", "1.8", |
| 71 | + "-source", "1.8", |
| 72 | + "-Xlint:deprecation"), |
| 73 | + libraryDependencies ++= Seq( |
| 74 | + "org.scala-lang" % "scala-reflect" % scalaVersion.value, |
| 75 | + "org.scalafx" %% "scalafx" % "8.0.102-R11", |
| 76 | + "org.scalafx" %% "scalafxml-core-sfx8" % "0.2.2", |
| 77 | + "org.scalatest" %% "scalatest" % "3.0.0" % "test", |
| 78 | + "junit" % "junit" % "4.12" % "test"), |
| 79 | + autoAPIMappings := true, |
| 80 | + manifestSetting, |
| 81 | + publishSetting, |
| 82 | + fork in Test := true, |
| 83 | + parallelExecution in Test := false, |
| 84 | + resolvers += sonatypeNexusSnapshots, |
| 85 | + // print junit-style XML for CI |
| 86 | + testOptions in Test <+= (target in Test) map { |
| 87 | + t => Tests.Argument(TestFrameworks.ScalaTest, "-u", "%s" format (t / "junitxmldir")) |
| 88 | + }, |
| 89 | + shellPrompt in ThisBuild := { state => "sbt:" + Project.extract(state).currentRef.project + "> " } |
| 90 | +) ++ mavenCentralSettings |
| 91 | + |
| 92 | +lazy val manifestSetting = packageOptions <+= (name, version, organization) map { |
| 93 | + (title, version, vendor) => |
| 94 | + Package.ManifestAttributes( |
| 95 | + "Created-By" -> "Simple Build Tool", |
| 96 | + "Built-By" -> Option(System.getenv("JAR_BUILT_BY")).getOrElse(System.getProperty("user.name")), |
| 97 | + "Build-Jdk" -> System.getProperty("java.version"), |
| 98 | + "Specification-Title" -> title, |
| 99 | + "Specification-Version" -> version, |
| 100 | + "Specification-Vendor" -> vendor, |
| 101 | + "Implementation-Title" -> title, |
| 102 | + "Implementation-Version" -> version, |
| 103 | + "Implementation-Vendor-Id" -> vendor, |
| 104 | + "Implementation-Vendor" -> vendor |
| 105 | + ) |
| 106 | +} |
| 107 | + |
| 108 | +lazy val publishSetting = publishTo <<= version { |
| 109 | + version: String => |
| 110 | + if (version.trim.endsWith("SNAPSHOT")) |
| 111 | + Some(sonatypeNexusSnapshots) |
| 112 | + else |
| 113 | + Some(sonatypeNexusStaging) |
| 114 | +} |
| 115 | + |
| 116 | +// Metadata needed by Maven Central |
| 117 | +// See also http://maven.apache.org/pom.html#Developers |
| 118 | +lazy val mavenCentralSettings = Seq( |
| 119 | + homepage := Some(new URL("http://www.scalafx.org/")), |
| 120 | + startYear := Some(2016), |
| 121 | + licenses := Seq(("BSD", new URL("https://github.com/scalafx/scalafx-extras/blob/master/LICENSE.txt"))), |
| 122 | + pomExtra <<= (pomExtra, name, description) { |
| 123 | + (pom, name, desc) => pom ++ Group( |
| 124 | + <scm> |
| 125 | + <url>https://github.com/scalafx/scalafx-extras</url> |
| 126 | + <connection>scm:git:https://github.com/scalafx/scalafx-extras.git</connection> |
| 127 | + </scm> |
| 128 | + ) |
| 129 | + } |
| 130 | +) |
0 commit comments