1- import sbt ._
2- import Keys ._
31import com .typesafe .sbt .osgi .{OsgiKeys , SbtOsgi }
4- import com .typesafe .tools .mima .plugin .{MimaPlugin , MimaKeys }, MimaKeys ._
2+ import com .typesafe .tools .mima .plugin .MimaKeys ._
3+ import com .typesafe .tools .mima .plugin .MimaPlugin
4+ import sbt .Keys ._
5+ import sbt .{Def , _ }
56
67object ScalaModulePlugin extends AutoPlugin {
78 val repoName = settingKey[String ](" The name of the repository under github.com/scala/." )
89 val mimaPreviousVersion = settingKey[Option [String ]](" The version of this module to compare against when running MiMa." )
910 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." )
1011
11- // Settings applied to the entire build when the plugin is loaded.
12-
1312 // See https://github.com/sbt/sbt/issues/2082
1413 override def requires = plugins.JvmPlugin
14+
1515 override def trigger = allRequirements
1616
1717 // Settings in here are implicitly `in ThisBuild`
@@ -54,11 +54,16 @@ object ScalaModulePlugin extends AutoPlugin {
5454 )
5555
5656 /**
57- * Enable `-opt:l:classpath` or `-optimize`, depending on the scala version.
57+ * Enable `-opt:l:inline`, `-opt:l: classpath` or `-optimize`, depending on the scala version.
5858 */
59- lazy val enableOptimizer : Setting [_] = scalacOptions in (Compile , compile) += {
60- val Some ((2 , maj)) = CrossVersion .partialVersion(scalaVersion.value)
61- if (maj >= 12 ) " -opt:l:classpath" else " -optimize"
59+ lazy val enableOptimizer : Setting [_] = scalacOptions in (Compile , compile) ++= {
60+ val Ver = """ (\d+)\.(\d+)\.(\d+).*""" .r
61+ val Ver (" 2" , maj, min) = scalaVersion.value
62+ (maj.toInt, min.toInt) match {
63+ case (m, _) if m < 12 => Seq (" -optimize" )
64+ case (12 , n) if n < 3 => Seq (" -opt:l:classpath" )
65+ case _ => Seq (" -opt:l:inline" , " -opt-inline-from:scala/**" )
66+ }
6267 }
6368
6469 /**
@@ -78,8 +83,6 @@ object ScalaModulePlugin extends AutoPlugin {
7883 lazy val scalaModuleSettings : Seq [Setting [_]] = Seq (
7984 repoName := name.value,
8085
81- mimaPreviousVersion := None ,
82-
8386 organization := " org.scala-lang.modules" ,
8487
8588 // don't use for doc scope, scaladoc warnings are not to be reckoned with
@@ -140,6 +143,10 @@ object ScalaModulePlugin extends AutoPlugin {
140143 </developer >
141144 </developers >
142145 )
146+ )
147+
148+ lazy val scalaModuleSettingsJVM : Seq [Setting [_]] = Seq (
149+ mimaPreviousVersion := None
143150 ) ++ mimaSettings ++ scalaModuleOsgiSettings
144151
145152 // 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 {
200207 // a setting-transform to turn the regular version into something osgi can deal with
201208 private val osgiVersion = version(_.replace('-' , '.' ))
202209
203- private lazy val scalaModuleOsgiSettings = SbtOsgi .osgiSettings ++ Seq (
210+ private lazy val scalaModuleOsgiSettings = SbtOsgi .projectSettings ++ SbtOsgi .autoImport. osgiSettings ++ Seq (
204211 OsgiKeys .bundleSymbolicName := s " ${organization.value}. ${name.value}" ,
205212 OsgiKeys .bundleVersion := osgiVersion.value,
206213
0 commit comments