@@ -105,7 +105,17 @@ object MainGenericRunner {
105105 case " -run" :: fqName :: tail =>
106106 process(tail, settings.withExecuteMode(ExecuteMode .Run ).withTargetToRun(fqName))
107107 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+
109119 case (" -version" | " --version" ) :: _ =>
110120 settings.copy(
111121 executeMode = ExecuteMode .Repl ,
@@ -141,6 +151,13 @@ object MainGenericRunner {
141151 val newSettings = if arg.startsWith(" -" ) then settings else settings.withPossibleEntryPaths(arg).withModeShouldBePossibleRun
142152 process(tail, newSettings.withResidualArgs(arg))
143153
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+
144161 def main (args : Array [String ]): Unit =
145162 val scalaOpts = envOrNone(" SCALA_OPTS" ).toArray.flatMap(_.split(" " ))
146163 val allArgs = scalaOpts ++ args
@@ -155,7 +172,7 @@ object MainGenericRunner {
155172 repl.Main .main(properArgs.toArray)
156173
157174 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)
159176 import dotty .tools .runner .RichClassLoader ._
160177 val newClassLoader = ScalaClassLoader .fromURLsParallelCapable(newClasspath)
161178 val targetToRun = settings.possibleEntryPaths.to(LazyList ).find { entryPath =>
@@ -177,8 +194,7 @@ object MainGenericRunner {
177194 cp.filterNot(c => compilerLibs.exists(c.contains))
178195 else
179196 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)
182198 val res = ObjectRunner .runAndCatch(newClasspath, settings.targetToRun, settings.residualArgs).flatMap {
183199 case ex : ClassNotFoundException if ex.getMessage == settings.targetToRun =>
184200 val file = settings.targetToRun
@@ -192,7 +208,6 @@ object MainGenericRunner {
192208 errorFn(" " , res)
193209 case ExecuteMode .Script =>
194210 val targetScriptPath : String = settings.targetScript.toString.replace('\\ ' , '/' )
195- System .setProperty(" script.path" , targetScriptPath)
196211 val properArgs =
197212 List (" -classpath" , settings.classPath.mkString(classpathSeparator)).filter(Function .const(settings.classPath.nonEmpty))
198213 ++ settings.residualArgs
0 commit comments