@@ -33,6 +33,7 @@ case class Settings(
33
33
targetScript : String = " " ,
34
34
save : Boolean = false ,
35
35
modeShouldBeRun : Boolean = false ,
36
+ compiler : Boolean = false ,
36
37
) {
37
38
def withExecuteMode (em : ExecuteMode ): Settings = this .executeMode match
38
39
case ExecuteMode .Guess =>
@@ -67,6 +68,9 @@ case class Settings(
67
68
68
69
def withModeShouldBeRun : Settings =
69
70
this .copy(modeShouldBeRun = true )
71
+
72
+ def withCompiler : Settings =
73
+ this .copy(compiler = true )
70
74
}
71
75
72
76
object MainGenericRunner {
@@ -99,6 +103,8 @@ object MainGenericRunner {
99
103
)
100
104
case " -save" :: tail =>
101
105
process(tail, settings.withSave)
106
+ case " -with-compiler" :: tail =>
107
+ process(tail, settings.withCompiler)
102
108
case (o @ javaOption(striped)) :: tail =>
103
109
process(tail, settings.withJavaArgs(striped).withScalaArgs(o))
104
110
case (o @ scalaOption(_* )) :: tail =>
@@ -130,7 +136,15 @@ object MainGenericRunner {
130
136
repl.Main .main(properArgs.toArray)
131
137
case ExecuteMode .Run =>
132
138
val scalaClasspath = ClasspathFromClassloader (Thread .currentThread().getContextClassLoader).split(classpathSeparator)
133
- val newClasspath = (settings.classPath ++ scalaClasspath :+ " ." ).map(File (_).toURI.toURL)
139
+
140
+ def removeCompiler (cp : Array [String ]) =
141
+ if (! settings.compiler) then // Let's remove compiler from the classpath
142
+ val compilerLibs = Seq (" scala3-compiler" , " scala3-interfaces" , " tasty-core" , " scala-asm" , " scala3-staging" , " scala3-tasty-inspector" )
143
+ cp.filterNot(c => compilerLibs.exists(c.contains))
144
+ else
145
+ cp
146
+ val newClasspath = (settings.classPath ++ removeCompiler(scalaClasspath) :+ " ." ).map(File (_).toURI.toURL)
147
+
134
148
val res = ObjectRunner .runAndCatch(newClasspath, settings.residualArgs.head, settings.residualArgs.drop(1 )).flatMap {
135
149
case ex : ClassNotFoundException if ex.getMessage == settings.residualArgs.head =>
136
150
val file = settings.residualArgs.head
0 commit comments