No unnecessary warning message with the launch command

when using the proguarded coursier launcher
This commit is contained in:
Alexandre Archambault 2016-02-11 23:58:35 +01:00
parent 6e5bdd80a1
commit 1ef56e9f49
1 changed files with 17 additions and 11 deletions

View File

@ -13,6 +13,7 @@ import coursier.util.Parse
import scala.annotation.tailrec
import scala.language.reflectiveCalls
import scala.util.Try
case class CommonOptions(
@Help("Keep optional dependencies (Maven)")
@ -228,18 +229,23 @@ case class Launch(
val contextLoader = Thread.currentThread().getContextClassLoader
val parentLoader0: ClassLoader = Launch.mainClassLoader(contextLoader)
.flatMap(cl => Option(cl.getParent))
.getOrElse {
if (common.verbose0 >= 0)
Console.err.println(
"Warning: cannot find the main ClassLoader that launched coursier. " +
"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."
)
val parentLoader0: ClassLoader =
if (Try(contextLoader.loadClass("coursier.Launch")).isSuccess)
Launch.mainClassLoader(contextLoader)
.flatMap(cl => Option(cl.getParent))
.getOrElse {
if (common.verbose0 >= 0)
Console.err.println(
"Warning: cannot find the main ClassLoader that launched coursier. " +
"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
}
val (parentLoader, filteredFiles) =
if (isolated.isolated.isEmpty)