diff --git a/build.sbt b/build.sbt index 5edbe6d..f3e9584 100644 --- a/build.sbt +++ b/build.sbt @@ -24,10 +24,6 @@ bintrayRepository := "sbt-plugins" bintrayOrganization := None -// this plugin depends on the sbt-osgi plugin -- 2-for-1! -// TODO update to 0.8.0 -// this might require us to modify the downstream project to enable the AutoPlugin -// See code changes and docs: https://github.com/sbt/sbt-osgi/commit/e3625e685b8d1784938ec66067d629251811a9d1 -addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.7.0") +addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.1") addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14") diff --git a/src/main/scala/ScalaModulePlugin.scala b/src/main/scala/ScalaModulePlugin.scala index 9ec73a8..9b5a545 100644 --- a/src/main/scala/ScalaModulePlugin.scala +++ b/src/main/scala/ScalaModulePlugin.scala @@ -1,17 +1,17 @@ -import sbt._ -import Keys._ import com.typesafe.sbt.osgi.{OsgiKeys, SbtOsgi} -import com.typesafe.tools.mima.plugin.{MimaPlugin, MimaKeys}, MimaKeys._ +import com.typesafe.tools.mima.plugin.MimaKeys._ +import com.typesafe.tools.mima.plugin.MimaPlugin +import sbt.Keys._ +import sbt.{Def, _} object ScalaModulePlugin extends AutoPlugin { val repoName = settingKey[String]("The name of the repository under github.com/scala/.") val mimaPreviousVersion = settingKey[Option[String]]("The version of this module to compare against when running MiMa.") val scalaVersionsByJvm = settingKey[Map[Int, List[(String, Boolean)]]]("For a Java major version (6, 8, 9), a list of a Scala version and a flag indicating whether to use this combination for publishing.") - // Settings applied to the entire build when the plugin is loaded. - // See https://github.com/sbt/sbt/issues/2082 override def requires = plugins.JvmPlugin + override def trigger = allRequirements // Settings in here are implicitly `in ThisBuild` @@ -54,11 +54,16 @@ object ScalaModulePlugin extends AutoPlugin { ) /** - * Enable `-opt:l:classpath` or `-optimize`, depending on the scala version. + * Enable `-opt:l:inline`, `-opt:l:classpath` or `-optimize`, depending on the scala version. */ - lazy val enableOptimizer: Setting[_] = scalacOptions in (Compile, compile) += { - val Some((2, maj)) = CrossVersion.partialVersion(scalaVersion.value) - if (maj >= 12) "-opt:l:classpath" else "-optimize" + lazy val enableOptimizer: Setting[_] = scalacOptions in (Compile, compile) ++= { + val Ver = """(\d+)\.(\d+)\.(\d+).*""".r + val Ver("2", maj, min) = scalaVersion.value + (maj.toInt, min.toInt) match { + case (m, _) if m < 12 => Seq("-optimize") + case (12, n) if n < 3 => Seq("-opt:l:classpath") + case _ => Seq("-opt:l:inline", "-opt-inline-from:scala/**") + } } /** @@ -78,8 +83,6 @@ object ScalaModulePlugin extends AutoPlugin { lazy val scalaModuleSettings: Seq[Setting[_]] = Seq( repoName := name.value, - mimaPreviousVersion := None, - organization := "org.scala-lang.modules", // don't use for doc scope, scaladoc warnings are not to be reckoned with @@ -140,6 +143,10 @@ object ScalaModulePlugin extends AutoPlugin { ) + ) + + lazy val scalaModuleSettingsJVM: Seq[Setting[_]] = Seq( + mimaPreviousVersion := None ) ++ mimaSettings ++ scalaModuleOsgiSettings // adapted from https://github.com/typesafehub/migration-manager/blob/0.1.6/sbtplugin/src/main/scala/com/typesafe/tools/mima/plugin/SbtMima.scala#L69 @@ -200,7 +207,7 @@ object ScalaModulePlugin extends AutoPlugin { // a setting-transform to turn the regular version into something osgi can deal with private val osgiVersion = version(_.replace('-', '.')) - private lazy val scalaModuleOsgiSettings = SbtOsgi.osgiSettings ++ Seq( + private lazy val scalaModuleOsgiSettings = SbtOsgi.projectSettings ++ SbtOsgi.autoImport.osgiSettings ++ Seq( OsgiKeys.bundleSymbolicName := s"${organization.value}.${name.value}", OsgiKeys.bundleVersion := osgiVersion.value,