Skip to content

Commit 74b093e

Browse files
authored
Merge pull request #27 from lrytz/sbt-osgi-0.9.1
Split jvm-specific settings into scalaModuleSettingsJVM
2 parents 040871b + a3b5676 commit 74b093e

File tree

2 files changed

+20
-17
lines changed

2 files changed

+20
-17
lines changed

build.sbt

+1-5
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@ bintrayRepository := "sbt-plugins"
2424

2525
bintrayOrganization := None
2626

27-
// this plugin depends on the sbt-osgi plugin -- 2-for-1!
28-
// TODO update to 0.8.0
29-
// this might require us to modify the downstream project to enable the AutoPlugin
30-
// See code changes and docs: https://github.com/sbt/sbt-osgi/commit/e3625e685b8d1784938ec66067d629251811a9d1
31-
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.7.0")
27+
addSbtPlugin("com.typesafe.sbt" % "sbt-osgi" % "0.9.1")
3228

3329
addSbtPlugin("com.typesafe" % "sbt-mima-plugin" % "0.1.14")

src/main/scala/ScalaModulePlugin.scala

+19-12
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import sbt._
2-
import Keys._
31
import 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

67
object 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

Comments
 (0)