From 66467bdec6ac53106c693da2c46f073446a1b2d0 Mon Sep 17 00:00:00 2001 From: Tobias Roeser Date: Thu, 24 Aug 2023 12:45:15 +0200 Subject: [PATCH] Avoid having the mill-launcher jar twice on the classpath (#2702) Pull request: https://github.com/com-lihaoyi/mill/pull/2702 --- runner/src/mill/runner/MillBuildBootstrap.scala | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/runner/src/mill/runner/MillBuildBootstrap.scala b/runner/src/mill/runner/MillBuildBootstrap.scala index b32cc5a6df6..0b14b50a456 100644 --- a/runner/src/mill/runner/MillBuildBootstrap.scala +++ b/runner/src/mill/runner/MillBuildBootstrap.scala @@ -328,7 +328,7 @@ object MillBuildBootstrap { // Copy the current location of the enclosing classes to `mill-launcher.jar` // if it has the wrong file extension, because the Zinc incremental compiler // doesn't recognize classpath entries without the proper file extension - val millLauncherOpt: Option[os.Path] = + val millLauncherOpt: Option[(os.Path, os.Path)] = if ( os.isFile(selfClassLocation) && !Set("zip", "jar", "class").contains(selfClassLocation.ext) @@ -340,9 +340,12 @@ object MillBuildBootstrap { if (!os.exists(millLauncher)) { os.copy(selfClassLocation, millLauncher, createFolders = true, replaceExisting = true) } - Some(millLauncher) + Some((selfClassLocation, millLauncher)) } else None - enclosingClasspath ++ millLauncherOpt + enclosingClasspath + // avoid having the same file twice in the classpath + .filter(f => millLauncherOpt.isEmpty || f != millLauncherOpt.get._1) ++ + millLauncherOpt.map(_._2) } def evaluateWithWatches(