Isolate coursier from the launched app even if coursier is proguarded

Confuses scala.util.Properties.versionNumberString from the launched app
in particular - apps launched with scala 2.11.7 end up with this method
returning 2.11.8...
This commit is contained in:
Alexandre Archambault 2016-04-22 16:06:51 +02:00
parent d2984cc51b
commit 7266e8c025
No known key found for this signature in database
GPG Key ID: 14640A6839C263A9
1 changed files with 14 additions and 16 deletions

View File

@ -85,22 +85,20 @@ case class Launch(
val contextLoader = Thread.currentThread().getContextClassLoader
val parentLoader0: ClassLoader =
if (Try(contextLoader.loadClass("coursier.cli.Launch")).isSuccess)
Launch.mainClassLoader(contextLoader)
.flatMap(cl => Option(cl.getParent))
.getOrElse {
if (options.common.verbosityLevel >= 0)
Console.err.println(
"Warning: cannot find the main ClassLoader that launched coursier.\n" +
"Was coursier launched by its main launcher? " +
"The ClassLoader of the application that is about to be launched will be intertwined " +
"with the one of coursier, which may be a problem if their dependencies conflict."
)
contextLoader
}
else
// proguarded -> no risk of conflicts, no need to find a specific ClassLoader
contextLoader
Launch.mainClassLoader(contextLoader)
.flatMap(cl => Option(cl.getParent))
.getOrElse {
// proguarded -> no risk of conflicts, no absolute need to find a specific ClassLoader
val isProguarded = Try(contextLoader.loadClass("coursier.cli.Launch")).isFailure
if (!isProguarded && options.common.verbosityLevel >= 0)
Console.err.println(
"Warning: cannot find the main ClassLoader that launched coursier.\n" +
"Was coursier launched by its main launcher? " +
"The ClassLoader of the application that is about to be launched will be intertwined " +
"with the one of coursier, which may be a problem if their dependencies conflict."
)
contextLoader
}
val (parentLoader, filteredFiles) =
if (options.isolated.isolated.isEmpty)