Update and align project layout with others

This commit is contained in:
Sarah Gerweck 2017-10-18 19:56:22 -07:00
parent 136d2b59a3
commit 5aa5d5a74c
4 changed files with 148 additions and 78 deletions

View File

@ -1,68 +1,37 @@
/* Note: This file is shared among many projects. Avoid putting project-specific things here. */
import sbt._
import Keys._
import scala.util.Properties.envOrNone
import com.typesafe.sbt.site._
import sbt.Keys._
import Helpers._
sealed trait Basics {
final val buildOrganization = "org.gerweck.scalafx"
final val buildOrganizationName = "Sarah Gerweck"
final val buildOrganizationUrl = Some("https://github.com/sarahgerweck")
final val githubOrganization = "sarahgerweck"
final val githubProject = "scalafx-utils"
final val projectDescription = "ScalaFX Utilities"
final val projectStartYear = 2015
final val projectHomepage = None
final val buildScalaVersion = "2.12.3"
final val extraScalaVersions = Seq("2.11.11")
final val minimumJavaVersion = "1.8"
final val defaultOptimize = true
final val defaultOptimizeGlobal = false
final val inlinePatterns = Seq("!akka.**,!slick.**")
final val autoAddCompileOptions = true
final val parallelBuild = true
final val cachedResolution = true
final val sonatypeResolver = true
final val defaultNewBackend = false
/* Metadata definitions */
lazy val githubPage = url(s"https://github.com/${githubOrganization}/${githubProject}")
lazy val buildMetadata = Vector(
licenses := Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt")),
homepage := Some(projectHomepage.getOrElse(githubPage)),
description := projectDescription,
startYear := Some(projectStartYear),
scmInfo := Some(ScmInfo(githubPage, s"scm:git:git@github.com:${githubOrganization}/${githubProject}.git"))
)
lazy val developerInfo = {
<developers>
<developer>
<id>sarah</id>
<name>Sarah Gerweck</name>
<email>sarah.a180@gmail.com</email>
<url>https://github.com/sarahgerweck</url>
<timezone>America/Los_Angeles</timezone>
</developer>
</developers>
}
object BasicSettings extends AutoPlugin with BasicSettings {
override def projectSettings = basicSettings
}
object BasicSettings extends AutoPlugin with Basics {
override def requires = SiteScaladocPlugin
trait BasicSettings extends ProjectSettings { st: SettingTemplate =>
/* Overridable flags */
lazy val optimize = boolFlag("OPTIMIZE") orElse boolFlag("OPTIMISE") getOrElse defaultOptimize
lazy val optimizeGlobal = boolFlag("OPTIMIZE_GLOBAL") getOrElse defaultOptimizeGlobal
lazy val optimizeWarn = boolFlag("OPTIMIZE_WARNINGS") getOrElse false
lazy val noFatalWarn = boolFlag("NO_FATAL_WARNINGS") getOrElse false
lazy val deprecation = boolFlag("NO_DEPRECATION") map (!_) getOrElse true
lazy val inlineWarn = boolFlag("INLINE_WARNINGS") getOrElse false
lazy val debug = boolFlag("DEBUGGER") getOrElse false
lazy val debugPort = intFlag("DEBUGGER_PORT", 5050)
lazy val debugSuspend = boolFlag("DEBUGGER_SUSPEND") getOrElse true
lazy val unusedWarn = boolFlag("UNUSED_WARNINGS") getOrElse false
lazy val importWarn = boolFlag("IMPORT_WARNINGS") getOrElse false
lazy val findbugsHtml = boolFlag("FINDBUGS_HTML") getOrElse !isJenkins
lazy val newBackend = boolFlag("NEW_BCODE_BACKEND") getOrElse defaultNewBackend
lazy val noBuildDocs = boolFlag("NO_SBT_DOCS").getOrElse(false) && !isJenkins
override lazy val projectSettings = (
lazy val basicSettings = new Def.SettingList(
buildMetadata ++
Seq (
organization := buildOrganization,
organizationName := buildOrganizationName,
organizationHomepage := buildOrganizationUrl map { url _ },
organizationHomepage := buildOrganizationUrl.orElse(if (githubOrgPageFallback) Some(githubOrgPage) else None),
scalaVersion := buildScalaVersion,
crossScalaVersions := buildScalaVersions,
@ -74,6 +43,12 @@ object BasicSettings extends AutoPlugin with Basics {
evictionWarningOptions in update :=
EvictionWarningOptions.default.withWarnTransitiveEvictions(false).withWarnDirectEvictions(false).withWarnScalaVersionEviction(false)
) ++ (
if (noBuildDocs) {
Seq(sources in (Compile, doc) := Seq.empty)
} else {
Seq.empty
}
) ++ (
if (autoAddCompileOptions) {
addScalacOptions() ++ addJavacOptions()
@ -90,21 +65,6 @@ object BasicSettings extends AutoPlugin with Basics {
)
)
/* Overridable flags */
lazy val optimize = boolFlag("OPTIMIZE") orElse boolFlag("OPTIMISE") getOrElse defaultOptimize
lazy val optimizeGlobal = boolFlag("OPTIMIZE_GLOBAL") getOrElse defaultOptimizeGlobal
lazy val optimizeWarn = boolFlag("OPTIMIZE_WARNINGS") getOrElse false
lazy val noFatalWarn = boolFlag("NO_FATAL_WARNINGS") getOrElse false
lazy val deprecation = boolFlag("NO_DEPRECATION") map (!_) getOrElse true
lazy val inlineWarn = boolFlag("INLINE_WARNINGS") getOrElse false
lazy val debug = boolFlag("DEBUGGER") getOrElse false
lazy val debugPort = envOrNone("DEBUGGER_PORT") map { _.toInt } getOrElse 5050
lazy val debugSuspend = boolFlag("DEBUGGER_SUSPEND") getOrElse true
lazy val unusedWarn = boolFlag("UNUSED_WARNINGS") getOrElse false
lazy val importWarn = boolFlag("IMPORT_WARNINGS") getOrElse false
lazy val java8Flag = boolFlag("BUILD_JAVA_8") getOrElse false
lazy val newBackend = boolFlag("NEW_BCODE_BACKEND") getOrElse defaultNewBackend
lazy val buildScalaVersions = buildScalaVersion +: extraScalaVersions
def basicScalacOptions = Def.derive {
@ -209,13 +169,5 @@ object BasicSettings extends AutoPlugin with Basics {
}
}
def basicSiteSettings = Def.derive {
scalacOptions in (Compile,doc) ++= Seq(
"-groups",
"-implicits",
"-diagrams",
"-sourcepath", (baseDirectory in ThisBuild).value.getAbsolutePath,
"-doc-source-url", s"https://github.com/${githubOrganization}/${githubProject}/blob/master€{FILE_PATH}.scala"
)
}
private[this] lazy val githubOrgPage = url(s"https://github.com/${githubOrganization}")
}

View File

@ -0,0 +1,32 @@
/** Basic metadata about the project that gets pulled into the build */
trait ProjectSettings
extends SettingTemplate
with SettingTemplate.ApacheLicensed
with SettingTemplate.GithubProject {
override final val buildOrganization = "org.gerweck.scalafx"
override final val buildOrganizationName = "Sarah Gerweck"
override final val projectDescription = "Utilities to simplify ScalaFX applications"
override final val projectStartYear = 2015
override final val githubOrganization = "sarahgerweck"
override final val githubProject = "scalafx-utils"
override final val buildScalaVersion = "2.12.3"
override final val extraScalaVersions = Seq("2.11.11")
override final val defaultOptimize = true
override final val defaultOptimizeGlobal = false
override final val sonatypeResolver = true
lazy val developerInfo = {
<developers>
<developer>
<id>sarah</id>
<name>Sarah Gerweck</name>
<email>sarah.a180@gmail.com</email>
<url>https://github.com/sarahgerweck</url>
<timezone>America/Los_Angeles</timezone>
</developer>
</developers>
}
}

View File

@ -0,0 +1,60 @@
/* Note: This file is shared among many projects. Avoid putting project-specific things here. */
import sbt._
import sbt.Keys._
import java.net.URL
trait SettingTemplate {
val buildOrganization: String
val buildOrganizationName: String
val buildOrganizationUrl: Option[URL] = None
val projectDescription: String
val projectStartYear: Int
val projectHomepage: Option[URL] = None
val buildScalaVersion: String
val extraScalaVersions: Seq[String]
val minimumJavaVersion: String = "1.8"
val defaultOptimize: Boolean = true
val defaultOptimizeGlobal: Boolean = false
val inlinePatterns: Seq[String] = Seq("!akka.**","!slick.**")
val autoAddCompileOptions: Boolean = true
val parallelBuild: Boolean = true
val cachedResolution: Boolean = true
val sonatypeResolver: Boolean = false
val projectLicenses: Seq[(String, URL)]
val defaultNewBackend: Boolean = false
val developerInfo: scala.xml.Elem
val buildMetadata: Seq[Setting[_]]
def sourceLocation(branch: String): Option[URL] = None
}
object SettingTemplate {
trait GithubProject extends SettingTemplate {
val githubOrganization: String
val githubProject: String
val githubOrgPageFallback: Boolean = true
lazy val githubPage = url(s"https://github.com/${githubOrganization}/${githubProject}")
override def sourceLocation(branch: String) = Some(url(s"${githubPage.toExternalForm}/blob/branch"))
lazy val buildMetadata = Vector(
licenses := projectLicenses,
homepage := Some(projectHomepage.getOrElse(githubPage)),
description := projectDescription,
startYear := Some(projectStartYear),
scmInfo := Some(ScmInfo(githubPage, s"scm:git:git@github.com:${githubOrganization}/${githubProject}.git"))
)
}
trait ApacheLicensed extends SettingTemplate {
final val projectLicenses = Seq("Apache License, Version 2.0" -> url("http://www.apache.org/licenses/LICENSE-2.0.txt"))
}
}

View File

@ -0,0 +1,26 @@
import sbt._
import Keys._
import com.typesafe.sbt.site._
object SiteSettingsPlugin extends AutoPlugin {
override def requires = SiteScaladocPlugin
override lazy val projectSettings = Seq(
scalacOptions in (Compile,doc) ++= Seq(
"-groups",
"-implicits",
"-diagrams",
"-sourcepath", (baseDirectory in ThisBuild).value.getAbsolutePath
),
scalacOptions in (Compile,doc) ++= (
(BasicSettings: SettingTemplate).sourceLocation("master") match {
case Some(url) =>
val srcUrl = url + "€{FILE_PATH}.scala"
Seq("-doc-source-url", srcUrl)
case None =>
Seq.empty
}
)
)
}