@@ -227,12 +227,6 @@ object Build {
227227 // Bootstrap with -optimise
228228 lazy val commonOptimisedSettings = commonBootstrappedSettings ++ Seq (scalacOptions ++= Seq (" -optimise" ))
229229
230- def commonDottySettings (implicit mode : Mode ): Seq [sbt.Def .Setting [_]] = mode match {
231- case NonBootstrapped => commonNonBootstrappedSettings
232- case Bootstrapped => commonBootstrappedSettings
233- case BootstrappedOptimised => commonOptimisedSettings
234- }
235-
236230 lazy val commonBenchmarkSettings = Seq (
237231 mainClass in (Jmh , run) := Some (" dotty.tools.benchmarks.Bench" ), // custom main for jmh:run
238232 javaOptions += " -DBENCH_CLASS_PATH=" + Attributed .data((fullClasspath in Compile ).value).mkString(" " , " :" , " " )
@@ -245,7 +239,7 @@ object Build {
245239 // This means that we need to provide dummy artefacts for these projects,
246240 // otherwise users will get compilation errors if they happen to transitively
247241 // depend on one of these projects.
248- lazy val commonDummySettings = commonDottySettings( Bootstrapped ) ++ Seq (
242+ lazy val commonDummySettings = commonBootstrappedSettings ++ Seq (
249243 crossPaths := false ,
250244 libraryDependencies := Seq ()
251245 )
@@ -726,7 +720,7 @@ object Build {
726720
727721 lazy val `dotty-language-server` = project.in(file(" language-server" )).
728722 dependsOn(dottyCompiler(Bootstrapped )).
729- settings(commonDottySettings( Bootstrapped ) ).
723+ settings(commonBootstrappedSettings ).
730724 settings(
731725 // Sources representing the shared configuration file used to communicate between the sbt-dotty
732726 // plugin and the language server
@@ -770,7 +764,7 @@ object Build {
770764 */
771765 lazy val sjsSandbox = project.in(file(" sandbox/scalajs" )).
772766 enablePlugins(ScalaJSPlugin ).
773- settings(commonDottySettings( NonBootstrapped ) ).
767+ settings(commonNonBootstrappedSettings ).
774768 settings(
775769 /* Remove the Scala.js compiler plugin for scalac, and enable the
776770 * Scala.js back-end of dotty instead.
@@ -1112,12 +1106,11 @@ object Build {
11121106 implicit class ProjectDefinitions (val project : Project ) extends AnyVal {
11131107
11141108 // FIXME: we do not aggregate `bin` because its tests delete jars, thus breaking other tests
1115- def asDottyRoot (implicit mode : Mode ): Project = project.
1109+ def asDottyRoot (implicit mode : Mode ): Project = project.withCommonSettings.
11161110 aggregate(`dotty-interfaces`, dottyLibrary, dottyCompiler, dottyDoc, `dotty-language-server`, dottySbtBridgeReference).
11171111 bootstrappedAggregate(`scala-library`, `scala-compiler`, `scala-reflect`, scalap).
11181112 dependsOn(dottyCompiler).
11191113 dependsOn(dottyLibrary).
1120- settings(commonDottySettings).
11211114 nonBootstrappedSettings(
11221115 triggeredMessage in ThisBuild := Watched .clearWhenTriggered,
11231116 dottyProjectFolderChecks,
@@ -1126,45 +1119,45 @@ object Build {
11261119 addCommandAlias(" legacyTests" , " dotty-compiler/testOnly dotc.tests" )
11271120 )
11281121
1129- def asDottyCompiler (implicit mode : Mode ): Project = project.
1122+ def asDottyCompiler (implicit mode : Mode ): Project = project.withCommonSettings.
11301123 dependsOn(`dotty-interfaces`).
11311124 dependsOn(dottyLibrary).
1132- settings(commonDottySettings).
11331125 settings(dottyCompilerSettings)
11341126
1135- def asDottyLibrary (implicit mode : Mode ): Project = project.
1136- settings(commonDottySettings).
1127+ def asDottyLibrary (implicit mode : Mode ): Project = project.withCommonSettings.
11371128 settings(dottyLibrarySettings).
11381129 bootstrappedSettings(
11391130 // Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called.
11401131 scalacOptions in Compile ++= Seq (" -sourcepath" , (scalaSource in Compile ).value.getAbsolutePath)
11411132 )
11421133
1143- def asDottyDoc (implicit mode : Mode ): Project = project.
1134+ def asDottyDoc (implicit mode : Mode ): Project = project.withCommonSettings.
11441135 dependsOn(dottyCompiler, dottyCompiler % " test->test" ).
1145- settings(commonDottySettings).
11461136 settings(dottyDocSettings)
11471137
1148- def asDottySbtBridge (implicit mode : Mode ): Project = project.
1138+ def asDottySbtBridge (implicit mode : Mode ): Project = project.withCommonSettings.
11491139 dependsOn(dottyCompiler).
1150- settings(commonDottySettings).
11511140 settings(dottySbtBridgeSettings)
11521141
1153- def asDottyBench (implicit mode : Mode ): Project = project.
1142+ def asDottyBench (implicit mode : Mode ): Project = project.withCommonSettings.
11541143 dependsOn(dottyCompiler).
1155- settings(commonDottySettings).
11561144 settings(commonBenchmarkSettings).
11571145 bootstrappedSettings(unmanagedSourceDirectories in Compile ++= Seq (baseDirectory.value / " .." / " bench" / " src" )).
11581146 enablePlugins(JmhPlugin )
11591147
1160- def asDist (implicit mode : Mode ): Project = project.
1148+ def asDist (implicit mode : Mode ): Project = project.withCommonSettings.
11611149 dependsOn(`dotty-interfaces`).
11621150 dependsOn(dottyCompiler).
11631151 dependsOn(dottyLibrary).
11641152 dependsOn(dottyDoc).
1165- settings(commonDottySettings).
11661153 settings(commonDistSettings).
1167- bootstrappedSettings(target := baseDirectory.value / " target" ) // override setting in commonDottySettings)
1154+ bootstrappedSettings(target := baseDirectory.value / " target" ) // override setting in commonBootstrappedSettings
1155+
1156+ def withCommonSettings (implicit mode : Mode ): Project = project.settings(mode match {
1157+ case NonBootstrapped => commonNonBootstrappedSettings
1158+ case Bootstrapped => commonBootstrappedSettings
1159+ case BootstrappedOptimised => commonOptimisedSettings
1160+ })
11681161 }
11691162
11701163}
0 commit comments