From 788fd3961e4a3298e63445c22d3497f550b09977 Mon Sep 17 00:00:00 2001 From: barkhorn Date: Tue, 18 Dec 2018 18:44:58 +0000 Subject: [PATCH] split publishing into its own config, trying to get sbt-pgp to work again --- build.sbt | 105 ++++++++------------------------------------ project/plugins.sbt | 9 ++-- publishing.sbt | 37 ++++++++++++++++ 3 files changed, 61 insertions(+), 90 deletions(-) create mode 100644 publishing.sbt diff --git a/build.sbt b/build.sbt index 66a4b5ea..47327321 100644 --- a/build.sbt +++ b/build.sbt @@ -1,30 +1,19 @@ -import sbtcrossproject.crossProject +import sbtcrossproject.CrossPlugin.autoImport.crossProject scalaVersion in ThisBuild := "2.11.12" crossScalaVersions in ThisBuild := Seq("2.10.7", "2.11.12", "2.12.6", "2.13.0-M3") scalaJSUseRhino in ThisBuild := true -organization in ThisBuild := "org.scalamock" -licenses in ThisBuild := Seq("MIT" -> url("https://opensource.org/licenses/MIT")) -scmInfo in ThisBuild := Some( - ScmInfo(url("https://github.com/paulbutcher/ScalaMock"), "scm:git:git@github.com:paulbutcher/ScalaMock.git") -) -developers in ThisBuild := List( - Developer("paulbutcher", "Paul Butcher", "", url("http://paulbutcher.com/")), - Developer("barkhorn", "Philipp Meyerhoefer", "", url("https://github.com/barkhorn")) -) -homepage in ThisBuild := Some(url("http://scalamock.org/")) lazy val scalatest = "org.scalatest" %% "scalatest" % "3.0.5-M1" lazy val specs2 = Def.setting { val v = CrossVersion.partialVersion(scalaVersion.value) match { - case Some((2, 10)) => - "3.9.1" // specs2 4.x does not support Scala 2.10 - case _ => - "4.0.2" + case Some((2, 10)) => "3.9.1" // specs2 4.x does not support Scala 2.10 + case _ => "4.0.2" } "org.specs2" %% "specs2-core" % v } -lazy val quasiquotes = libraryDependencies ++= { + +lazy val withQuasiquotes = libraryDependencies ++= { CrossVersion.partialVersion(scalaVersion.value) match { case Some((2, 10)) => Seq(compilerPlugin("org.scalamacros" % "paradise" % "2.1.0" cross CrossVersion.full), @@ -46,91 +35,35 @@ val commonSettings = Defaults.coreDefaultSettings ++ Seq( "-target:jvm-" + (if (scalaVersion.value < "2.11") "1.7" else "1.8")) ) -lazy val examples = crossProject(JSPlatform, JVMPlatform) in file("examples") settings( - commonSettings, - name := "ScalaMock Examples", - skip in publish := true, - libraryDependencies ++= Seq( - scalatest % Test, - specs2.value % Test - ) - ) dependsOn scalamock - -lazy val `examples-js` = examples.js - -lazy val `examples-jvm` = examples.jvm - lazy val scalamock = crossProject(JSPlatform, JVMPlatform) in file(".") settings( commonSettings, - publishTo := Some( - if (isSnapshot.value) - Opts.resolver.sonatypeSnapshots - else - Opts.resolver.sonatypeStaging - ), - quasiquotes, name := "scalamock", publishArtifact in (Compile, packageBin) := true, publishArtifact in (Compile, packageDoc) := true, publishArtifact in (Compile, packageSrc) := true, publishArtifact in Test := false, - scalacOptions in (Compile, doc) ++= Opts.doc.title("ScalaMock") ++ Opts.doc.version(version.value) ++ Seq("-doc-root-content", "rootdoc.txt", "-version"), - pomIncludeRepository := { _ => false }, + scalacOptions in (Compile, doc) ++= Opts.doc.title("ScalaMock") ++ + Opts.doc.version(version.value) ++ Seq("-doc-root-content", "rootdoc.txt", "-version"), libraryDependencies ++= Seq( "org.scala-lang" % "scala-reflect" % scalaVersion.value, scalatest % Optional, specs2.value % Optional - ) + ), + withQuasiquotes ) lazy val `scalamock-js` = scalamock.js - lazy val `scalamock-jvm` = scalamock.jvm -releaseCrossBuild := true -releaseProcess := { - import ReleaseTransformations._ - Seq[ReleaseStep]( - checkSnapshotDependencies, - inquireVersions, - runClean, - runTest, - setReleaseVersion, - commitReleaseVersion, - tagRelease, - releaseStepCommand("publishSigned") +lazy val examples = crossProject(JSPlatform, JVMPlatform) in file("examples") settings( + commonSettings, + name := "ScalaMock Examples", + skip in publish := true, + libraryDependencies ++= Seq( + scalatest % Test, + specs2.value % Test ) -} +) dependsOn scalamock -credentials ++= ( - for { - u <- Option(System.getenv().get("SONATYPE_USERNAME")) - p <- Option(System.getenv().get("SONATYPE_PASSWORD")) - } yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", u, p) -).toSeq - -{ - val f = Path.userHome / ".sbt" / ".gpgsettings" - if (f.exists) { - println(s"pgp settings loaded from $f") - val pphrase :: hexkey :: _ = IO.readLines(f) - usePgpKeyHex(hexkey) - Seq( - pgpPassphrase := Some(pphrase.toCharArray), - useGpg := true - ) - } else { - println(s"$f does not exist - pgp settings empty") - Seq.empty[Def.Setting[_]] - } -} - -version in ThisBuild := { - val Snapshot = """(\d+)\.(\d+)\.(\d+)-\d+.*?""".r - git.gitDescribedVersion.value.getOrElse("0.0.0-1")match { - case Snapshot(maj, min, _) => s"$maj.${min.toInt + 1}.0-SNAPSHOT" - case v => v - } -} - -isSnapshot in ThisBuild := version.value.endsWith("-SNAPSHOT") +lazy val `examples-js` = examples.js +lazy val `examples-jvm` = examples.jvm diff --git a/project/plugins.sbt b/project/plugins.sbt index 68153e0b..afb876db 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -1,6 +1,7 @@ -addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.24") -addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0") -addSbtPlugin("com.github.gseitz" % "sbt-release" % "1.0.7") + addSbtPlugin("org.xerial.sbt" % "sbt-sonatype" % "2.3") addSbtPlugin("com.jsuereth" % "sbt-pgp" % "1.1.0") -addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "0.9.3") +addSbtPlugin("com.typesafe.sbt" % "sbt-git" % "1.0.0") + +addSbtPlugin("org.scala-js" % "sbt-scalajs" % "0.6.24") +addSbtPlugin("org.portable-scala" % "sbt-scalajs-crossproject" % "0.5.0") diff --git a/publishing.sbt b/publishing.sbt new file mode 100644 index 00000000..84fa16b1 --- /dev/null +++ b/publishing.sbt @@ -0,0 +1,37 @@ +organization in ThisBuild := "org.scalamock" +licenses in ThisBuild := Seq("MIT" -> url("https://opensource.org/licenses/MIT")) +scmInfo in ThisBuild := Some( + ScmInfo(url("https://github.com/paulbutcher/ScalaMock"), "scm:git:git@github.com:paulbutcher/ScalaMock.git") +) +developers in ThisBuild := List( + Developer("paulbutcher", "Paul Butcher", "", url("http://paulbutcher.com/")), + Developer("barkhorn", "Philipp Meyerhoefer", "", url("https://github.com/barkhorn")) +) +homepage in ThisBuild := Some(url("http://scalamock.org/")) +pomIncludeRepository in ThisBuild := { _ => false } + +version in ThisBuild := { + val Snapshot = """(\d+)\.(\d+)\.(\d+)-\d+.*?""".r + git.gitDescribedVersion.value.getOrElse("0.0.0-1")match { + case Snapshot(maj, min, _) => s"$maj.${min.toInt + 1}.0-SNAPSHOT" + case v => v + } +} + +isSnapshot in ThisBuild := version.value.endsWith("-SNAPSHOT") + +publishTo in ThisBuild := Some( + if (isSnapshot.value) Opts.resolver.sonatypeSnapshots else Opts.resolver.sonatypeStaging +) +publishConfiguration in ThisBuild := publishConfiguration.value.withOverwrite(true) +publishLocalConfiguration in ThisBuild := publishLocalConfiguration.value.withOverwrite(true) + +addCommandAlias("ci-all", ";+clean ;+compile ;+test ;+package") +addCommandAlias("release", ";+publishSigned ;sonatypeReleaseAll") + +credentials ++= ( + for { + u <- Option(System.getenv().get("SONATYPE_USERNAME")) + p <- Option(System.getenv().get("SONATYPE_PASSWORD")) + } yield Credentials("Sonatype Nexus Repository Manager", "oss.sonatype.org", u, p) + ).toSeq