From 8e82860df7ef0734997d41207c67510763fb646d Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Mon, 26 Jan 2015 23:57:36 +0000 Subject: [PATCH 1/5] Delete empty build.sbt files. --- examples/java/complex-app/build.sbt | 0 examples/java/simple-app/build.sbt | 0 examples/java/simple-lib/build.sbt | 0 examples/scala/complex-app/build.sbt | 0 examples/scala/simple-app/build.sbt | 0 examples/scala/simple-lib/build.sbt | 0 test-lib/build.sbt | 0 7 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 examples/java/complex-app/build.sbt delete mode 100644 examples/java/simple-app/build.sbt delete mode 100644 examples/java/simple-lib/build.sbt delete mode 100644 examples/scala/complex-app/build.sbt delete mode 100644 examples/scala/simple-app/build.sbt delete mode 100644 examples/scala/simple-lib/build.sbt delete mode 100644 test-lib/build.sbt diff --git a/examples/java/complex-app/build.sbt b/examples/java/complex-app/build.sbt deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/java/simple-app/build.sbt b/examples/java/simple-app/build.sbt deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/java/simple-lib/build.sbt b/examples/java/simple-lib/build.sbt deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/scala/complex-app/build.sbt b/examples/scala/complex-app/build.sbt deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/scala/simple-app/build.sbt b/examples/scala/simple-app/build.sbt deleted file mode 100644 index e69de29b..00000000 diff --git a/examples/scala/simple-lib/build.sbt b/examples/scala/simple-lib/build.sbt deleted file mode 100644 index e69de29b..00000000 diff --git a/test-lib/build.sbt b/test-lib/build.sbt deleted file mode 100644 index e69de29b..00000000 From 3cb10e687980812d05c8838f72820c4fbc29c53c Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 27 Jan 2015 00:28:04 +0000 Subject: [PATCH 2/5] Scala 2.10.4 (this build only). --- build.sbt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.sbt b/build.sbt index aaa6d956..536a8ad5 100644 --- a/build.sbt +++ b/build.sbt @@ -16,7 +16,7 @@ scalacOptions in GlobalScope in Compile := Seq("-unchecked", "-deprecation", "-f 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 From 840bb0dc58ec7f82f243ad00d23d565fa1188073 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 27 Jan 2015 00:29:51 +0000 Subject: [PATCH 3/5] Cleanup sbt 0.13.7+ build.sbt format. --- build.sbt | 6 +----- config/build.sbt | 22 ++++++---------------- project/plugins.sbt | 4 ---- 3 files changed, 7 insertions(+), 25 deletions(-) diff --git a/build.sbt b/build.sbt index 536a8ad5..989917eb 100644 --- a/build.sbt +++ b/build.sbt @@ -7,13 +7,11 @@ 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.4" @@ -21,9 +19,7 @@ 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 diff --git a/config/build.sbt b/config/build.sbt index 511a4fe1..3ba96cdb 100644 --- a/config/build.sbt +++ b/config/build.sbt @@ -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 diff --git a/project/plugins.sbt b/project/plugins.sbt index 9a3c2fed..ef03f11a 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,11 +1,7 @@ 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") From ad63b52073e8a7edc7c18aa12b75002c20977fc5 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 27 Jan 2015 00:31:48 +0000 Subject: [PATCH 4/5] Cleanup Build.scala. --- project/Build.scala | 54 ++++++++++++++------------------------------- 1 file changed, 17 insertions(+), 37 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 70b1c716..83e26ab4 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1,6 +1,6 @@ import sbt._ import Keys._ -import com.typesafe.sbt.osgi.SbtOsgi._ +import com.typesafe.sbt.osgi.SbtOsgi.{ OsgiKeys, osgiSettings } object ConfigBuild extends Build { val unpublished = Seq( @@ -16,7 +16,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" @@ -27,7 +27,6 @@ object ConfigBuild extends Build { override val settings = super.settings ++ Seq(isSnapshot <<= isSnapshot or version(_ endsWith "-SNAPSHOT")) lazy val rootSettings: Seq[Setting[_]] = - Project.defaultSettings ++ unpublished ++ Seq(aggregate in doc := false, doc := (doc in (configLib, Compile)).value, @@ -43,51 +42,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 = unpublished) - 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 +82,7 @@ abstract class PublishToSonatype(build: Build) { def scmUrl: String def scmConnection = "scm:git:" + scmUrl - def generatePomExtra(scalaVersion: String): xml.NodeSeq = { + def generatePomExtra: xml.NodeSeq = { { projectUrl } @@ -126,9 +106,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 ) } From 65ff5f9f2c46b6d8d4fe31ffe87b15e193d721a3 Mon Sep 17 00:00:00 2001 From: Dale Wijnand Date: Tue, 27 Jan 2015 00:26:31 +0000 Subject: [PATCH 5/5] Replace JavaVersionCheck with sbt-javaversioncheck. --- config/build.sbt | 2 +- project/Build.scala | 7 ++-- project/JavaVersionCheck.scala | 61 ---------------------------------- project/plugins.sbt | 1 + 4 files changed, 7 insertions(+), 64 deletions(-) delete mode 100644 project/JavaVersionCheck.scala diff --git a/config/build.sbt b/config/build.sbt index 3ba96cdb..45b4932b 100644 --- a/config/build.sbt +++ b/config/build.sbt @@ -30,4 +30,4 @@ parallelExecution in Test := false sources in (Compile, doc) ~= (_.filter(_.getParentFile.getName != "impl")) -JavaVersionCheck.javacVersionCheckSettings +javaVersionPrefix in javaVersionCheck := Some("1.6") diff --git a/project/Build.scala b/project/Build.scala index 83e26ab4..e17e788d 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -1,6 +1,7 @@ import sbt._ import Keys._ import com.typesafe.sbt.osgi.SbtOsgi.{ OsgiKeys, osgiSettings } +import com.typesafe.sbt.JavaVersionCheckPlugin.autoImport._ object ConfigBuild extends Build { val unpublished = Seq( @@ -26,8 +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[_]] = - unpublished ++ + commonSettings ++ Seq(aggregate in doc := false, doc := (doc in (configLib, Compile)).value, aggregate in packageDoc := false, @@ -52,7 +55,7 @@ object ConfigBuild extends Build { publishLocal := sys.error("use publishLocalSigned instead of plain publishLocal") )) dependsOn testLib % "test->test" - def project(id: String, base: File) = Project(id, base, settings = unpublished) + def project(id: String, base: File) = Project(id, base, settings = commonSettings) lazy val testLib = project("config-test-lib", file("test-lib")) diff --git a/project/JavaVersionCheck.scala b/project/JavaVersionCheck.scala deleted file mode 100644 index e614dcfe..00000000 --- a/project/JavaVersionCheck.scala +++ /dev/null @@ -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 - } - ) -} diff --git a/project/plugins.sbt b/project/plugins.sbt index ef03f11a..943763fe 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -5,3 +5,4 @@ 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")