@@ -35,7 +35,7 @@ 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 Source .fromURL(s " https://repo1.maven.org/maven2/org/scala-lang/scala3_ $version/maven-metadata.xml " ) -> version
39
39
catch { case t : java.io.FileNotFoundException =>
40
40
val major :: minor :: Nil = version.split('.' ).toList
41
41
if (minor.toInt <= 0 ) throw t
@@ -92,7 +92,7 @@ object DottyPlugin extends AutoPlugin {
92
92
*/
93
93
def withDottyCompat (scalaVersion : String ): ModuleID = {
94
94
val name = moduleID.name
95
- if (name != " dotty " && name != " dotty -library" && name != " dotty -compiler" )
95
+ if (name != " scala3 " && name != " scala3 -library" && name != " scala3 -compiler" )
96
96
moduleID.crossVersion match {
97
97
case binary : librarymanagement.Binary =>
98
98
val compatVersion =
@@ -167,6 +167,14 @@ object DottyPlugin extends AutoPlugin {
167
167
168
168
// https://github.com/sbt/sbt/issues/3110
169
169
val Def = sbt.Def
170
+
171
+ private def scala3Artefact (version : String , name : String ) =
172
+ if (version.startsWith(" 0." )) s " dotty- $name"
173
+ else if (version.startsWith(" 3." )) s " scala3- $name"
174
+ else throw new RuntimeException (
175
+ s " Cannot construct a Scala 3 artefact name $name for a non-Scala3 " +
176
+ s " scala version ${version}" )
177
+
170
178
override def projectSettings : Seq [Setting [_]] = {
171
179
Seq (
172
180
isDotty := scalaVersion.value.startsWith(" 0." ) || scalaVersion.value.startsWith(" 3." ),
@@ -195,8 +203,10 @@ object DottyPlugin extends AutoPlugin {
195
203
},
196
204
197
205
scalaOrganization := {
198
- if (isDotty .value)
206
+ if (scalaVersion .value.startsWith( " 0. " ) )
199
207
" ch.epfl.lamp"
208
+ else if (scalaVersion.value.startsWith(" 3." ))
209
+ " org.scala-lang"
200
210
else
201
211
scalaOrganization.value
202
212
},
@@ -212,14 +222,14 @@ object DottyPlugin extends AutoPlugin {
212
222
scalaCompilerBridgeBinaryJar := Def .settingDyn {
213
223
if (isDotty.value) Def .task {
214
224
val updateReport = fetchArtifactsOf(
215
- scalaOrganization.value % " dotty- sbt-bridge" % scalaVersion.value,
225
+ scalaOrganization.value % scala3Artefact(scalaVersion.value, " sbt-bridge" ) % scalaVersion.value,
216
226
dependencyResolution.value,
217
227
scalaModuleInfo.value,
218
228
updateConfiguration.value,
219
229
(unresolvedWarningConfiguration in update).value,
220
230
streams.value.log,
221
231
)
222
- Option (getJar(updateReport, scalaOrganization.value, " dotty- sbt-bridge" , scalaVersion.value))
232
+ Option (getJar(updateReport, scalaOrganization.value, scala3Artefact(scalaVersion.value, " sbt-bridge" ) , scalaVersion.value))
223
233
}
224
234
else Def .task {
225
235
None : Option [File ]
@@ -228,7 +238,7 @@ object DottyPlugin extends AutoPlugin {
228
238
229
239
// Needed for RCs publishing
230
240
scalaBinaryVersion := {
231
- if (isDotty .value)
241
+ if (scalaVersion .value.startsWith( " 0. " ) )
232
242
scalaVersion.value.split(" \\ ." ).take(2 ).mkString(" ." )
233
243
else
234
244
scalaBinaryVersion.value
@@ -326,15 +336,15 @@ object DottyPlugin extends AutoPlugin {
326
336
// ... instead, we'll fetch the compiler and its dependencies ourselves.
327
337
scalaInstance := Def .taskDyn {
328
338
if (isDotty.value)
329
- dottyScalaInstanceTask(" dotty- compiler" )
339
+ dottyScalaInstanceTask(scala3Artefact(scalaVersion.value, " compiler" ) )
330
340
else
331
341
Def .valueStrict { scalaInstance.taskValue }
332
342
}.value,
333
343
334
344
// We need more stuff on the classpath to run the `doc` task.
335
345
scalaInstance in doc := Def .taskDyn {
336
346
if (isDotty.value)
337
- dottyScalaInstanceTask(" dotty- doc" )
347
+ dottyScalaInstanceTask(scala3Artefact(scalaVersion.value, " doc" ) )
338
348
else
339
349
Def .valueStrict { (scalaInstance in doc).taskValue }
340
350
}.value,
@@ -343,8 +353,8 @@ object DottyPlugin extends AutoPlugin {
343
353
libraryDependencies ++= {
344
354
if (isDotty.value && autoScalaLibrary.value) {
345
355
val name =
346
- if (isDottyJS.value) " dotty- library_sjs1"
347
- else " dotty- library"
356
+ if (isDottyJS.value) scala3Artefact(scalaVersion.value, " library_sjs1" )
357
+ else scala3Artefact(scalaVersion.value, " library" )
348
358
Seq (scalaOrganization.value %% name % scalaVersion.value)
349
359
} else
350
360
Seq ()
@@ -479,9 +489,9 @@ object DottyPlugin extends AutoPlugin {
479
489
val scalaLibraryJar = getJar(updateReport,
480
490
" org.scala-lang" , " scala-library" , revision = AllPassFilter )
481
491
val dottyLibraryJar = getJar(updateReport,
482
- scalaOrganization.value, s " dotty- library_ ${scalaBinaryVersion.value}" , scalaVersion.value)
492
+ scalaOrganization.value, scala3Artefact(scalaVersion.value, s " library_ ${scalaBinaryVersion.value}" ) , scalaVersion.value)
483
493
val compilerJar = getJar(updateReport,
484
- scalaOrganization.value, s " dotty- compiler_ ${scalaBinaryVersion.value}" , scalaVersion.value)
494
+ scalaOrganization.value, scala3Artefact(scalaVersion.value, s " compiler_ ${scalaBinaryVersion.value}" ) , scalaVersion.value)
485
495
val allJars =
486
496
getJars(updateReport, AllPassFilter , AllPassFilter , AllPassFilter )
487
497
0 commit comments