Merge pull request #244 from dwijnand/cleanup-build

Cleanup build
This commit is contained in:
Havoc Pennington 2015-01-26 20:45:51 -05:00
commit ac09c7e33d
12 changed files with 31 additions and 126 deletions

View File

@ -7,23 +7,19 @@ import com.typesafe.sbt.SbtPgp.PgpKeys.{ useGpg, publishSigned, publishLocalSign
// Release tags should follow: http://semver.org/
SbtGit.versionWithGit
SbtGit.GitKeys.baseVersion in ThisBuild := "1.1.0"
SbtGit.git.baseVersion := "1.1.0"
organization in GlobalScope := "com.typesafe"
scalacOptions in GlobalScope in Compile := Seq("-unchecked", "-deprecation", "-feature")
scalacOptions in GlobalScope in Test := Seq("-unchecked", "-deprecation", "-feature")
scalaVersion in ThisBuild := "2.10.2"
scalaVersion in ThisBuild := "2.10.4"
useGpg in GlobalScope := true
aggregate in publishSigned := false
publishSigned := (publishSigned in configLib).value
aggregate in publishLocalSigned := false
publishLocalSigned := (publishLocalSigned in configLib).value

View File

@ -1,43 +1,33 @@
import de.johoop.findbugs4sbt.FindBugs._
import de.johoop.findbugs4sbt.ReportType
import de.johoop.findbugs4sbt.Effort
import de.johoop.jacoco4sbt._
import JacocoPlugin._
import de.johoop.findbugs4sbt.{ Effort, ReportType }
import de.johoop.jacoco4sbt.JacocoPlugin.jacoco
fork in test := true
fork in run := true
fork in run in Test := true
autoScalaLibrary := false
crossPaths := false
libraryDependencies += "net.liftweb" %% "lift-json" % "2.5" % "test"
libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test"
externalResolvers += "Scala Tools Snapshots" at "http://scala-tools.org/repo-snapshots/"
seq(findbugsSettings : _*)
findbugsSettings
findbugsReportType := Some(ReportType.Html)
findbugsReportName := Some("findbugs.html")
findbugsEffort := Effort.High
findbugsMaxMemory := 1000
seq(jacoco.settings : _*)
jacoco.settings
javacOptions in (Compile,compile) ++= Seq("-source", "1.6", "-target", "1.6", "-g")
javacOptions in (Compile, compile) ++= Seq("-source", "1.6", "-target", "1.6", "-g")
// because we test some global state such as singleton caches,
// we have to run tests in serial.
parallelExecution in Test := false
sources in (Compile, doc) := (sources in (Compile, doc)).value.filter(_.getParentFile.getName != "impl")
sources in (Compile, doc) ~= (_.filter(_.getParentFile.getName != "impl"))
JavaVersionCheck.javacVersionCheckSettings
javaVersionPrefix in javaVersionCheck := Some("1.6")

View File

@ -1,6 +1,7 @@
import sbt._
import Keys._
import com.typesafe.sbt.osgi.SbtOsgi._
import com.typesafe.sbt.osgi.SbtOsgi.{ OsgiKeys, osgiSettings }
import com.typesafe.sbt.JavaVersionCheckPlugin.autoImport._
object ConfigBuild extends Build {
val unpublished = Seq(
@ -16,7 +17,7 @@ object ConfigBuild extends Build {
publishLocal := {}
)
object sonatype extends PublishToSonatype(ConfigBuild) {
object sonatype extends PublishToSonatype {
def projectUrl = "https://github.com/typesafehub/config"
def developerId = "havocp"
def developerName = "Havoc Pennington"
@ -26,9 +27,10 @@ object ConfigBuild extends Build {
override val settings = super.settings ++ Seq(isSnapshot <<= isSnapshot or version(_ endsWith "-SNAPSHOT"))
lazy val commonSettings: Seq[Setting[_]] = unpublished ++ Seq(javaVersionPrefix in javaVersionCheck := None)
lazy val rootSettings: Seq[Setting[_]] =
Project.defaultSettings ++
unpublished ++
commonSettings ++
Seq(aggregate in doc := false,
doc := (doc in (configLib, Compile)).value,
aggregate in packageDoc := false,
@ -43,51 +45,32 @@ object ConfigBuild extends Build {
lazy val configLib = Project(id = "config",
base = file("config"),
settings =
Project.defaultSettings ++
sonatype.settings ++
osgiSettings ++
Seq(
OsgiKeys.exportPackage := Seq("com.typesafe.config", "com.typesafe.config.impl"),
packagedArtifact in (Compile, packageBin) <<= (artifact in (Compile, packageBin), OsgiKeys.bundle).identityMap,
artifact in (Compile, packageBin) ~= { _.copy(`type` = "bundle") },
publish := { throw new RuntimeException("use publishSigned instead of plain publish") },
publishLocal := { throw new RuntimeException("use publishLocalSigned instead of plain publishLocal") }
)) dependsOn(testLib % "test->test")
publish := sys.error("use publishSigned instead of plain publish"),
publishLocal := sys.error("use publishLocalSigned instead of plain publishLocal")
)) dependsOn testLib % "test->test"
lazy val testLib = Project(id = "config-test-lib",
base = file("test-lib"),
settings = Project.defaultSettings ++ unpublished)
def project(id: String, base: File) = Project(id, base, settings = commonSettings)
lazy val simpleLibScala = Project(id = "config-simple-lib-scala",
base = file("examples/scala/simple-lib"),
settings = Project.defaultSettings ++ unpublished) dependsOn(configLib)
lazy val testLib = project("config-test-lib", file("test-lib"))
lazy val simpleAppScala = Project(id = "config-simple-app-scala",
base = file("examples/scala/simple-app"),
settings = Project.defaultSettings ++ unpublished) dependsOn(simpleLibScala)
lazy val simpleLibScala = project("config-simple-lib-scala", file("examples/scala/simple-lib")) dependsOn configLib
lazy val simpleAppScala = project("config-simple-app-scala", file("examples/scala/simple-app")) dependsOn simpleLibScala
lazy val complexAppScala = project("config-complex-app-scala", file("examples/scala/complex-app")) dependsOn simpleLibScala
lazy val complexAppScala = Project(id = "config-complex-app-scala",
base = file("examples/scala/complex-app"),
settings = Project.defaultSettings ++ unpublished) dependsOn(simpleLibScala)
lazy val simpleLibJava = Project(id = "config-simple-lib-java",
base = file("examples/java/simple-lib"),
settings = Project.defaultSettings ++ unpublished) dependsOn(configLib)
lazy val simpleAppJava = Project(id = "config-simple-app-java",
base = file("examples/java/simple-app"),
settings = Project.defaultSettings ++ unpublished) dependsOn(simpleLibJava)
lazy val complexAppJava = Project(id = "config-complex-app-java",
base = file("examples/java/complex-app"),
settings = Project.defaultSettings ++ unpublished) dependsOn(simpleLibJava)
lazy val simpleLibJava = project("config-simple-lib-java", file("examples/java/simple-lib")) dependsOn configLib
lazy val simpleAppJava = project("config-simple-app-java", file("examples/java/simple-app")) dependsOn simpleLibJava
lazy val complexAppJava = project("config-complex-app-java", file("examples/java/complex-app")) dependsOn simpleLibJava
}
// from https://raw.github.com/paulp/scala-improving/master/project/PublishToSonatype.scala
abstract class PublishToSonatype(build: Build) {
import build._
abstract class PublishToSonatype {
val ossSnapshots = "Sonatype OSS Snapshots" at "https://oss.sonatype.org/content/repositories/snapshots/"
val ossStaging = "Sonatype OSS Staging" at "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
@ -102,7 +85,7 @@ abstract class PublishToSonatype(build: Build) {
def scmUrl: String
def scmConnection = "scm:git:" + scmUrl
def generatePomExtra(scalaVersion: String): xml.NodeSeq = {
def generatePomExtra: xml.NodeSeq = {
<url>{ projectUrl }</url>
<licenses>
<license>
@ -126,9 +109,9 @@ abstract class PublishToSonatype(build: Build) {
def settings: Seq[Setting[_]] = Seq(
publishMavenStyle := true,
publishTo <<= (isSnapshot) { (snapshot) => Some(if (snapshot) ossSnapshots else ossStaging) },
publishTo <<= isSnapshot { (snapshot) => Some(if (snapshot) ossSnapshots else ossStaging) },
publishArtifact in Test := false,
pomIncludeRepository := (_ => false),
pomExtra <<= (scalaVersion)(generatePomExtra)
pomExtra := generatePomExtra
)
}

View File

@ -1,61 +0,0 @@
import sbt._
object JavaVersionCheck {
val javacVersionPrefix = taskKey[Option[String]]("java version prefix required by javacVersionCheck")
val javacVersionCheck = taskKey[String]("checks the Java version vs. javacVersionPrefix, returns actual version")
def javacVersionCheckSettings: Seq[Setting[_]] = Seq(
javacVersionPrefix := Some("1.6"),
javacVersionCheck := {
val realLog = Keys.streams.value.log
val javac = (Keys.compileInputs in Keys.compile in Compile).value.compilers.javac
val captureVersionLog = new sbt.Logger() {
var captured: Option[String] = None
def log(level: sbt.Level.Value,message: => String): Unit = {
val m = message
if (level == Level.Warn && m.startsWith("javac ")) {
captured = Some(m.substring("javac ".length).trim)
} else {
realLog.log(level, m)
}
}
def success(message: => String): Unit = realLog.success(message)
def trace(t: => Throwable): Unit = realLog.trace(t)
}
javac(sources=Nil, classpath=Nil, outputDirectory=file("."), options=Seq("-version"))(captureVersionLog)
val version = captureVersionLog.captured match {
case Some(v) => v
case None =>
throw new Exception("Failed to get or parse the output of javac -version")
}
javacVersionPrefix.value match {
case Some(prefix) =>
if (!version.startsWith(prefix)) {
throw new Exception(s"javac version ${version} may not be used to publish, it has to start with ${prefix} due to javacVersionPrefix setting")
}
case None =>
}
version
},
// we hook onto deliverConfiguration to run the version check as early as possible,
// before we actually do anything. But we don't want to require the version check
// just for compile.
Keys.deliverConfiguration := {
val log = Keys.streams.value.log
val javacVersion = javacVersionCheck.value
log.info("Will publish locally with javac version " + javacVersion)
Keys.deliverConfiguration.value
},
Keys.deliverLocalConfiguration := {
val log = Keys.streams.value.log
val javacVersion = javacVersionCheck.value
log.info("Will publish locally with javac version " + javacVersion)
Keys.deliverLocalConfiguration.value
}
)
}

View File

@ -1,11 +1,8 @@
addSbtPlugin("de.johoop" % "findbugs4sbt" % "1.2.1")
addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-pgp" % "0.8.1")
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.6.0")
resolvers += "jgit-repo" at "http://download.eclipse.org/jgit/maven"
addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.6.2")
addSbtPlugin("com.typesafe.sbt" % "sbt-javaversioncheck" % "0.1.0")

View File