@@ -11,9 +11,13 @@ import sbt.librarymanagement.ivy.IvyDependencyResolution
11
11
import sbt .librarymanagement .{ UnresolvedWarningConfiguration , UpdateConfiguration }
12
12
13
13
object ScalaModulePlugin extends AutoPlugin {
14
- val repoName = settingKey[String ](" The name of the repository under github.com/scala/." )
15
- val mimaPreviousVersion = settingKey[Option [String ]](" The version of this module to compare against when running MiMa." )
16
- 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." )
14
+ object autoImport {
15
+ val scalaModuleRepoName = settingKey[String ](" The name of the repository under github.com/scala/." )
16
+ val scalaModuleMimaPreviousVersion = settingKey[Option [String ]](" The version of this module to compare against when running MiMa." )
17
+ val scalaModuleScalaVersionsByJvm = 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." )
18
+ val scalaModuleEnableOptimizerInlineFrom = settingKey[String ](" The value passed to -opt-inline-from by `enableOptimizer` on 2.13 and higher." )
19
+ }
20
+ import autoImport ._
17
21
18
22
// See https://github.com/sbt/sbt/issues/2082
19
23
override def requires = plugins.JvmPlugin
@@ -22,7 +26,7 @@ object ScalaModulePlugin extends AutoPlugin {
22
26
23
27
// Settings in here are implicitly `in ThisBuild`
24
28
override def buildSettings : Seq [Setting [_]] = Seq (
25
- scalaVersionsByJvm := Map .empty,
29
+ scalaModuleScalaVersionsByJvm := Map .empty,
26
30
27
31
crossScalaVersions := {
28
32
val OneDot = """ 1\.(\d).*""" .r // 1.6, 1.8
@@ -36,7 +40,7 @@ object ScalaModulePlugin extends AutoPlugin {
36
40
val isTravis = Option (System .getenv(" TRAVIS" )).exists(_ == " true" ) // `contains` doesn't exist in Scala 2.10
37
41
val isTravisPublishing = Option (System .getenv(" TRAVIS_TAG" )).exists(_.trim.nonEmpty)
38
42
39
- val byJvm = scalaVersionsByJvm .value
43
+ val byJvm = scalaModuleScalaVersionsByJvm .value
40
44
if (byJvm.isEmpty)
41
45
throw new RuntimeException (s " Make sure to define `scalaVersionsByJvm in ThisBuild` in `build.sbt` in the root project, using the `ThisBuild` scope. " )
42
46
@@ -55,11 +59,10 @@ object ScalaModulePlugin extends AutoPlugin {
55
59
}
56
60
scalaVersions
57
61
},
58
- enableOptimizerInlineFrom := " <sources>" ,
62
+ scalaModuleEnableOptimizerInlineFrom := " <sources>" ,
59
63
scalaVersion := crossScalaVersions.value.head
60
64
)
61
65
62
- val enableOptimizerInlineFrom = settingKey[String ](" The value passed to -opt-inline-from by `enableOptimizer` on 2.13 and higher" )
63
66
/**
64
67
* Enable `-opt:l:inline`, `-opt:l:classpath` or `-optimize`, depending on the scala version.
65
68
*/
@@ -69,7 +72,7 @@ object ScalaModulePlugin extends AutoPlugin {
69
72
(maj.toInt, min.toInt) match {
70
73
case (m, _) if m < 12 => Seq (" -optimize" )
71
74
case (12 , n) if n < 3 => Seq (" -opt:l:project" )
72
- case _ => Seq (" -opt:l:inline" , " -opt-inline-from:" + enableOptimizerInlineFrom .value)
75
+ case _ => Seq (" -opt:l:inline" , " -opt-inline-from:" + scalaModuleEnableOptimizerInlineFrom .value)
73
76
}
74
77
}
75
78
@@ -88,7 +91,7 @@ object ScalaModulePlugin extends AutoPlugin {
88
91
* To be included in the main sbt project of a Scala module.
89
92
*/
90
93
lazy val scalaModuleSettings : Seq [Setting [_]] = Seq (
91
- repoName := name.value,
94
+ scalaModuleRepoName := name.value,
92
95
93
96
organization := " org.scala-lang.modules" ,
94
97
@@ -128,7 +131,7 @@ object ScalaModulePlugin extends AutoPlugin {
128
131
},
129
132
130
133
publishMavenStyle := true ,
131
- scmInfo := Some (ScmInfo (url(s " https://github.com/scala/ ${repoName .value}" ),s " scm:git:git://github.com/scala/ ${repoName .value}.git " )),
134
+ scmInfo := Some (ScmInfo (url(s " https://github.com/scala/ ${scalaModuleRepoName .value}" ),s " scm:git:git://github.com/scala/ ${scalaModuleRepoName .value}.git " )),
132
135
homepage := Some (url(" http://www.scala-lang.org/" )),
133
136
organizationHomepage := Some (url(" http://www.scala-lang.org/" )),
134
137
licenses := Seq (" Apache-2.0" -> url(" https://www.apache.org/licenses/LICENSE-2.0" )),
@@ -137,7 +140,7 @@ object ScalaModulePlugin extends AutoPlugin {
137
140
pomExtra := (
138
141
<issueManagement >
139
142
<system >GitHub </system >
140
- <url >https:// github.com/ scala/ {repoName .value}/ issues</url >
143
+ <url >https:// github.com/ scala/ {scalaModuleRepoName .value}/ issues</url >
141
144
</issueManagement >
142
145
<developers >
143
146
<developer >
@@ -169,14 +172,14 @@ object ScalaModulePlugin extends AutoPlugin {
169
172
private val runMimaIfEnabled = taskKey[Unit ](" Run MiMa if mimaPreviousVersion and the module can be resolved against the current scalaBinaryVersion." )
170
173
171
174
private lazy val mimaSettings : Seq [Setting [_]] = MimaPlugin .mimaDefaultSettings ++ Seq (
172
- mimaPreviousVersion := None ,
175
+ scalaModuleMimaPreviousVersion := None ,
173
176
174
177
// We're not using `%%` here in order to support both jvm and js projects (cross version `_2.12` / `_sjs0.6_2.12`)
175
- mimaPreviousArtifacts := mimaPreviousVersion .value.map(v => organization.value % moduleName.value % v cross crossVersion.value).toSet,
178
+ mimaPreviousArtifacts := scalaModuleMimaPreviousVersion .value.map(v => organization.value % moduleName.value % v cross crossVersion.value).toSet,
176
179
177
180
canRunMima := {
178
181
val log = streams.value.log
179
- mimaPreviousVersion .value match {
182
+ scalaModuleMimaPreviousVersion .value match {
180
183
case None =>
181
184
log.warn(" MiMa will NOT run because no mimaPreviousVersion is provided." )
182
185
false
0 commit comments