@@ -35,7 +35,14 @@ object DottyPlugin extends AutoPlugin {
35
35
36
36
// get latest nightly version from maven
37
37
def fetchSource (version : String ): (scala.io.BufferedSource , String ) =
38
- try Source .fromURL(s " https://repo1.maven.org/maven2/ch/epfl/lamp/dotty_ $version/maven-metadata.xml " ) -> version
38
+ try {
39
+ val url =
40
+ if (version.startsWith(" 0" ))
41
+ s " https://repo1.maven.org/maven2/ch/epfl/lamp/dotty-compiler_ $version/maven-metadata.xml "
42
+ else
43
+ s " https://repo1.maven.org/maven2/org/scala-lang/scala3-compiler_ $version/maven-metadata.xml "
44
+ Source .fromURL(url) -> version
45
+ }
39
46
catch { case t : java.io.FileNotFoundException =>
40
47
val major :: minor :: Nil = version.split('.' ).toList
41
48
if (minor.toInt <= 0 ) throw t
@@ -92,7 +99,7 @@ object DottyPlugin extends AutoPlugin {
92
99
*/
93
100
def withDottyCompat (scalaVersion : String ): ModuleID = {
94
101
val name = moduleID.name
95
- if (name != " dotty " && name != " dotty -library" && name != " dotty -compiler" )
102
+ if (name != " scala3 " && name != " scala3 -library" && name != " scala3 -compiler" )
96
103
moduleID.crossVersion match {
97
104
case binary : librarymanagement.Binary =>
98
105
val compatVersion =
@@ -167,6 +174,14 @@ object DottyPlugin extends AutoPlugin {
167
174
168
175
// https://github.com/sbt/sbt/issues/3110
169
176
val Def = sbt.Def
177
+
178
+ private def scala3Artefact (version : String , name : String ) =
179
+ if (version.startsWith(" 0." )) s " dotty- $name"
180
+ else if (version.startsWith(" 3." )) s " scala3- $name"
181
+ else throw new RuntimeException (
182
+ s " Cannot construct a Scala 3 artefact name $name for a non-Scala3 " +
183
+ s " scala version ${version}" )
184
+
170
185
override def projectSettings : Seq [Setting [_]] = {
171
186
Seq (
172
187
isDotty := scalaVersion.value.startsWith(" 0." ) || scalaVersion.value.startsWith(" 3." ),
@@ -195,8 +210,10 @@ object DottyPlugin extends AutoPlugin {
195
210
},
196
211
197
212
scalaOrganization := {
198
- if (isDotty .value)
213
+ if (scalaVersion .value.startsWith( " 0. " ) )
199
214
" ch.epfl.lamp"
215
+ else if (scalaVersion.value.startsWith(" 3." ))
216
+ " org.scala-lang"
200
217
else
201
218
scalaOrganization.value
202
219
},
@@ -212,14 +229,14 @@ object DottyPlugin extends AutoPlugin {
212
229
scalaCompilerBridgeBinaryJar := Def .settingDyn {
213
230
if (isDotty.value) Def .task {
214
231
val updateReport = fetchArtifactsOf(
215
- scalaOrganization.value % " dotty- sbt-bridge" % scalaVersion.value,
232
+ scalaOrganization.value % scala3Artefact(scalaVersion.value, " sbt-bridge" ) % scalaVersion.value,
216
233
dependencyResolution.value,
217
234
scalaModuleInfo.value,
218
235
updateConfiguration.value,
219
236
(unresolvedWarningConfiguration in update).value,
220
237
streams.value.log,
221
238
)
222
- Option (getJar(updateReport, scalaOrganization.value, " dotty- sbt-bridge" , scalaVersion.value))
239
+ Option (getJar(updateReport, scalaOrganization.value, scala3Artefact(scalaVersion.value, " sbt-bridge" ) , scalaVersion.value))
223
240
}
224
241
else Def .task {
225
242
None : Option [File ]
@@ -228,10 +245,15 @@ object DottyPlugin extends AutoPlugin {
228
245
229
246
// Needed for RCs publishing
230
247
scalaBinaryVersion := {
231
- if (isDotty.value)
232
- scalaVersion.value.split(" \\ ." ).take(2 ).mkString(" ." )
233
- else
234
- scalaBinaryVersion.value
248
+ scalaVersion.value.split(" [\\ .-]" ).toList match {
249
+ case " 0" :: minor :: _ => s " 0. $minor"
250
+ case " 3" :: minor :: patch :: suffix =>
251
+ s " 3. $minor. $patch" + (suffix match {
252
+ case milestone :: _ => s " - $milestone"
253
+ case Nil => " "
254
+ })
255
+ case _ => scalaBinaryVersion.value
256
+ }
235
257
},
236
258
237
259
// We want:
@@ -326,15 +348,15 @@ object DottyPlugin extends AutoPlugin {
326
348
// ... instead, we'll fetch the compiler and its dependencies ourselves.
327
349
scalaInstance := Def .taskDyn {
328
350
if (isDotty.value)
329
- dottyScalaInstanceTask(" dotty- compiler" )
351
+ dottyScalaInstanceTask(scala3Artefact(scalaVersion.value, " compiler" ) )
330
352
else
331
353
Def .valueStrict { scalaInstance.taskValue }
332
354
}.value,
333
355
334
356
// We need more stuff on the classpath to run the `doc` task.
335
357
scalaInstance in doc := Def .taskDyn {
336
358
if (isDotty.value)
337
- dottyScalaInstanceTask(" dotty- doc" )
359
+ dottyScalaInstanceTask(scala3Artefact(scalaVersion.value, " doc" ) )
338
360
else
339
361
Def .valueStrict { (scalaInstance in doc).taskValue }
340
362
}.value,
@@ -343,8 +365,8 @@ object DottyPlugin extends AutoPlugin {
343
365
libraryDependencies ++= {
344
366
if (isDotty.value && autoScalaLibrary.value) {
345
367
val name =
346
- if (isDottyJS.value) " dotty- library_sjs1"
347
- else " dotty- library"
368
+ if (isDottyJS.value) scala3Artefact(scalaVersion.value, " library_sjs1" )
369
+ else scala3Artefact(scalaVersion.value, " library" )
348
370
Seq (scalaOrganization.value %% name % scalaVersion.value)
349
371
} else
350
372
Seq ()
@@ -479,9 +501,9 @@ object DottyPlugin extends AutoPlugin {
479
501
val scalaLibraryJar = getJar(updateReport,
480
502
" org.scala-lang" , " scala-library" , revision = AllPassFilter )
481
503
val dottyLibraryJar = getJar(updateReport,
482
- scalaOrganization.value, s " dotty- library_ ${scalaBinaryVersion.value}" , scalaVersion.value)
504
+ scalaOrganization.value, scala3Artefact(scalaVersion.value, s " library_ ${scalaBinaryVersion.value}" ) , scalaVersion.value)
483
505
val compilerJar = getJar(updateReport,
484
- scalaOrganization.value, s " dotty- compiler_ ${scalaBinaryVersion.value}" , scalaVersion.value)
506
+ scalaOrganization.value, scala3Artefact(scalaVersion.value, s " compiler_ ${scalaBinaryVersion.value}" ) , scalaVersion.value)
485
507
val allJars =
486
508
getJars(updateReport, AllPassFilter , AllPassFilter , AllPassFilter )
487
509
0 commit comments