Skip to content

Commit 36e27ba

Browse files
committed
Publish a usable bootstrapped dotty
- The bootstrapped dotty artifacts are now named dotty-*_0.1 instead of dotty-*-bootstrapped_2.11, which means they can be used in sbt projects. - The dummy scala{-library,-reflect,-compiler,p} aritfacts are now made to work with the bootstrapped dotty. - Compiling the bootstrapped dotty no longer requires publishing the non-bootstrapped dotty, only dotty-sbt-bridge needs to be published, so you can do: ;dotty-sbt-bridge/publishLocal;dotty-bootstrapped/test
1 parent 19f6e02 commit 36e27ba

File tree

3 files changed

+50
-21
lines changed

3 files changed

+50
-21
lines changed

.drone.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,5 @@ matrix:
4242
CI_PUBLISH: false
4343
- CI_TEST: test
4444
CI_PUBLISH: false
45-
- CI_TEST: ;publishLocal ;dotty-bootstrapped/test
45+
- CI_TEST: ;dotty-sbt-bridge/publishLocal ;dotty-bootstrapped/test
4646
CI_PUBLISH: false

.drone.yml.sig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
eyJhbGciOiJIUzI1NiJ9.IyBBZnRlciB1cGRhdGluZyB0aGlzIGZpbGUsIHlvdSBuZWVkIHRvIHJlLXNpZ24gaXQ6CiMKIyAtIEluc3RhbGwgW2Ryb25lLWNsaV0oaHR0cDovL3JlYWRtZS5kcm9uZS5pby91c2FnZS9nZXR0aW5nLXN0YXJ0ZWQtY2xpLykKIyAtIENvcHkgeW91ciB0b2tlbiBmcm9tICBodHRwOi8vZG90dHktY2kuZXBmbC5jaC9hY2NvdW50IChDbGljayBTSE9XIFRPS0VOKQojIC0gKGV4cG9ydCBEUk9ORV9UT0tFTj15b3VyLXRva2VuOyBleHBvcnQgRFJPTkVfU0VSVkVSPWh0dHA6Ly9kb3R0eS1jaS5lcGZsLmNoOyBkcm9uZSBzaWduIGxhbXBlcGZsL2RvdHR5KQojCiMgUGxlYXNlIG5vdGUgdGhhdCB0aGUgc2lnbmluZyBj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wZGF0ZVNjYWxhTGlicmFyeQogICAgICAtIHNidCAtSi1YbXg0MDk2bSAtSi1YWDpSZXNlcnZlZENvZGVDYWNoZVNpemU9NTEybSAtSi1YWDpNYXhNZXRhc3BhY2VTaXplPTEwMjRtIC1EZG90dHkuZHJvbmUubWVtPTQwOTZtICIke0NJX1RFU1R9IgogICAgd2hlbjoKICAgICAgYnJhbmNoOgogICAgICAgIGV4Y2x1ZGU6IGdoLXBhZ2VzCgogIGRvY3VtZW50YXRpb246CiAgICBpbWFnZTogbGFtcGVwZmwvZG90dHk6MjQtMDQtMjAxNwogICAgcHVsbDogdHJ1ZQogICAgY29tbWFuZHM6CiAgICAgIC0gLi9wcm9qZWN0L3NjcmlwdHMvZ2VuRG9jcyAiJHtDSV9QVUJMSVNIfSIgJEJPVF9QQVNTCiAgICB3aGVuOgogICAgICBicmFuY2g6IG1hc3RlcgoKICBzbGFjazoKICAgIGltYWdlOiBwbHVnaW5zL3NsYWNrCiAgICBjaGFubmVsOiBkb3R0eQogICAgd2hlbjoKICAgICAgYnJhbmNoOiBtYXN0ZXIKICAgICAgc3RhdHVzOiBjaGFuZ2VkCgptYXRyaXg6CiAgaW5jbHVkZToKICAgIC0gQ0lfVEVTVDogZG90dHktYmluLXRlc3RzL3Rlc3QKICAgICAgQ0lfUFVCTElTSDogdHJ1ZQogICAgLSBDSV9URVNUOiBsZWdhY3lUZXN0cwogICAgICBDSV9QVUJMSVNIOiBmYWxzZQogICAgLSBDSV9URVNUOiB0ZXN0CiAgICAgIENJX1BVQkxJU0g6IGZhbHNlCiAgICAtIENJX1RFU1Q6IDtkb3R0eS1zYnQtYnJpZGdlL3B1Ymxpc2hMb2NhbCA7ZG90dHktYm9vdHN0cmFwcGVkL3Rlc3QKICAgICAgQ0lfUFVCTElTSDogZmFsc2UK.oGDqInSbkSMvrUuLat_UdKNbHNTTvv0yK7WGdsnOdMc

