@@ -81,6 +81,9 @@ case class Settings(
81
81
def withSave : Settings =
82
82
this .copy(save = true )
83
83
84
+ def noSave : Settings =
85
+ this .copy(save = false )
86
+
84
87
def withModeShouldBePossibleRun : Settings =
85
88
this .copy(modeShouldBePossibleRun = true )
86
89
@@ -135,6 +138,8 @@ object MainGenericRunner {
135
138
)
136
139
case " -save" :: tail =>
137
140
process(tail, settings.withSave)
141
+ case " -nosave" :: tail =>
142
+ process(tail, settings.noSave)
138
143
case " -with-compiler" :: tail =>
139
144
process(tail, settings.withCompiler)
140
145
case (o @ javaOption(striped)) :: tail =>
@@ -207,18 +212,20 @@ object MainGenericRunner {
207
212
case ExecuteMode .Script =>
208
213
val targetScript = Paths .get(settings.targetScript).toFile
209
214
val targetJar = settings.targetScript.replaceAll(" [.][^\\ /]*$" , " " )+ " .jar"
210
- val precompiledJar = Paths .get (targetJar).toFile
215
+ val precompiledJar = File (targetJar)
211
216
val mainClass = if ! precompiledJar.isFile then " " else Jar (targetJar).mainClass.getOrElse(" " )
212
- val jarIsValid = mainClass.nonEmpty && precompiledJar.lastModified >= targetScript.lastModified
217
+ val jarIsValid = mainClass.nonEmpty && precompiledJar.lastModified >= targetScript.lastModified && settings.save
213
218
if jarIsValid then
214
219
// precompiledJar exists, is newer than targetScript, and manifest defines a mainClass
215
220
sys.props(" script.path" ) = targetScript.toPath.toAbsolutePath.normalize.toString
216
221
val scalaClasspath = ClasspathFromClassloader (Thread .currentThread().getContextClassLoader).split(classpathSeparator)
217
222
val newClasspath = (settings.classPath.flatMap(_.split(classpathSeparator).filter(_.nonEmpty)) ++ removeCompiler(scalaClasspath) :+ " ." ).map(File (_).toURI.toURL)
218
- if mainClass.nonEmpty then
223
+ val res = if mainClass.nonEmpty then
219
224
ObjectRunner .runAndCatch(newClasspath :+ File (targetJar).toURI.toURL, mainClass, settings.scriptArgs)
220
225
else
221
226
Some (IllegalArgumentException (s " No main class defined in manifest in jar: $precompiledJar" ))
227
+ errorFn(" " , res)
228
+
222
229
else
223
230
val properArgs =
224
231
List (" -classpath" , settings.classPath.mkString(classpathSeparator)).filter(Function .const(settings.classPath.nonEmpty))
0 commit comments