diff --git a/build.sbt b/build.sbt index e9040bef..07ab4b18 100644 --- a/build.sbt +++ b/build.sbt @@ -4,23 +4,138 @@ // Release tags should follow: http://semver.org/ import scalariform.formatter.preferences._ -enablePlugins(GitVersioning) -git.baseVersion := "1.3.0" +ThisBuild / git.baseVersion := "1.3.0" +ThisBuild / organization := "com.typesafe" +ThisBuild / Compile / scalacOptions := List("-unchecked", "-deprecation", "-feature") +ThisBuild / Test / scalacOptions := List("-unchecked", "-deprecation", "-feature") +ThisBuild / scalaVersion := "2.10.6" -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" - -val sonatype = new PublishToSonatype { - def projectUrl = "https://github.com/lightbend/config" - def developerId = "havocp" - def developerName = "Havoc Pennington" - def developerUrl = "http://ometer.com/" - def scmUrl = "git://github.com/lightbend/config.git" +ThisBuild / scmInfo := Option( + ScmInfo(url("https://github.com/lightbend/config"), "scm:git@github.com:lightbend/config.git") +) +ThisBuild / developers := List( + Developer( + id = "havocp", + name = "Havoc Pennington", + email = "@havocp", + url = url("http://ometer.com/") + ) +) +ThisBuild / description := "configuration library for JVM languages using HOCON files" +ThisBuild / licenses := List("Apache-2.0" -> url("https://www.apache.org/licenses/LICENSE-2.0")) +ThisBuild / homepage := Option(url("https://github.com/lightbend/config")) +ThisBuild / pomIncludeRepository := { _ => false } +ThisBuild / publishTo := { + val nexus = "https://oss.sonatype.org/" + if ((ThisBuild / isSnapshot).value) Option("Sonatype OSS Snapshots" at nexus + "content/repositories/snapshots") + else Option("Sonatype OSS Staging" at nexus + "service/local/staging/deploy/maven2") } +ThisBuild / publishMavenStyle := true + +lazy val root = (project in file(".")) + .enablePlugins(GitVersioning) + .aggregate( + testLib, configLib, + simpleLibScala, simpleAppScala, complexAppScala, + simpleLibJava, simpleAppJava, complexAppJava + ) + .settings(commonSettings) + .settings(nocomma { + name := "config-root" + git.baseVersion := (ThisBuild / git.baseVersion).value + doc / aggregate := false + doc := (configLib / Compile / doc).value + packageDoc / aggregate := false + packageDoc := (configLib / Compile / packageDoc).value + checkstyle / aggregate := false + checkstyle := (configLib / Compile / checkstyle).value + useGpg := true + PgpKeys.publishSigned / aggregate := false + PgpKeys.publishSigned := (PgpKeys.publishSigned in configLib).value + PgpKeys.publishLocalSigned / aggregate := false + PgpKeys.publishLocalSigned := (PgpKeys.publishLocalSigned in configLib).value + }) + +lazy val configLib = Project("config", file("config")) + .enablePlugins(SbtOsgi) + .dependsOn(testLib % "test->test") + .settings(osgiSettings) + .settings(nocomma { + autoScalaLibrary := false + crossPaths := false + libraryDependencies += "net.liftweb" %% "lift-json" % "2.5" % Test + libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % Test + + Compile / compile / javacOptions ++= Seq("-source", "1.8", "-target", "1.8", + "-g", "-Xlint:unchecked") + + Compile / doc / javacOptions ++= Seq("-group", s"Public API (version ${version.value})", "com.typesafe.config:com.typesafe.config.parser", + "-group", "Internal Implementation - Not ABI Stable", "com.typesafe.config.impl") + javadocSourceBaseUrl := { + for (gitHead <- com.typesafe.sbt.SbtGit.GitKeys.gitHeadCommit.value) + yield s"https://github.com/lightbend/config/blob/$gitHead/config/src/main/java" + } + // because we test some global state such as singleton caches, + // we have to run tests in serial. + Test / parallelExecution := false + + test / fork := true + Test / fork := true + run / fork := true + Test/ run / fork := true + + //env vars for tests + Test / envVars ++= Map("testList.0" -> "0", "testList.1" -> "1") + + OsgiKeys.exportPackage := Seq("com.typesafe.config", "com.typesafe.config.impl") + publish := sys.error("use publishSigned instead of plain publish") + publishLocal := sys.error("use publishLocalSigned instead of plain publishLocal") + Compile / packageBin / packageOptions += + Package.ManifestAttributes("Automatic-Module-Name" -> "typesafe.config" ) + scalariformPreferences := scalariformPreferences.value + .setPreference(IndentSpaces, 4) + .setPreference(FirstArgumentOnNewline, Preserve) + + checkstyleConfigLocation := CheckstyleConfigLocation.File((baseDirectory.value / "checkstyle-config.xml").toString) + + Compile / checkstyle := { + val log = streams.value.log + (Compile / checkstyle).value + val resultFile = (Compile / checkstyleOutputFile).value + val results = scala.xml.XML.loadFile(resultFile) + val errorFiles = results \\ "checkstyle" \\ "file" + + def errorFromXml(node: scala.xml.NodeSeq): (String, String, String) = { + val line: String = (node \ "@line" text) + val msg: String = (node \ "@message" text) + val source: String = (node \ "@source" text) + (line, msg, source) + } + def errorsFromXml(fileNode: scala.xml.NodeSeq): Seq[(String, String, String, String)] = { + val name: String = (fileNode \ "@name" text) + val errors = (fileNode \\ "error") map { e => errorFromXml(e) } + errors map { case (line, error, source) => (name, line, error, source) } + } + + val errors = errorFiles flatMap { f => errorsFromXml(f) } + + if (errors.nonEmpty) { + for (e <- errors) { + log.error(s"${e._1}:${e._2}: ${e._3} (from ${e._4})") + } + throw new RuntimeException(s"Checkstyle failed with ${errors.size} errors") + } + log.info("No errors from checkstyle") + } + + // add checkstyle as a dependency of doc + Compile / doc := ((Compile / doc).dependsOn(Compile / checkstyle)).value + + findbugsReportType := Some(FindbugsReport.Html) + findbugsReportPath := Some(crossTarget.value / "findbugs.html") + findbugsEffort := FindbugsEffort.Maximum + findbugsMaxMemory := 2000 + }) lazy val commonSettings: Seq[Setting[_]] = Def.settings( unpublished, @@ -29,38 +144,6 @@ lazy val commonSettings: Seq[Setting[_]] = Def.settings( .setPreference(FirstArgumentOnNewline, Preserve) ) -lazy val root = (project in file(".")) - .settings( - commonSettings, - aggregate in doc := false, - doc := (doc in (configLib, Compile)).value, - aggregate in packageDoc := false, - packageDoc := (packageDoc in (configLib, Compile)).value, - aggregate in checkstyle := false, - checkstyle := (checkstyle in (configLib, Compile)).value - ) - .aggregate( - testLib, configLib, - simpleLibScala, simpleAppScala, complexAppScala, - simpleLibJava, simpleAppJava, complexAppJava - ) - -lazy val configLib = Project("config", file("config")) - .settings( - sonatype.settings, - osgiSettings, - OsgiKeys.exportPackage := Seq("com.typesafe.config", "com.typesafe.config.impl"), - publish := sys.error("use publishSigned instead of plain publish"), - publishLocal := sys.error("use publishLocalSigned instead of plain publishLocal"), - packageOptions in (Compile, packageBin) += - Package.ManifestAttributes("Automatic-Module-Name" -> "typesafe.config" ), - scalariformPreferences := scalariformPreferences.value - .setPreference(IndentSpaces, 4) - .setPreference(FirstArgumentOnNewline, Preserve) - ) - .enablePlugins(SbtOsgi) - .dependsOn(testLib % "test->test") - def proj(id: String, base: File) = Project(id, base) settings commonSettings lazy val testLib = proj("config-test-lib", file("test-lib")) @@ -73,23 +156,13 @@ lazy val simpleLibJava = proj("config-simple-lib-java", file("examples/java/si lazy val simpleAppJava = proj("config-simple-app-java", file("examples/java/simple-app")) dependsOn simpleLibJava lazy val complexAppJava = proj("config-complex-app-java", file("examples/java/complex-app")) dependsOn simpleLibJava -useGpg := true - -aggregate in PgpKeys.publishSigned := false -PgpKeys.publishSigned := (PgpKeys.publishSigned in configLib).value - -aggregate in PgpKeys.publishLocalSigned := false -PgpKeys.publishLocalSigned := (PgpKeys.publishLocalSigned in configLib).value - val unpublished = Seq( // no artifacts in this project - publishArtifact := false, + publishArtifact := false, // make-pom has a more specific publishArtifact setting already // so needs specific override - publishArtifact in makePom := false, + makePom / publishArtifact := false, // no docs to publish - publishArtifact in packageDoc := false, - // can't seem to get rid of ivy files except by no-op'ing the entire publish task - publish := {}, - publishLocal := {} + packageDoc / publishArtifact := false, + publish / skip := true ) diff --git a/config/build.sbt b/config/build.sbt deleted file mode 100644 index a588d747..00000000 --- a/config/build.sbt +++ /dev/null @@ -1,68 +0,0 @@ -fork in test := true -fork in Test := true -fork in run := true -fork in run in Test := true - -//env vars for tests -envVars in Test ++= Map("testList.0" -> "0", "testList.1" -> "1") - -autoScalaLibrary := false -crossPaths := false - -libraryDependencies += "net.liftweb" %% "lift-json" % "2.5" % "test" -libraryDependencies += "com.novocode" % "junit-interface" % "0.11" % "test" - -checkstyleConfigLocation := CheckstyleConfigLocation.File((baseDirectory.value / "checkstyle-config.xml").toString) - -checkstyle in Compile := { - val log = streams.value.log - (checkstyle in Compile).value - val resultFile = (checkstyleOutputFile in Compile).value - val results = scala.xml.XML.loadFile(resultFile) - val errorFiles = results \\ "checkstyle" \\ "file" - - def errorFromXml(node: scala.xml.NodeSeq): (String, String, String) = { - val line: String = (node \ "@line" text) - val msg: String = (node \ "@message" text) - val source: String = (node \ "@source" text) - (line, msg, source) - } - def errorsFromXml(fileNode: scala.xml.NodeSeq): Seq[(String, String, String, String)] = { - val name: String = (fileNode \ "@name" text) - val errors = (fileNode \\ "error") map { e => errorFromXml(e) } - errors map { case (line, error, source) => (name, line, error, source) } - } - - val errors = errorFiles flatMap { f => errorsFromXml(f) } - - if (errors.nonEmpty) { - for (e <- errors) { - log.error(s"${e._1}:${e._2}: ${e._3} (from ${e._4})") - } - throw new RuntimeException(s"Checkstyle failed with ${errors.size} errors") - } - log.info("No errors from checkstyle") -} - -// add checkstyle as a dependency of doc -doc in Compile := ((doc in Compile).dependsOn(checkstyle in Compile)).value - -findbugsReportType := Some(FindbugsReport.Html) -findbugsReportPath := Some(crossTarget.value / "findbugs.html") -findbugsEffort := FindbugsEffort.Maximum -findbugsMaxMemory := 2000 - -javacOptions in (Compile, compile) ++= Seq("-source", "1.8", "-target", "1.8", - "-g", "-Xlint:unchecked") - -// because we test some global state such as singleton caches, -// we have to run tests in serial. -parallelExecution in Test := false - -javacOptions in (Compile, doc) ++= Seq("-group", s"Public API (version ${version.value})", "com.typesafe.config:com.typesafe.config.parser", - "-group", "Internal Implementation - Not ABI Stable", "com.typesafe.config.impl") - -javadocSourceBaseUrl := { - for (gitHead <- com.typesafe.sbt.SbtGit.GitKeys.gitHeadCommit.value) - yield s"https://github.com/lightbend/config/blob/$gitHead/config/src/main/java" -} diff --git a/project/PublishToSonatype.scala b/project/PublishToSonatype.scala deleted file mode 100644 index 9c12d5cd..00000000 --- a/project/PublishToSonatype.scala +++ /dev/null @@ -1,48 +0,0 @@ -import sbt._, Keys._ - -// from https://raw.github.com/paulp/scala-improving/master/project/PublishToSonatype.scala -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/" - - def projectUrl: String - def developerId: String - def developerName: String - def developerUrl: String - - def licenseName = "Apache License, Version 2.0" - def licenseUrl = "https://www.apache.org/licenses/LICENSE-2.0" - def licenseDistribution = "repo" - def scmUrl: String - def scmConnection = "scm:git:" + scmUrl - - def generatePomExtra: xml.NodeSeq = { - <url>{ projectUrl }</url> - <licenses> - <license> - <name>{ licenseName }</name> - <url>{ licenseUrl }</url> - <distribution>{ licenseDistribution }</distribution> - </license> - </licenses> - <scm> - <url>{ scmUrl }</url> - <connection>{ scmConnection }</connection> - </scm> - <developers> - <developer> - <id>{ developerId }</id> - <name>{ developerName }</name> - <url>{ developerUrl }</url> - </developer> - </developers> - } - - def settings: Seq[Setting[_]] = Seq( - publishMavenStyle := true, - publishTo := Some(if (isSnapshot.value) ossSnapshots else ossStaging), - publishArtifact in Test := false, - pomIncludeRepository := (_ => false), - pomExtra := generatePomExtra - ) -} diff --git a/project/plugins.sbt b/project/plugins.sbt index 3ed275fa..dd15b5dd 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -7,3 +7,4 @@ addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2") addSbtPlugin("com.etsy" % "sbt-checkstyle-plugin" % "3.1.1") addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") +addSbtPlugin("com.eed3si9n" % "sbt-nocomma" % "0.1.0")