project/Build.scala

Lines changed: 48 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -109,15 +109,43 @@ object Build {
109109
version := dottyVersion,
110110
scalaVersion := dottyNonBootstrappedVersion,
111111
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")),
113125

114126
// sbt gets very unhappy if two projects use the same target
115127
target := baseDirectory.value / ".." / "out" / name.value,
116128

117129
// The non-bootstrapped dotty-library is not necessary when bootstrapping dotty
118130
autoScalaLibrary := false,
119131
// ...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+
}
121149
)
122150

123151
// sbt >= 0.13.12 will automatically rewrite transitive dependencies on
@@ -127,7 +155,7 @@ object Build {
127155
// This means that we need to provide dummy artefacts for these projects,
128156
// otherwise users will get compilation errors if they happen to transitively
129157
// depend on one of these projects.
130-
lazy val commonDummySettings = commonNonBootstrappedSettings ++ Seq(
158+
lazy val commonDummySettings = commonBootstrappedSettings ++ Seq(
131159
crossPaths := false,
132160
libraryDependencies := Seq()
133161
)
@@ -147,8 +175,7 @@ object Build {
147175
// this is only necessary for compatibility with sbt which currently hardcodes the "dotty" artifact name
148176
lazy val dotty = project.in(file(".")).
149177
// 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).
152179
dependsOn(`dotty-compiler`).
153180
dependsOn(`dotty-library`).
154181
settings(commonNonBootstrappedSettings).
@@ -159,14 +186,14 @@ object Build {
159186
addCommandAlias("legacyTests", "dotty-compiler/testOnly dotc.tests")
160187
)
161188

162-
// Meta project aggregating all bootstrapped projects
189+
// Same as `dotty` but using bootstrapped projects.
163190
lazy val `dotty-bootstrapped` = project.
164191
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)
170197

171198
lazy val `dotty-interfaces` = project.in(file("interfaces")).
172199
settings(commonScala2Settings). // Java-only project, so this is fine
@@ -341,7 +368,7 @@ object Build {
341368
// get libraries onboard
342369
resolvers += Resolver.typesafeIvyRepo("releases"), // For org.scala-sbt:interface
343370
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",
345372
"com.novocode" % "junit-interface" % "0.11" % "test",
346373
"org.scala-lang" % "scala-reflect" % scalacVersion,
347374
"org.scala-lang" % "scala-library" % scalacVersion % "test"),
@@ -526,13 +553,11 @@ object Build {
526553
)
527554

528555
lazy val `dotty-compiler-bootstrapped` = project.in(file("compiler")).
556+
dependsOn(`dotty-interfaces`).
529557
dependsOn(`dotty-library-bootstrapped`).
530558
settings(commonBootstrappedSettings).
531559
settings(dottyCompilerSettings).
532560
settings(
533-
// Used instead of "dependsOn(`dotty-interfaces`)" because the latter breaks sbt somehow
534-
libraryDependencies += scalaOrganization.value % "dotty-interfaces" % version.value,
535-
536561
packageAll := {
537562
(packageAll in `dotty-compiler`).value ++ Seq(
538563
("dotty-compiler" -> (packageBin in Compile).value.getAbsolutePath),
@@ -564,9 +589,13 @@ object Build {
564589
settings(commonNonBootstrappedSettings).
565590
settings(dottyLibrarySettings)
566591

567-
lazy val `dotty-library-bootstrapped` = project.in(file("library")).
592+
lazy val `dotty-library-bootstrapped`: Project = project.in(file("library")).
568593
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+
)
570599

571600
// until sbt/sbt#2402 is fixed (https://github.com/sbt/sbt/issues/2402)
572601
lazy val cleanSbtBridge = TaskKey[Unit]("cleanSbtBridge", "delete dotty-sbt-bridge cache")
@@ -594,7 +623,7 @@ object Build {
594623
libraryDependencies ++= Seq(
595624
"org.scala-sbt" % "interface" % sbtVersion.value,
596625
"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"
598627
),
599628
// The sources should be published with crossPaths := false since they
600629
// need to be compiled by the project using the bridge.
@@ -739,7 +768,7 @@ object DottyInjectedPlugin extends AutoPlugin {
739768
// Depend on dotty-library so that sbt projects using dotty automatically
740769
// depend on the dotty-library
741770
lazy val `scala-library` = project.
742-
dependsOn(`dotty-library`).
771+
dependsOn(`dotty-library-bootstrapped`).
743772
settings(commonDummySettings)
744773

745774
lazy val `scala-compiler` = project.

0 commit comments

Comments
 (0)