File tree Expand file tree Collapse file tree 4 files changed +60
-2
lines changed
cli/src/main/scala/scala/cli
integration/src/test/scala/scala/cli/integration Expand file tree Collapse file tree 4 files changed +60
-2
lines changed Original file line number Diff line number Diff line change @@ -16,6 +16,7 @@ import scala.cli.javaLauncher.JavaLauncherCli
16
16
import scala .cli .launcher .{LauncherCli , LauncherOptions , PowerOptions }
17
17
import scala .cli .publish .BouncycastleSignerMaker
18
18
import scala .cli .util .ConfigDbUtils
19
+ import scala .collection .mutable .ListBuffer
19
20
import scala .util .Properties
20
21
21
22
object ScalaCli {
@@ -53,7 +54,8 @@ object ScalaCli {
53
54
private def isGraalvmNativeImage : Boolean =
54
55
sys.props.contains(" org.graalvm.nativeimage.imagecode" )
55
56
56
- private var defaultScalaVersion : Option [String ] = None
57
+ private var defaultScalaVersion : Option [String ] = None
58
+ val launcherPredefinedRepositories : ListBuffer [String ] = ListBuffer .empty
57
59
58
60
def getDefaultScalaVersion : String = defaultScalaVersion.getOrElse(Constants .defaultScalaVersion)
59
61
@@ -243,6 +245,8 @@ object ScalaCli {
243
245
case None =>
244
246
if launcherOpts.cliUserScalaVersion.nonEmpty then
245
247
defaultScalaVersion = launcherOpts.cliUserScalaVersion
248
+ if launcherOpts.cliPredefinedRepository.nonEmpty then
249
+ launcherPredefinedRepositories.addAll(launcherOpts.cliPredefinedRepository)
246
250
if launcherOpts.powerOptions.power then
247
251
isSipScala = false
248
252
args0.toArray
Original file line number Diff line number Diff line change @@ -394,7 +394,10 @@ final case class SharedOptions(
394
394
extraClassPath = extraRegularJarsAndClasspath,
395
395
extraCompileOnlyJars = extraCompileOnlyClassPath,
396
396
extraSourceJars = extraSourceJars.extractedClassPath ++ assumedSourceJars,
397
- extraRepositories = dependencies.repository.map(_.trim).filter(_.nonEmpty),
397
+ extraRepositories =
398
+ (dependencies.repository ++ ScalaCli .launcherPredefinedRepositories).map(_.trim).filter(
399
+ _.nonEmpty
400
+ ),
398
401
extraDependencies = ShadowingSeq .from(
399
402
SharedOptions .parseDependencies(
400
403
dependencies.dependency.map(Positioned .none),
Original file line number Diff line number Diff line change @@ -28,6 +28,15 @@ final case class LauncherOptions(
28
28
@ Tag (tags.implementation)
29
29
@ Name (" cliDefaultScalaVersion" )
30
30
cliUserScalaVersion : Option [String ] = None ,
31
+ @ Group (HelpGroup .Launcher .toString)
32
+ @ HelpMessage (" " )
33
+ @ Hidden
34
+ @ Tag (tags.implementation)
35
+ @ Name (" r" )
36
+ @ Name (" repo" )
37
+ @ Name (" repository" )
38
+ @ Name (" predefinedRepository" )
39
+ cliPredefinedRepository : List [String ] = Nil ,
31
40
@ Recurse
32
41
powerOptions : PowerOptions = PowerOptions ()
33
42
)
Original file line number Diff line number Diff line change @@ -593,4 +593,46 @@ class SipScalaTests extends ScalaCliSuite {
593
593
expect(r.err.trim().contains(" already specified" ))
594
594
}
595
595
}
596
+
597
+ for {
598
+ withBloop <- Seq (true , false )
599
+ withBloopString = if (withBloop) " with Bloop" else " with --server=false"
600
+ }
601
+ test(
602
+ s " default Scala version coming straight from a predefined local repository $withBloopString"
603
+ ) {
604
+ TestInputs (
605
+ os.rel / " simple.sc" -> " println(dotty.tools.dotc.config.Properties.simpleVersionString)"
606
+ )
607
+ .fromRoot { root =>
608
+ val localRepoPath = root / " local-repo"
609
+ val sv = " 3.4.1-RC1"
610
+ val csRes = os.proc(
611
+ TestUtil .cs,
612
+ " fetch" ,
613
+ " --cache" ,
614
+ localRepoPath,
615
+ s " org.scala-lang:scala3-compiler_3: $sv"
616
+ )
617
+ .call(cwd = root)
618
+ expect(csRes.exitCode == 0 )
619
+ val buildServerOptions =
620
+ if (withBloop) Nil else Seq (" --server=false" )
621
+ val r = os.proc(
622
+ TestUtil .cli,
623
+ " --cli-default-scala-version" ,
624
+ sv,
625
+ " --predefined-repository" ,
626
+ (localRepoPath / " https" / " repo1.maven.org" / " maven2" ).toNIO.toUri.toASCIIString,
627
+ " run" ,
628
+ " simple.sc" ,
629
+ " --with-compiler" ,
630
+ " --offline" ,
631
+ " --power" ,
632
+ buildServerOptions
633
+ )
634
+ .call(cwd = root)
635
+ expect(r.out.trim() == sv)
636
+ }
637
+ }
596
638
}
You can’t perform that action at this time.
0 commit comments