Skip to content

Commit af0ebac

Browse files
committed
Distinguish four kinds of projects
There are four kinds of projects in our build: - Projects compiled only with Scala 2 (dotty-bot, as well as dotty-interfaces since it's Java-only) - Projects that are part of dotty and compiled with Scala 2 - Projects that are part of dotty and compiled with a non-bootstrapped dotty - Dummy projects for scala{-library,-compiler,-reflect,p}, see the comment above `commonDummySettings` They are now distinguished using four sets of settings. The first and second set are identical but this will change with the next commit.
1 parent f7df65e commit af0ebac

File tree

1 file changed

+49
-48
lines changed

1 file changed

+49
-48
lines changed

project/Build.scala

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ object Build {
6666
lazy val dottydoc = inputKey[Unit]("run dottydoc")
6767

6868
lazy val commonSettings = publishSettings ++ Seq(
69-
scalaVersion := scalacVersion,
70-
version := dottyVersion,
7169
organization := dottyOrganization,
7270
organizationName := "LAMP/EPFL",
7371
organizationHomepage := Some(url("http://lamp.epfl.ch")),
@@ -92,11 +90,24 @@ object Build {
9290
ivyScala ~= (_ map (_ copy (overrideScalaVersion = false)))
9391
)
9492

95-
// Settings used by all dotty-compiled projects
96-
lazy val commonBootstrappedSettings = Seq(
93+
// Settings used for projects compiled only with Scala 2
94+
lazy val commonScala2Settings = commonSettings ++ Seq(
95+
version := dottyVersion,
96+
scalaVersion := scalacVersion
97+
)
98+
99+
// Settings used when compiling dotty using Scala 2
100+
lazy val commonNonBootstrappedSettings = commonSettings ++ publishSettings ++ Seq(
101+
version := dottyVersion,
102+
scalaVersion := scalacVersion
103+
)
104+
105+
// Settings used when compiling dotty with a non-bootstrapped dotty
106+
lazy val commonBootstrappedSettings = commonSettings ++ Seq(
97107
EclipseKeys.skipProject := true,
98-
scalaOrganization := dottyOrganization,
108+
version := dottyVersion,
99109
scalaVersion := dottyVersion,
110+
scalaOrganization := dottyOrganization,
100111
scalaBinaryVersion := "2.11",
101112

102113
// sbt gets very unhappy if two projects use the same target
@@ -108,6 +119,18 @@ object Build {
108119
libraryDependencies += "org.scala-lang" % "scala-library" % scalacVersion
109120
)
110121

122+
// sbt >= 0.13.12 will automatically rewrite transitive dependencies on
123+
// any version in any organization of scala{-library,-compiler,-reflect,p}
124+
// to have organization `scalaOrganization` and version `scalaVersion`
125+
// (see https://github.com/sbt/sbt/pull/2634).
126+
// This means that we need to provide dummy artefacts for these projects,
127+
// otherwise users will get compilation errors if they happen to transitively
128+
// depend on one of these projects.
129+
lazy val commonDummySettings = commonNonBootstrappedSettings ++ Seq(
130+
crossPaths := false,
131+
libraryDependencies := Seq()
132+
)
133+
111134
/** Projects -------------------------------------------------------------- */
112135

113136
// Needed because the dotty project aggregates dotty-sbt-bridge but dotty-sbt-bridge
@@ -127,7 +150,7 @@ object Build {
127150
`scala-library`, `scala-compiler`, `scala-reflect`, scalap).
128151
dependsOn(`dotty-compiler`).
129152
dependsOn(`dotty-library`).
130-
settings(commonSettings).
153+
settings(commonNonBootstrappedSettings).
131154
settings(
132155
triggeredMessage in ThisBuild := Watched.clearWhenTriggered,
133156

@@ -139,13 +162,13 @@ object Build {
139162
lazy val `dotty-bootstrapped` = project.
140163
aggregate(`dotty-library-bootstrapped`, `dotty-compiler-bootstrapped`, `dotty-doc-bootstrapped`,
141164
dottySbtBridgeBootstrappedRef).
142-
settings(commonSettings).
165+
settings(commonBootstrappedSettings).
143166
settings(
144167
publishArtifact := false
145168
)
146169

147170
lazy val `dotty-interfaces` = project.in(file("interfaces")).
148-
settings(commonSettings).
171+
settings(commonScala2Settings). // Java-only project, so this is fine
149172
settings(
150173
// Do not append Scala versions to the generated artifacts
151174
crossPaths := false,
@@ -213,19 +236,17 @@ object Build {
213236

214237
lazy val `dotty-doc` = project.in(file("doc-tool")).
215238
dependsOn(`dotty-compiler`, `dotty-compiler` % "test->test").
216-
settings(commonSettings).
217-
settings(dottyDocSettings).
218-
settings(publishSettings)
239+
settings(commonNonBootstrappedSettings).
240+
settings(dottyDocSettings)
219241

220242
lazy val `dotty-doc-bootstrapped` = project.in(file("doc-tool")).
221243
dependsOn(`dotty-compiler-bootstrapped`, `dotty-compiler-bootstrapped` % "test->test").
222-
settings(commonSettings).
223244
settings(commonBootstrappedSettings).
224245
settings(dottyDocSettings)
225246

226247

227248
lazy val `dotty-bot` = project.in(file("bot")).
228-
settings(commonSettings).
249+
settings(commonScala2Settings).
229250
settings(
230251
resourceDirectory in Test := baseDirectory.value / "test" / "resources",
231252

@@ -484,7 +505,7 @@ object Build {
484505
lazy val `dotty-compiler` = project.in(file("compiler")).
485506
dependsOn(`dotty-interfaces`).
486507
dependsOn(`dotty-library`).
487-
settings(commonSettings).
508+
settings(commonNonBootstrappedSettings).
488509
settings(dottyCompilerSettings).
489510
settings(
490511
// Disable scaladoc generation, it's way too slow and we'll replace it
@@ -505,7 +526,6 @@ object Build {
505526

506527
lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).
507528
dependsOn(`dotty-library-bootstrapped`).
508-
settings(commonSettings).
509529
settings(commonBootstrappedSettings).
510530
settings(dottyCompilerSettings).
511531
settings(
@@ -522,7 +542,7 @@ object Build {
522542

523543
/* Contains unit tests for the scripts */
524544
lazy val `dotty-bin-tests` = project.in(file("bin")).
525-
settings(commonSettings).
545+
settings(commonNonBootstrappedSettings).
526546
settings(
527547
publishArtifact := false,
528548
parallelExecution in Test := false,
@@ -540,12 +560,10 @@ object Build {
540560
)
541561

542562
lazy val `dotty-library` = project.in(file("library")).
543-
settings(commonSettings).
544-
settings(dottyLibrarySettings).
545-
settings(publishSettings)
563+
settings(commonNonBootstrappedSettings).
564+
settings(dottyLibrarySettings)
546565

547566
lazy val `dotty-library-bootstrapped` = project.in(file("library")).
548-
settings(commonSettings).
549567
settings(commonBootstrappedSettings).
550568
settings(dottyLibrarySettings)
551569

@@ -590,7 +608,7 @@ object Build {
590608

591609
lazy val `dotty-sbt-bridge` = project.in(file("sbt-bridge")).
592610
dependsOn(`dotty-compiler`).
593-
settings(commonSettings).
611+
settings(commonNonBootstrappedSettings).
594612
settings(dottySbtBridgeSettings).
595613
settings(ScriptedPlugin.scriptedSettings: _*).
596614
settings(
@@ -632,7 +650,6 @@ object DottyInjectedPlugin extends AutoPlugin {
632650

633651
lazy val `dotty-sbt-bridge-bootstrapped` = project.in(file("sbt-bridge")).
634652
dependsOn(`dotty-compiler-bootstrapped`).
635-
settings(commonSettings).
636653
settings(commonBootstrappedSettings).
637654
settings(dottySbtBridgeSettings)
638655

@@ -648,7 +665,7 @@ object DottyInjectedPlugin extends AutoPlugin {
648665
*/
649666
lazy val sjsSandbox = project.in(file("sandbox/scalajs")).
650667
enablePlugins(ScalaJSPlugin).
651-
settings(commonSettings).
668+
settings(commonNonBootstrappedSettings).
652669
settings(
653670
/* Remove the Scala.js compiler plugin for scalac, and enable the
654671
* Scala.js back-end of dotty instead.
@@ -681,7 +698,7 @@ object DottyInjectedPlugin extends AutoPlugin {
681698

682699
lazy val `dotty-bench` = project.in(file("bench")).
683700
dependsOn(`dotty-compiler` % "compile->test").
684-
settings(commonSettings).
701+
settings(commonNonBootstrappedSettings).
685702
settings(
686703
baseDirectory in (Test,run) := (baseDirectory in `dotty-compiler`).value,
687704

@@ -718,39 +735,23 @@ object DottyInjectedPlugin extends AutoPlugin {
718735
}
719736
)
720737

721-
722-
// Dummy scala-library artefact. This is useful because sbt projects
723-
// automatically depend on scalaOrganization.value % "scala-library" % scalaVersion.value
738+
// Depend on dotty-library so that sbt projects using dotty automatically
739+
// depend on the dotty-library
724740
lazy val `scala-library` = project.
725741
dependsOn(`dotty-library`).
726-
settings(commonSettings).
727-
settings(
728-
crossPaths := false
729-
)
742+
settings(commonDummySettings)
730743

731-
// sbt >= 0.13.12 will automatically rewrite transitive dependencies on
732-
// any version in any organization of scala{-library,-compiler,-reflect,p}
733-
// to have organization `scalaOrganization` and version `scalaVersion`
734-
// (see https://github.com/sbt/sbt/pull/2634).
735-
// This means that we need to provide dummy artefacts for these projects,
736-
// otherwise users will get compilation errors if they happen to transitively
737-
// depend on one of these projects.
738744
lazy val `scala-compiler` = project.
739-
settings(commonSettings).
740-
settings(
741-
crossPaths := false
742-
)
745+
settings(commonDummySettings)
743746
lazy val `scala-reflect` = project.
744-
settings(commonSettings).
747+
settings(commonDummySettings).
745748
settings(
746-
crossPaths := false,
747-
libraryDependencies := Seq("org.scala-lang" % "scala-reflect" % scalaVersion.value)
749+
libraryDependencies := Seq("org.scala-lang" % "scala-reflect" % scalacVersion)
748750
)
749751
lazy val scalap = project.
750-
settings(commonSettings).
752+
settings(commonDummySettings).
751753
settings(
752-
crossPaths := false,
753-
libraryDependencies := Seq("org.scala-lang" % "scalap" % scalaVersion.value)
754+
libraryDependencies := Seq("org.scala-lang" % "scalap" % scalacVersion)
754755
)
755756

756757
lazy val publishSettings = Seq(

0 commit comments

Comments
 (0)