Skip to content

Commit 168efa7

Browse files
committed
Build.scala: Replace thisBuildSettings and sourceStructure by commonSettings
No need to have multiple ways to define settings common to all projects, and thisBuildSettings doesn't work for keys which are defined in every project but not globally.
1 parent 954afd4 commit 168efa7

File tree

2 files changed

+28
-29
lines changed

2 files changed

+28
-29
lines changed

build.sbt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,3 @@ val `scala-library` = Build.`scala-library`
1616
val `scala-compiler` = Build.`scala-compiler`
1717
val `scala-reflect` = Build.`scala-reflect`
1818
val scalap = Build.scalap
19-
20-
inThisBuild(Build.thisBuildSettings)

project/Build.scala

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -65,28 +65,23 @@ object Build {
6565
// Shorthand for compiling a docs site
6666
lazy val dottydoc = inputKey[Unit]("run dottydoc")
6767

68-
// Used in build.sbt
69-
val thisBuildSettings = Seq(
70-
scalaVersion in Global := scalacVersion,
71-
version in Global := dottyVersion,
72-
organization in Global := dottyOrganization,
73-
organizationName in Global := "LAMP/EPFL",
74-
organizationHomepage in Global := Some(url("http://lamp.epfl.ch")),
75-
homepage in Global := Some(url("https://github.com/lampepfl/dotty")),
76-
77-
// scalac options
78-
scalacOptions in Global ++= Seq(
68+
lazy val commonSettings = Seq(
69+
scalaVersion := scalacVersion,
70+
version := dottyVersion,
71+
organization := dottyOrganization,
72+
organizationName := "LAMP/EPFL",
73+
organizationHomepage := Some(url("http://lamp.epfl.ch")),
74+
homepage := Some(url("https://github.com/lampepfl/dotty")),
75+
76+
scalacOptions ++= Seq(
7977
"-feature",
8078
"-deprecation",
8179
"-encoding", "UTF8",
8280
"-language:existentials,higherKinds,implicitConversions"
8381
),
8482

85-
javacOptions in Global ++= Seq("-Xlint:unchecked", "-Xlint:deprecation")
86-
)
83+
javacOptions ++= Seq("-Xlint:unchecked", "-Xlint:deprecation"),
8784

88-
// set sources to src/, tests to test/ and resources to resources/
89-
lazy val sourceStructure = Seq(
9085
scalaSource in Compile := baseDirectory.value / "src",
9186
scalaSource in Test := baseDirectory.value / "test",
9287
javaSource in Compile := baseDirectory.value / "src",
@@ -129,6 +124,7 @@ object Build {
129124
`scala-library`, `scala-compiler`, `scala-reflect`, scalap).
130125
dependsOn(`dotty-compiler`).
131126
dependsOn(`dotty-library`).
127+
settings(commonSettings).
132128
settings(
133129
triggeredMessage in ThisBuild := Watched.clearWhenTriggered,
134130

@@ -140,12 +136,13 @@ object Build {
140136
// Meta project aggregating all bootstrapped projects
141137
lazy val `dotty-bootstrapped` = project.
142138
aggregate(`dotty-library-bootstrapped`, `dotty-compiler-bootstrapped`, `dotty-doc-bootstrapped`).
139+
settings(commonSettings).
143140
settings(
144141
publishArtifact := false
145142
)
146143

147144
lazy val `dotty-interfaces` = project.in(file("interfaces")).
148-
settings(sourceStructure).
145+
settings(commonSettings).
149146
settings(
150147
// Do not append Scala versions to the generated artifacts
151148
crossPaths := false,
@@ -214,19 +211,19 @@ object Build {
214211

215212
lazy val `dotty-doc` = project.in(file("doc-tool")).
216213
dependsOn(`dotty-compiler`, `dotty-compiler` % "test->test").
217-
settings(sourceStructure).
214+
settings(commonSettings).
218215
settings(dottyDocSettings).
219216
settings(publishing)
220217

221218
lazy val `dotty-doc-bootstrapped` = project.in(file("doc-tool")).
222219
dependsOn(`dotty-compiler-bootstrapped`, `dotty-compiler-bootstrapped` % "test->test").
223-
settings(sourceStructure).
220+
settings(commonSettings).
224221
settings(commonBootstrappedSettings).
225222
settings(dottyDocSettings)
226223

227224

228225
lazy val `dotty-bot` = project.in(file("bot")).
229-
settings(sourceStructure).
226+
settings(commonSettings).
230227
settings(
231228
resourceDirectory in Test := baseDirectory.value / "test" / "resources",
232229

@@ -485,7 +482,7 @@ object Build {
485482
lazy val `dotty-compiler` = project.in(file("compiler")).
486483
dependsOn(`dotty-interfaces`).
487484
dependsOn(`dotty-library`).
488-
settings(sourceStructure).
485+
settings(commonSettings).
489486
settings(dottyCompilerSettings).
490487
settings(
491488
// Disable scaladoc generation, it's way too slow and we'll replace it
@@ -507,7 +504,7 @@ object Build {
507504

508505
lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).
509506
dependsOn(`dotty-library-bootstrapped`).
510-
settings(sourceStructure).
507+
settings(commonSettings).
511508
settings(commonBootstrappedSettings).
512509
settings(dottyCompilerSettings).
513510
settings(
@@ -524,7 +521,7 @@ object Build {
524521

525522
/* Contains unit tests for the scripts */
526523
lazy val `dotty-bin-tests` = project.in(file("bin")).
527-
settings(sourceStructure).
524+
settings(commonSettings).
528525
settings(
529526
publishArtifact := false,
530527
parallelExecution in Test := false,
@@ -542,12 +539,12 @@ object Build {
542539
)
543540

544541
lazy val `dotty-library` = project.in(file("library")).
545-
settings(sourceStructure).
542+
settings(commonSettings).
546543
settings(dottyLibrarySettings).
547544
settings(publishing)
548545

549546
lazy val `dotty-library-bootstrapped` = project.in(file("library")).
550-
settings(sourceStructure).
547+
settings(commonSettings).
551548
settings(commonBootstrappedSettings).
552549
settings(dottyLibrarySettings)
553550

@@ -556,7 +553,7 @@ object Build {
556553

557554
lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge")).
558555
dependsOn(`dotty-compiler`).
559-
settings(sourceStructure).
556+
settings(commonSettings).
560557
settings(
561558
cleanSbtBridge := {
562559
val dottySbtBridgeVersion = version.value
@@ -643,7 +640,7 @@ object DottyInjectedPlugin extends AutoPlugin {
643640
*/
644641
lazy val sjsSandbox = project.in(file("sandbox/scalajs")).
645642
enablePlugins(ScalaJSPlugin).
646-
settings(sourceStructure).
643+
settings(commonSettings).
647644
settings(
648645
/* Remove the Scala.js compiler plugin for scalac, and enable the
649646
* Scala.js back-end of dotty instead.
@@ -676,7 +673,7 @@ object DottyInjectedPlugin extends AutoPlugin {
676673

677674
lazy val `dotty-bench` = project.in(file("bench")).
678675
dependsOn(`dotty-compiler` % "compile->test").
679-
settings(sourceStructure).
676+
settings(commonSettings).
680677
settings(
681678
baseDirectory in (Test,run) := (baseDirectory in `dotty-compiler`).value,
682679

@@ -718,6 +715,7 @@ object DottyInjectedPlugin extends AutoPlugin {
718715
// automatically depend on scalaOrganization.value % "scala-library" % scalaVersion.value
719716
lazy val `scala-library` = project.
720717
dependsOn(`dotty-library`).
718+
settings(commonSettings).
721719
settings(
722720
crossPaths := false
723721
).
@@ -731,17 +729,20 @@ object DottyInjectedPlugin extends AutoPlugin {
731729
// otherwise users will get compilation errors if they happen to transitively
732730
// depend on one of these projects.
733731
lazy val `scala-compiler` = project.
732+
settings(commonSettings).
734733
settings(
735734
crossPaths := false
736735
).
737736
settings(publishing)
738737
lazy val `scala-reflect` = project.
738+
settings(commonSettings).
739739
settings(
740740
crossPaths := false,
741741
libraryDependencies := Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
742742
).
743743
settings(publishing)
744744
lazy val scalap = project.
745+
settings(commonSettings).
745746
settings(
746747
crossPaths := false,
747748
libraryDependencies := Seq("org.scala-lang" % "scalap" % scalaVersion.value)

0 commit comments

Comments
 (0)