@@ -105,7 +105,17 @@ object MainGenericRunner {
105
105
case " -run" :: fqName :: tail =>
106
106
process(tail, settings.withExecuteMode(ExecuteMode .Run ).withTargetToRun(fqName))
107
107
case (" -cp" | " -classpath" | " --class-path" ) :: cp :: tail =>
108
- process(tail, settings.copy(classPath = settings.classPath.appended(cp)))
108
+ val (tailargs, cpstr) = if classpathSeparator != ';' || cp.contains(classpathSeparator) then
109
+ (tail, cp)
110
+ else
111
+ val globdir = cp.replace('\\ ' , '/' ).replaceAll(" /[^/]*$" ," " )
112
+ val jarfiles = cp :: tail
113
+ val cpfiles = jarfiles.takeWhile( f => f.startsWith(globdir) && ((f.toLowerCase.endsWith(" .jar" ) || f.endsWith(" .zip" ))) )
114
+ val tailargs = jarfiles.drop(cpfiles.size)
115
+ (tailargs, cpfiles.mkString(classpathSeparator))
116
+
117
+ process(tailargs, settings.copy(classPath = settings.classPath.appended(cpstr)))
118
+
109
119
case (" -version" | " --version" ) :: _ =>
110
120
settings.copy(
111
121
executeMode = ExecuteMode .Repl ,
@@ -141,6 +151,13 @@ object MainGenericRunner {
141
151
val newSettings = if arg.startsWith(" -" ) then settings else settings.withPossibleEntryPaths(arg).withModeShouldBePossibleRun
142
152
process(tail, newSettings.withResidualArgs(arg))
143
153
154
+ // collect globbed classpath entries
155
+ def collectGlobbedEntries (entries : List [String ]): (List [String ], List [String ]) = {
156
+ val cpfiles = entries.takeWhile( f => (f.toLowerCase.endsWith(" .jar" ) || f.endsWith(" .zip" )) )
157
+ val remainder = entries.drop(cpfiles.size)
158
+ (cpfiles, remainder)
159
+ }
160
+
144
161
def main (args : Array [String ]): Unit =
145
162
val scalaOpts = envOrNone(" SCALA_OPTS" ).toArray.flatMap(_.split(" " ))
146
163
val allArgs = scalaOpts ++ args
@@ -155,7 +172,7 @@ object MainGenericRunner {
155
172
repl.Main .main(properArgs.toArray)
156
173
157
174
case ExecuteMode .PossibleRun =>
158
- val newClasspath = (settings.classPath :+ " ." ).map(File (_).toURI.toURL)
175
+ val newClasspath = (settings.classPath :+ " ." ).flatMap(_.split(classpathSeparator).filter(_.nonEmpty)). map(File (_).toURI.toURL)
159
176
import dotty .tools .runner .RichClassLoader ._
160
177
val newClassLoader = ScalaClassLoader .fromURLsParallelCapable(newClasspath)
161
178
val targetToRun = settings.possibleEntryPaths.to(LazyList ).find { entryPath =>
@@ -177,8 +194,7 @@ object MainGenericRunner {
177
194
cp.filterNot(c => compilerLibs.exists(c.contains))
178
195
else
179
196
cp
180
- val newClasspath = (settings.classPath ++ removeCompiler(scalaClasspath) :+ " ." ).map(File (_).toURI.toURL)
181
-
197
+ val newClasspath = (settings.classPath.flatMap(_.split(classpathSeparator).filter(_.nonEmpty)) ++ removeCompiler(scalaClasspath) :+ " ." ).map(File (_).toURI.toURL)
182
198
val res = ObjectRunner .runAndCatch(newClasspath, settings.targetToRun, settings.residualArgs).flatMap {
183
199
case ex : ClassNotFoundException if ex.getMessage == settings.targetToRun =>
184
200
val file = settings.targetToRun
@@ -192,7 +208,6 @@ object MainGenericRunner {
192
208
errorFn(" " , res)
193
209
case ExecuteMode .Script =>
194
210
val targetScriptPath : String = settings.targetScript.toString.replace('\\ ' , '/' )
195
- System .setProperty(" script.path" , targetScriptPath)
196
211
val properArgs =
197
212
List (" -classpath" , settings.classPath.mkString(classpathSeparator)).filter(Function .const(settings.classPath.nonEmpty))
198
213
++ settings.residualArgs
0 commit comments