diff options
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/mill/util/ClassLoader.scala | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/core/src/mill/util/ClassLoader.scala b/core/src/mill/util/ClassLoader.scala new file mode 100644 index 00000000..a1b42158 --- /dev/null +++ b/core/src/mill/util/ClassLoader.scala @@ -0,0 +1,19 @@ +package mill.util + +import java.net.{URL, URLClassLoader} + +import io.github.retronym.java9rtexport.Export + +object ClassLoader { + def create(urls: Seq[URL], parent: java.lang.ClassLoader): URLClassLoader = { + val cl = new URLClassLoader(urls.toArray, parent) + if (!ammonite.util.Util.java9OrAbove) return cl + try { + cl.loadClass("javax.script.ScriptEngineManager") + cl + } catch { + case _: ClassNotFoundException => + new URLClassLoader((urls ++ Some(Export.export().toURI.toURL)).toArray, parent) + } + } +} |