Skip to content

Commit 0928a5d

Browse files
committed
Split jvm-specific settings into scalaModuleSettingsJVM
Move jvm-specific settings from scalaModuleSettings to a new scalaModuleSettingsJVM setting. This means that JVM projects in scala modules now have to add bot `scalaModuleSettings` and `scalaModuleSettingsJVM`. Adding sbt-osgi settings in a scala-js project caused the published jar to be empty (scala/scala-parser-combinators#119). Upgrades sbt-osgi to the latest version. Also anticipates the new optimizer settings in 2.12.3 (scala/scala#5964).
1 parent 040871b commit 0928a5d

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-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

+18-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,15 @@ 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 v = scalaVersion.value
61+
val Some((2, maj)) = CrossVersion.partialVersion(v)
62+
if (maj >= 12) {
63+
if (v.startsWith("2.12.3")) Seq("-opt:l:inline", "-opt-inline-from", "scala.**")
64+
else Seq("-opt:l:classpath")
65+
} else Seq("-optimize")
6266
}
6367

6468
/**
@@ -78,8 +82,6 @@ object ScalaModulePlugin extends AutoPlugin {
7882
lazy val scalaModuleSettings: Seq[Setting[_]] = Seq(
7983
repoName := name.value,
8084

81-
mimaPreviousVersion := None,
82-
8385
organization := "org.scala-lang.modules",
8486

8587
// don't use for doc scope, scaladoc warnings are not to be reckoned with
@@ -140,6 +142,10 @@ object ScalaModulePlugin extends AutoPlugin {
140142
</developer>
141143
</developers>
142144
)
145+
)
146+
147+
lazy val scalaModuleSettingsJVM: Seq[Setting[_]] = Seq(
148+
mimaPreviousVersion := None
143149
) ++ mimaSettings ++ scalaModuleOsgiSettings
144150

145151
// 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 +206,7 @@ object ScalaModulePlugin extends AutoPlugin {
200206
// a setting-transform to turn the regular version into something osgi can deal with
201207
private val osgiVersion = version(_.replace('-', '.'))
202208

203-
private lazy val scalaModuleOsgiSettings = SbtOsgi.osgiSettings ++ Seq(
209+
private lazy val scalaModuleOsgiSettings = SbtOsgi.projectSettings ++ SbtOsgi.autoImport.osgiSettings ++ Seq(
204210
OsgiKeys.bundleSymbolicName := s"${organization.value}.${name.value}",
205211
OsgiKeys.bundleVersion := osgiVersion.value,
206212

0 commit comments

Comments
 (0)