@@ -105,17 +105,20 @@ 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- val globdir = cp.replaceAll(" [\\\\ /][^\\\\ /]*$" , " " ) // slash/backslash agnostic
109- val (tailargs, cpstr) = if globdir.nonEmpty && ! cp.contains(classpathSeparator) then
108+ val cpEntries = cp.split(classpathSeparator).toList
109+ val singleEntryClasspath : Boolean = cpEntries.nonEmpty && cpEntries.drop(1 ).isEmpty
110+ val globdir : String = if singleEntryClasspath then cp.replaceAll(" [\\\\ /][^\\\\ /]*$" , " " ) else " " // slash/backslash agnostic
111+ def validGlobbedJar (s : String ): Boolean = s.startsWith(globdir) && ((s.toLowerCase.endsWith(" .jar" ) || s.toLowerCase.endsWith(" .zip" )))
112+ val (tailargs, newEntries) = if singleEntryClasspath && validGlobbedJar(cpEntries.head) then
113+ // reassemble globbed wildcard classpath
110114 // globdir is wildcard directory for globbed jar files, reconstruct the intended classpath
111- val jarfiles = cp :: tail
112- val cpfiles = jarfiles.takeWhile( f => f.startsWith(globdir) && ((f.toLowerCase.endsWith(" .jar" ) || f.endsWith(" .zip" ))) )
113- val tailargs = jarfiles.drop(cpfiles.size)
114- (tailargs, cpfiles.mkString(classpathSeparator))
115+ val cpJars = tail.takeWhile( f => validGlobbedJar(f) )
116+ val remainingArgs = tail.drop(cpJars.size)
117+ (remainingArgs, cpEntries ++ cpJars)
115118 else
116- (tail, cp )
117-
118- process(tailargs, settings.copy(classPath = settings.classPath ++ cpstr.split(classpathSeparator) .filter(_.nonEmpty)))
119+ (tail, cpEntries )
120+
121+ process(tailargs, settings.copy(classPath = settings.classPath ++ newEntries .filter(_.nonEmpty)))
119122
120123 case (" -version" | " --version" ) :: _ =>
121124 settings.copy(
@@ -240,4 +243,22 @@ object MainGenericRunner {
240243 e.foreach(_.printStackTrace())
241244 ! isFailure
242245 }
246+
247+ def display (settings : Settings )= Seq (
248+ s " verbose: ${settings.verbose}" ,
249+ s " classPath: ${settings.classPath.mkString(" \n " ," \n " ," " )}" ,
250+ s " executeMode: ${settings.executeMode}" ,
251+ s " exitCode: ${settings.exitCode}" ,
252+ s " javaArgs: ${settings.javaArgs}" ,
253+ s " scalaArgs: ${settings.scalaArgs}" ,
254+ s " residualArgs: ${settings.residualArgs}" ,
255+ s " possibleEntryPaths: ${settings.possibleEntryPaths}" ,
256+ s " scriptArgs: ${settings.scriptArgs}" ,
257+ s " targetScript: ${settings.targetScript}" ,
258+ s " targetToRun: ${settings.targetToRun}" ,
259+ s " save: ${settings.save}" ,
260+ s " modeShouldBePossibleRun: ${settings.modeShouldBePossibleRun}" ,
261+ s " modeShouldBeRun: ${settings.modeShouldBeRun}" ,
262+ s " compiler: ${settings.compiler}" ,
263+ )
243264}
0 commit comments