You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Convert to AutoPlugin, apply Scala version settings to the build
Make sure to set `crossScalaVersions` / `scalaVersion` (using `scalaVersionsByJvm`) in the
build, not only the project where `scalaModuleSettings` is referenced.
valrepoName= settingKey[String]("The name of the repository under github.com/scala/.")
8
-
valmimaPreviousVersion= settingKey[Option[String]]("The version of this module to compare against when running MiMa.")
9
-
valscalaVersionsByJvm= 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.")
6
+
objectScalaModulePluginextendsAutoPlugin {
7
+
valrepoName= settingKey[String]("The name of the repository under github.com/scala/.")
8
+
valmimaPreviousVersion= settingKey[Option[String]]("The version of this module to compare against when running MiMa.")
9
+
valscalaVersionsByJvm= 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.")
10
10
11
-
privatevalcanRunMima= taskKey[Boolean]("Decides if MiMa should run.")
12
-
privatevalrunMimaIfEnabled= taskKey[Unit]("Run MiMa if mimaPreviousVersion and the module can be resolved against the current scalaBinaryVersion.")
11
+
// Settings applied to the entire build when the plugin is loaded.
13
12
14
-
lazyvalscalaModuleSettings:Seq[Setting[_]] =Seq(
15
-
repoName := name.value,
16
-
17
-
mimaPreviousVersion :=None,
13
+
overridedeftrigger= allRequirements
18
14
19
-
scalaVersionsByJvm :=Map.empty,
15
+
overridedefbuildSettings:Seq[Setting[_]] =Seq(
16
+
scalaVersionsByJvm :=Map.empty,
20
17
21
-
crossScalaVersions := {
18
+
crossScalaVersions in ThisBuild:= {
22
19
valOneDot="""1\.(\d).*""".r // 1.6, 1.8
23
20
valMaj="""(\d+).*""".r // 9
24
21
valjavaVersion=System.getProperty("java.version") match {
25
22
caseOneDot(n) => n.toInt
26
23
caseMaj(n) => n.toInt
27
24
case v =>thrownewRuntimeException(s"Unknown Java version: $v")
case (v, publish) if!isTravisPublishing || publish => v
32
36
}
33
37
if (scalaVersions.isEmpty) {
34
-
if (isTravisPublishing) {
38
+
if (isTravis) {
35
39
sLog.value.warn(s"No Scala version in `scalaVersionsByJvm` in build.sbt needs to be released on Java major version $javaVersion.")
36
40
// Exit successfully, don't fail the (travis) build. This happens for example if `openjdk7`
37
41
// is part of the travis configuration for testing, but it's not used for releasing against
38
42
// any Scala version.
39
43
System.exit(0)
40
44
} else
41
-
thrownewRuntimeException(s"No Scala version for Java major version $javaVersion. Adjust `scalaVersionsByJvm` in build.sbt.")
45
+
thrownewRuntimeException(s"No Scala version for Java major version $javaVersion. Change your Java version or adjust `scalaVersionsByJvm` in build.sbt.")
42
46
}
43
47
scalaVersions
44
48
},
45
49
46
-
scalaVersion := crossScalaVersions.value.head,
50
+
scalaVersion in ThisBuild:= crossScalaVersions.value.head
51
+
)
52
+
53
+
/**
54
+
* Enable `-opt:l:classpath` or `-optimize`, depending on the scala version.
55
+
*/
56
+
lazyvalenableOptimizer:Setting[_] = scalacOptions in (Compile, compile) += {
57
+
valScalaMaj="""2\.(\d+)\..*""".r
58
+
valScalaMaj(scalaMaj) = scalaVersion.value
59
+
if (scalaMaj.toInt >=12) "-opt:l:classpath"else"-optimize"
60
+
}
61
+
62
+
/**
63
+
* Practical for multi-project builds.
64
+
*/
65
+
lazyvaldisablePublishing:Seq[Setting[_]] =Seq(
66
+
publishArtifact :=false,
67
+
// The above is enough for Maven repos but it doesn't prevent publishing of ivy.xml files
0 commit comments