Skip to content

Commit ab80996

Browse files
authored
Merge pull request #18 from lrytz/crossVersion
Introduce new scalaVersionsByJvm setting
2 parents 3603bd2 + 24ebe95 commit ab80996

File tree

1 file changed

+36
-11
lines changed

1 file changed

+36
-11
lines changed

src/main/scala/ScalaModulePlugin.scala

+36-11
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import com.typesafe.tools.mima.plugin.{MimaPlugin, MimaKeys}, MimaKeys._
66
object ScalaModulePlugin extends Plugin {
77
val repoName = settingKey[String]("The name of the repository under github.com/scala/.")
88
val mimaPreviousVersion = settingKey[Option[String]]("The version of this module to compare against when running MiMa.")
9+
val scalaVersionsByJvm = settingKey[Map[Int, List[(String, Boolean)]]]("For a Java major version (6, 8, 9), a list of Scala version and a flag indicating whether to use this combination for publishing.")
910

1011
private val canRunMima = taskKey[Boolean]("Decides if MiMa should run.")
1112
private val runMimaIfEnabled = taskKey[Unit]("Run MiMa if mimaPreviousVersion and the module can be resolved against the current scalaBinaryVersion.")
@@ -15,16 +16,40 @@ object ScalaModulePlugin extends Plugin {
1516

1617
mimaPreviousVersion := None,
1718

19+
scalaVersionsByJvm := Map.empty,
20+
21+
crossScalaVersions := {
22+
val OneDot = """1\.(\d).*""".r // 1.6, 1.8
23+
val Maj = """(\d+).*""".r // 9
24+
val javaVersion = System.getProperty("java.version") match {
25+
case OneDot(n) => n.toInt
26+
case Maj(n) => n.toInt
27+
case v => throw new RuntimeException(s"Unknown Java version: $v")
28+
}
29+
val isTravisPublishing = Option(System.getenv("TRAVIS_TAG")).getOrElse("").trim.nonEmpty
30+
val scalaVersions = scalaVersionsByJvm.value.getOrElse(javaVersion, Nil) collect {
31+
case (v, publish) if !isTravisPublishing || publish => v
32+
}
33+
if (scalaVersions.isEmpty) {
34+
if (isTravisPublishing) {
35+
sLog.value.warn(s"No Scala version in `scalaVersionsByJvm` in build.sbt needs to be released on Java major version $javaVersion.")
36+
// Exit successfully, don't fail the (travis) build. This happens for example if `openjdk7`
37+
// is part of the travis configuration for testing, but it's not used for releasing against
38+
// any Scala version.
39+
System.exit(0)
40+
} else
41+
throw new RuntimeException(s"No Scala version for Java major version $javaVersion. Adjust `scalaVersionsByJvm` in build.sbt.")
42+
}
43+
scalaVersions
44+
},
45+
46+
scalaVersion := crossScalaVersions.value.head,
47+
1848
organization := "org.scala-lang.modules",
1949

2050
// so we don't have to wait for sonatype to synch to maven central when deploying a new module
2151
resolvers += Resolver.sonatypeRepo("releases"),
2252

23-
// to allow compiling against snapshot versions of Scala
24-
resolvers += Resolver.sonatypeRepo("snapshots"),
25-
26-
// resolvers += "scala-release-temp" at "http://private-repo.typesafe.com/typesafe/scala-release-temp/"
27-
2853
// don't use for doc scope, scaladoc warnings are not to be reckoned with
2954
// TODO: turn on for nightlies, but don't enable for PR validation... "-Xfatal-warnings"
3055
scalacOptions in compile ++= Seq("-optimize", "-feature", "-deprecation", "-unchecked", "-Xlint"),
@@ -72,17 +97,17 @@ object ScalaModulePlugin extends Plugin {
7297
pomIncludeRepository := { _ => false },
7398
pomExtra := (
7499
<issueManagement>
75-
<system>JIRA</system>
76-
<url>https://issues.scala-lang.org/</url>
100+
<system>GitHub</system>
101+
<url>https://github.com/scala/{repoName.value}/issues</url>
77102
</issueManagement>
78103
<developers>
79104
<developer>
80-
<id>epfl</id>
81-
<name>EPFL</name>
105+
<id>lamp</id>
106+
<name>LAMP/EPFL</name>
82107
</developer>
83108
<developer>
84-
<id>Typesafe</id>
85-
<name>Typesafe, Inc.</name>
109+
<id>Lightbend</id>
110+
<name>Lightbend, Inc.</name>
86111
</developer>
87112
</developers>
88113
)

0 commit comments

Comments
 (0)