@@ -140,12 +140,10 @@ object NativeImagePlugin extends AutoPlugin {
140140
141141 override lazy val projectSettings : Seq [Def .Setting [_]] = List (
142142 libraryDependencies += " org.scalameta" % " svm-subs" % " 101.0.0" ,
143- target.in(NativeImage ) := target.in(Compile ).value / " native-image" ,
144- target.in(NativeImageTest ) := target.in(Test ).value / " native-image-test" ,
145- target.in(NativeImageInternal ) :=
146- target.in(Compile ).value / " native-image-internal" ,
147- target.in(NativeImageTestInternal ) :=
148- target.in(Test ).value / " native-image-test-internal" ,
143+ NativeImage / target := (Compile / target).value / " native-image" ,
144+ NativeImageTest / target := (Test / target).value / " native-image-test" ,
145+ NativeImageInternal / target := (Compile / target).value / " native-image-internal" ,
146+ NativeImageTestInternal / target := (Test / target).value / " native-image-test-internal" ,
149147 nativeImageReady := {
150148 val s = streams.value
151149
@@ -163,15 +161,15 @@ object NativeImagePlugin extends AutoPlugin {
163161 nativeImageJvm := " graalvm-java11" ,
164162 nativeImageJvmIndex := " cs" ,
165163 nativeImageVersion := " 20.2.0" ,
166- name.in( NativeImage ) := name.value,
167- name.in( NativeImageTest ) := name.in (Test ).value,
168- mainClass.in( NativeImage ) := mainClass.in (Compile ).value,
169- mainClass.in( NativeImageTest ) := mainClass.in (Test ).value,
170- nativeImageOptions := List () ,
164+ NativeImage / name := name.value,
165+ NativeImageTest / name := (Test / name ).value,
166+ NativeImage / mainClass := (Compile / mainClass ).value,
167+ NativeImageTest / mainClass := (Test / mainClass ).value,
168+ nativeImageOptions := List .empty ,
171169 nativeImageTestOptions := nativeImageOptions.value,
172- nativeImageTestRunOptions := List () ,
170+ nativeImageTestRunOptions := List .empty ,
173171 nativeImageCoursier := {
174- val dir = target.in (NativeImageInternal ).value
172+ val dir = (NativeImageInternal / target ).value
175173 val out = copyResource(" coursier" , dir)
176174 if (Properties .isWin) {
177175 copyResource(" coursier.bat" , dir)
@@ -297,7 +295,7 @@ object NativeImagePlugin extends AutoPlugin {
297295 arguments.mkString(" " )
298296 Project
299297 .extract(newState)
300- .runInputTask(run in ( tpr, Compile ) , input, newState)
298+ .runInputTask(tpr / Compile / run , input, newState)
301299 },
302300 nativeImageTestRunAgent := {
303301 val _ = nativeImageTestCommand.value
@@ -313,11 +311,11 @@ object NativeImagePlugin extends AutoPlugin {
313311
314312 val options = (javaOptions in (Test , run)).value ++ Seq (agentOption)
315313
316- val __ = compile.in (Test ).value
317- val main = mainClass.in (NativeImageTest ).value
318- val cp = fullClasspath.in (Test ).value.map(_.data)
319- val manifest = target.in (NativeImageTestInternal ).value / " manifest.jar"
320- manifest.getParentFile() .mkdirs()
314+ val __ = (Test / compile ).value
315+ val main = (NativeImageTest / mainClass ).value
316+ val cp = (Test / fullClasspath ).value.map(_.data)
317+ val manifest = (NativeImageTestInternal / target ).value / " manifest.jar"
318+ manifest.getParentFile.mkdirs()
321319 createManifestJar(manifest, cp)
322320 val nativeClasspath = manifest.absolutePath
323321
@@ -331,7 +329,7 @@ object NativeImagePlugin extends AutoPlugin {
331329 throw new MessageOnlyException (
332330 " no mainClass is specified for tests. " +
333331 " To fix this problem, update build.sbt to include the settings " +
334- " `mainClass.in( Test) := Some(\" com.MainTestClass\" )`"
332+ " `Test / mainClass := Some(\" com.MainTestClass\" )`"
335333 )
336334 )
337335 command ++= nativeImageTestRunOptions.value
@@ -344,12 +342,12 @@ object NativeImagePlugin extends AutoPlugin {
344342 }
345343 },
346344 nativeImageOutput :=
347- target.in (NativeImage ).value / name.in (NativeImage ).value,
345+ (NativeImage / target ).value / (NativeImage / name ).value,
348346 nativeImageTestOutput :=
349- target.in (NativeImageTest ).value / name.in (NativeImageTest ).value,
347+ (NativeImageTest / target ).value / (NativeImageTest / name ).value,
350348 nativeImageCopy := {
351349 val binary = nativeImage.value
352- val out = fileParser(baseDirectory.in (ThisBuild ).value).parsed
350+ val out = fileParser((ThisBuild / baseDirectory ).value).parsed
353351 Files .copy(
354352 binary.toPath(),
355353 out.toPath(),
@@ -384,17 +382,17 @@ object NativeImagePlugin extends AutoPlugin {
384382 }
385383 },
386384 nativeImage := {
387- val _ = compile.in (Compile ).value
388- val main = mainClass.in (NativeImage ).value
385+ val _ = (Compile / compile ).value
386+ val main = (NativeImage / mainClass ).value
389387 val binaryName = nativeImageOutput.value
390- val cp = fullClasspath.in (Compile ).value.map(_.data)
388+ val cp = (Compile / fullClasspath ).value.map(_.data)
391389 // NOTE(olafur): we pass in a manifest jar instead of the full classpath
392390 // for two reasons:
393391 // * large classpaths quickly hit on the "argument list too large"
394392 // error, especially on Windows.
395393 // * we print the full command to the console and the manifest jar makes
396394 // it more readable and easier to copy-paste.
397- val manifest = target.in (NativeImageInternal ).value / " manifest.jar"
395+ val manifest = (NativeImageInternal / target ).value / " manifest.jar"
398396 manifest.getParentFile().mkdirs()
399397 createManifestJar(manifest, cp)
400398 val nativeClasspath = manifest.absolutePath
@@ -410,14 +408,14 @@ object NativeImagePlugin extends AutoPlugin {
410408 throw new MessageOnlyException (
411409 " no mainClass is specified. " +
412410 " To fix this problem, update build.sbt to include the settings " +
413- " `mainClass.in( Compile) := Some(\" com.MainClass\" )`"
411+ " `Compile / mainClass := Some(\" com.MainClass\" )`"
414412 )
415413 )
416414 command += binaryName.absolutePath
417415
418416 // Start native-image linker.
419417 streams.value.log.info(command.mkString(" " ))
420- val cwd = target.in (NativeImage ).value
418+ val cwd = (NativeImage / target ).value
421419 cwd.mkdirs()
422420 val exit = Process (command, cwd = Some (cwd)).!
423421 if (exit != 0 ) {
@@ -431,17 +429,17 @@ object NativeImagePlugin extends AutoPlugin {
431429 binaryName
432430 },
433431 nativeImageTest := {
434- val _ = compile.in (Test ).value
435- val main = mainClass.in (NativeImageTest ).value
432+ val _ = (Test / compile ).value
433+ val main = (NativeImageTest / mainClass ).value
436434 val binaryName = nativeImageTestOutput.value
437- val cp = fullClasspath.in (Test ).value.map(_.data)
435+ val cp = (Test / fullClasspath ).value.map(_.data)
438436 // NOTE(olafur): we pass in a manifest jar instead of the full classpath
439437 // for two reasons:
440438 // * large classpaths quickly hit on the "argument list too large"
441439 // error, especially on Windows.
442440 // * we print the full command to the console and the manifest jar makes
443441 // it more readable and easier to copy-paste.
444- val manifest = target.in (NativeImageTestInternal ).value / " manifest.jar"
442+ val manifest = (NativeImageTestInternal / target ).value / " manifest.jar"
445443 manifest.getParentFile().mkdirs()
446444 createManifestJar(manifest, cp)
447445 val nativeClasspath = manifest.absolutePath
@@ -457,14 +455,14 @@ object NativeImagePlugin extends AutoPlugin {
457455 throw new MessageOnlyException (
458456 " no mainClass is specified for tests. " +
459457 " To fix this problem, update build.sbt to include the settings " +
460- " `mainClass.in( Test) := Some(\" com.MainTestClass\" )`"
458+ " `Test / mainClass := Some(\" com.MainTestClass\" )`"
461459 )
462460 )
463461 command += binaryName.absolutePath
464462
465463 // Start native-image linker.
466464 streams.value.log.info(command.mkString(" " ))
467- val cwd = target.in (NativeImageTest ).value
465+ val cwd = (NativeImageTest / target ).value
468466 cwd.mkdirs()
469467 val exit = Process (command, cwd = Some (cwd)).!
470468 if (exit != 0 ) {
@@ -519,8 +517,7 @@ object NativeImagePlugin extends AutoPlugin {
519517 // this happens if the dependency jar resides on a different drive then the manifest, i.e. C:\Coursier\Cache and D:\myapp\target
520518 // copy dependency next to manifest as fallback
521519 case _ : IllegalArgumentException =>
522- import java .nio .file .Files
523- import java .nio .file .StandardCopyOption
520+ import java .nio .file .{Files , StandardCopyOption }
524521 Files .copy(
525522 dependencyPath,
526523 manifestPath.resolve(path.getName),
@@ -546,15 +543,15 @@ object NativeImagePlugin extends AutoPlugin {
546543
547544 private def alertUser (streams : std.TaskStreams [_], message : String ): Unit = {
548545 streams.log.info(message)
549- if (isCI)
550- return
551- try {
552- if (Properties .isMac) {
553- Process (List (" say" , message)).!
546+ if (! isCI) {
547+ try {
548+ if (Properties .isMac) {
549+ Process (List (" say" , message)).!
550+ }
551+ // NOTE(olafur): feel free to add support for Linux/Windows.
552+ } catch {
553+ case NonFatal (_) =>
554554 }
555- // NOTE(olafur): feel free to add support for Linux/Windows.
556- } catch {
557- case NonFatal (_) =>
558555 }
559556 }
560557}
0 commit comments