1- import ScalaModulePlugin ._
2- import sbtcrossproject .{crossProject , CrossType }
31import _root_ .scalafix .sbt .BuildInfo .{scalafixVersion , scala212 => scalafixScala212 }
4- import sys .process ._
2+ import com .lightbend .tools .scalamoduleplugin .ScalaModulePlugin ._
3+
4+ import scala .sys .process ._
55
66lazy val commonSettings = Seq (
77 headerLicense := Some (HeaderLicense .Custom (s """ |Scala (https://www.scala-lang.org)
@@ -14,11 +14,9 @@ lazy val commonSettings = Seq(
1414 |See the NOTICE file distributed with this work for
1515 |additional information regarding copyright ownership.
1616 | """ .stripMargin)),
17- mimaPreviousVersion := Some (" 2.1.1" ),
17+ scalaModuleMimaPreviousVersion := Some (" 2.1.1" ),
1818)
1919
20- version in ThisBuild := " 2.1.3-SNAPSHOT"
21-
2220lazy val root = project
2321 .in(file(" ." ))
2422 .settings(commonSettings)
@@ -52,16 +50,6 @@ lazy val scala211 = "2.11.12"
5250lazy val scala212 = " 2.12.8"
5351lazy val scala213 = " 2.13.0"
5452
55- scalaVersionsByJvm in ThisBuild := {
56- val all = List (scala211, scala212, scala213)
57- // Map[JvmMajorVersion, List[(ScalaVersion, UseForPublishing)]]
58- Map (
59- 8 -> all.map(_ -> true ),
60- 11 -> all.map(_ -> false ),
61- 12 -> all.map(_ -> false )
62- )
63- }
64-
6553/** Create an OSGi version range for standard Scala versioning
6654 * schemes that describes binary compatible versions. */
6755def osgiVersionRange (version : String , requireMicro : Boolean = false ): String =
@@ -289,54 +277,21 @@ lazy val dontPublish = Seq(
289277 packagedArtifacts := Map .empty,
290278 publish := {},
291279 publishLocal := {},
292- mimaPreviousVersion := None ,
280+ scalaModuleMimaPreviousVersion := None ,
293281)
294282
295- val preRelease = " preRelease"
296283val travisScalaVersion = sys.env.get(" TRAVIS_SCALA_VERSION" ).flatMap(Version .parse)
297284val releaseVersion = sys.env.get(" TRAVIS_TAG" ).flatMap(Version .parse)
298285val isScalaJs = sys.env.get(" SCALAJS_VERSION" ).map(_.nonEmpty).getOrElse(false )
299286val isScalaNative = sys.env.get(" SCALANATIVE_VERSION" ).map(_.nonEmpty).getOrElse(false )
300287val isScalafix = sys.env.get(" TEST_SCALAFIX" ).nonEmpty
301288val isScalafmt = sys.env.get(" TEST_SCALAFMT" ).nonEmpty
302289val isBinaryCompat = sys.env.get(" TEST_BINARY_COMPAT" ).nonEmpty
303- val isRelease = releaseVersion.nonEmpty
304-
305- val releaseCredentials =
306- if (isRelease) {
307- def env (key : String ): String = Option (System .getenv(key)).getOrElse(" " )
308-
309- Seq (
310- pgpPassphrase := Some (env(" PGP_PASSPHRASE" ).toArray),
311- pgpPublicRing := file(" admin/pubring.asc" ),
312- pgpSecretRing := file(" admin/secring.asc" ),
313- credentials += Credentials (" Sonatype Nexus Repository Manager" ,
314- " oss.sonatype.org" ,
315- env(" SONA_USER" ),
316- env(" SONA_PASS" ))
317- )
318- } else {
319- Seq ()
320- }
321-
322- inThisBuild(releaseCredentials)
290+ val jdkVersion = sys.env.get(" ADOPTOPENJDK" ).map(_.toInt)
323291
324292// required by sbt-scala-module
325293inThisBuild(
326294 Seq (
327- commands += Command .command(preRelease) { state =>
328- // Show Compat version, Scala version, and Java Version
329- val jvmVersion = Version .parse(sys.props(" java.specification.version" )).get.minor
330- releaseVersion match {
331- case Some (tagVersion) =>
332- println(
333- s " Releasing $tagVersion with Scala ${travisScalaVersion.get} on Java version $jvmVersion. " )
334- // Copy pgp stuff
335- " admin/pre-release.sh" ! state.globalLogging.full
336- case None =>
337- }
338- state
339- },
340295 commands += Command .command(" scalafmt-test" ) { state =>
341296 Seq (" admin/scalafmt.sh" , " --test" ) ! state.globalLogging.full
342297 state
@@ -388,10 +343,18 @@ inThisBuild(
388343 releaseVersion.map(" set every version := \" " + _ + " \" " ).toList
389344
390345 val publishTask =
391- if (releaseVersion.nonEmpty && ! isBinaryCompat) {
346+ if (releaseVersion.nonEmpty && ! isBinaryCompat && jdkVersion == Some (8 )) {
347+ // we cannot run "ci-release" because that reads the `CI_RELEASE` / `CI_SONATYPE_RELEASE`
348+ // env vars, which we cannot modify from java (easily). so we inline what this command does.
349+ CiReleasePlugin .setupGpg()
392350 List (
393- preRelease,
394- s " $projectPrefix/publishSigned "
351+ // work around https://github.com/olafurpg/sbt-ci-release/issues/64
352+ " set pgpSecretRing := pgpSecretRing.value" ,
353+ " set pgpPublicRing := pgpPublicRing.value" ,
354+ s " $projectPrefix/publishSigned " ,
355+ " sonatypePrepare" ,
356+ " sonatypeBundleUpload" ,
357+ " sonatypeClose" ,
395358 )
396359 } else {
397360 Nil
0 commit comments