@@ -109,15 +109,43 @@ object Build {
109
109
version := dottyVersion,
110
110
scalaVersion := dottyNonBootstrappedVersion,
111
111
scalaOrganization := dottyOrganization,
112
- scalaBinaryVersion := " 2.11" ,
112
+ scalaBinaryVersion := " 0.1" ,
113
+
114
+ // Use the same name as the non-bootstrapped projects for the artifacts
115
+ moduleName ~= { _.stripSuffix(" -bootstrapped" ) },
116
+
117
+ // Prevent sbt from setting the Scala bootclasspath, otherwise it will
118
+ // contain `scalaInstance.value.libraryJar` which in our case is the
119
+ // non-bootstrapped dotty-library that will then take priority over
120
+ // the bootstrapped dotty-library on the classpath or sourcepath.
121
+ classpathOptions ~= (_.copy(autoBoot = false )),
122
+ // We still need a Scala bootclasspath equal to the JVM bootclasspath,
123
+ // otherwise sbt 0.13 incremental compilation breaks (https://github.com/sbt/sbt/issues/3142)
124
+ scalacOptions ++= Seq (" -bootclasspath" , sys.props(" sun.boot.class.path" )),
113
125
114
126
// sbt gets very unhappy if two projects use the same target
115
127
target := baseDirectory.value / " .." / " out" / name.value,
116
128
117
129
// The non-bootstrapped dotty-library is not necessary when bootstrapping dotty
118
130
autoScalaLibrary := false ,
119
131
// ...but scala-library is
120
- libraryDependencies += " org.scala-lang" % " scala-library" % scalacVersion
132
+ libraryDependencies += " org.scala-lang" % " scala-library" % scalacVersion,
133
+
134
+ // Compile using the non-bootstrapped and non-published dotty
135
+ managedScalaInstance := false ,
136
+ scalaInstance := {
137
+ val libraryJar = (packageBin in (`dotty-library`, Compile )).value
138
+ val compilerJar = (packageBin in (`dotty-compiler`, Compile )).value
139
+
140
+ // All compiler dependencies except the library
141
+ val otherDependencies = (dependencyClasspath in (`dotty-compiler`, Compile )).value
142
+ .filterNot(_.get(artifact.key).exists(_.name == " dotty-library" ))
143
+ .map(_.data)
144
+
145
+ // This ScalaInstance#apply overload is deprecated in sbt 0.13, but the non-deprecated
146
+ // constructor in sbt 1.0 does not exist in sbt 0.13
147
+ ScalaInstance (scalaVersion.value, libraryJar, compilerJar, otherDependencies : _* )(state.value.classLoaderCache.apply)
148
+ }
121
149
)
122
150
123
151
// sbt >= 0.13.12 will automatically rewrite transitive dependencies on
@@ -127,7 +155,7 @@ object Build {
127
155
// This means that we need to provide dummy artefacts for these projects,
128
156
// otherwise users will get compilation errors if they happen to transitively
129
157
// depend on one of these projects.
130
- lazy val commonDummySettings = commonNonBootstrappedSettings ++ Seq (
158
+ lazy val commonDummySettings = commonBootstrappedSettings ++ Seq (
131
159
crossPaths := false ,
132
160
libraryDependencies := Seq ()
133
161
)
@@ -147,8 +175,7 @@ object Build {
147
175
// this is only necessary for compatibility with sbt which currently hardcodes the "dotty" artifact name
148
176
lazy val dotty = project.in(file(" ." )).
149
177
// FIXME: we do not aggregate `bin` because its tests delete jars, thus breaking other tests
150
- aggregate(`dotty-interfaces`, `dotty-library`, `dotty-compiler`, `dotty-doc`, dottySbtBridgeRef,
151
- `scala-library`, `scala-compiler`, `scala-reflect`, scalap).
178
+ aggregate(`dotty-interfaces`, `dotty-library`, `dotty-compiler`, `dotty-doc`, dottySbtBridgeRef).
152
179
dependsOn(`dotty-compiler`).
153
180
dependsOn(`dotty-library`).
154
181
settings(commonNonBootstrappedSettings).
@@ -159,14 +186,14 @@ object Build {
159
186
addCommandAlias(" legacyTests" , " dotty-compiler/testOnly dotc.tests" )
160
187
)
161
188
162
- // Meta project aggregating all bootstrapped projects
189
+ // Same as `dotty` but using bootstrapped projects.
163
190
lazy val `dotty-bootstrapped` = project.
164
191
aggregate(`dotty-library-bootstrapped`, `dotty-compiler-bootstrapped`, `dotty-doc-bootstrapped`,
165
- dottySbtBridgeBootstrappedRef).
166
- settings(commonBootstrappedSettings ).
167
- settings(
168
- publishArtifact := false
169
- )
192
+ dottySbtBridgeBootstrappedRef,
193
+ `scala-library`, `scala-compiler`, `scala-reflect`, scalap ).
194
+ dependsOn(`dotty-compiler-bootstrapped`).
195
+ dependsOn(`dotty-library-bootstrapped`).
196
+ settings(commonBootstrappedSettings )
170
197
171
198
lazy val `dotty-interfaces` = project.in(file(" interfaces" )).
172
199
settings(commonScala2Settings). // Java-only project, so this is fine
@@ -341,7 +368,7 @@ object Build {
341
368
// get libraries onboard
342
369
resolvers += Resolver .typesafeIvyRepo(" releases" ), // For org.scala-sbt:interface
343
370
libraryDependencies ++= Seq (" org.scala-sbt" % " interface" % sbtVersion.value,
344
- " org.scala-lang.modules" %% " scala-xml " % " 1.0.1" ,
371
+ " org.scala-lang.modules" % " scala-xml_2.11 " % " 1.0.1" ,
345
372
" com.novocode" % " junit-interface" % " 0.11" % " test" ,
346
373
" org.scala-lang" % " scala-reflect" % scalacVersion,
347
374
" org.scala-lang" % " scala-library" % scalacVersion % " test" ),
@@ -526,13 +553,11 @@ object Build {
526
553
)
527
554
528
555
lazy val `dotty-compiler-bootstrapped` = project.in(file(" compiler" )).
556
+ dependsOn(`dotty-interfaces`).
529
557
dependsOn(`dotty-library-bootstrapped`).
530
558
settings(commonBootstrappedSettings).
531
559
settings(dottyCompilerSettings).
532
560
settings(
533
- // Used instead of "dependsOn(`dotty-interfaces`)" because the latter breaks sbt somehow
534
- libraryDependencies += scalaOrganization.value % " dotty-interfaces" % version.value,
535
-
536
561
packageAll := {
537
562
(packageAll in `dotty-compiler`).value ++ Seq (
538
563
(" dotty-compiler" -> (packageBin in Compile ).value.getAbsolutePath),
@@ -564,9 +589,13 @@ object Build {
564
589
settings(commonNonBootstrappedSettings).
565
590
settings(dottyLibrarySettings)
566
591
567
- lazy val `dotty-library-bootstrapped` = project.in(file(" library" )).
592
+ lazy val `dotty-library-bootstrapped` : Project = project.in(file(" library" )).
568
593
settings(commonBootstrappedSettings).
569
- settings(dottyLibrarySettings)
594
+ settings(dottyLibrarySettings).
595
+ settings(
596
+ // Needed so that the library sources are visible when `dotty.tools.dotc.core.Definitions#init` is called.
597
+ scalacOptions in Compile ++= Seq (" -sourcepath" , (scalaSource in Compile ).value.getAbsolutePath)
598
+ )
570
599
571
600
// until sbt/sbt#2402 is fixed (https://github.com/sbt/sbt/issues/2402)
572
601
lazy val cleanSbtBridge = TaskKey [Unit ](" cleanSbtBridge" , " delete dotty-sbt-bridge cache" )
@@ -594,7 +623,7 @@ object Build {
594
623
libraryDependencies ++= Seq (
595
624
" org.scala-sbt" % " interface" % sbtVersion.value,
596
625
" org.scala-sbt" % " api" % sbtVersion.value % " test" ,
597
- " org.specs2" %% " specs2 " % " 2.3.11" % " test"
626
+ " org.specs2" % " specs2_2.11 " % " 2.3.11" % " test"
598
627
),
599
628
// The sources should be published with crossPaths := false since they
600
629
// need to be compiled by the project using the bridge.
@@ -739,7 +768,7 @@ object DottyInjectedPlugin extends AutoPlugin {
739
768
// Depend on dotty-library so that sbt projects using dotty automatically
740
769
// depend on the dotty-library
741
770
lazy val `scala-library` = project.
742
- dependsOn(`dotty-library`).
771
+ dependsOn(`dotty-library-bootstrapped `).
743
772
settings(commonDummySettings)
744
773
745
774
lazy val `scala-compiler` = project.
0 commit comments