sbt.internal.ClassLoaderWarmup.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of main_2.12 Show documentation
Show all versions of main_2.12 Show documentation
sbt is an interactive build tool
The newest version!
/*
* sbt
* Copyright 2023, Scala center
* Copyright 2011 - 2022, Lightbend, Inc.
* Copyright 2008 - 2010, Mark Harrah
* Licensed under Apache License 2.0 (see LICENSE)
*/
package sbt.internal
import java.util.concurrent.{ ExecutorService, Executors }
import sbt.plugins.{ CorePlugin, IvyPlugin, JvmPlugin }
private[internal] object ClassLoaderWarmup {
def warmup(): Unit = {
if (Runtime.getRuntime.availableProcessors > 1) {
val executorService: ExecutorService =
Executors.newFixedThreadPool(Runtime.getRuntime.availableProcessors - 1)
def submit[R](f: => R): Unit = {
executorService.submit(new Runnable {
override def run(): Unit = { f; () }
})
()
}
submit(Class.forName("sbt.internal.parser.SbtParserInit").getConstructor().newInstance())
submit(CorePlugin.projectSettings)
submit(IvyPlugin.projectSettings)
submit(JvmPlugin.projectSettings)
submit(() => {
try {
val clazz = Class.forName("scala.reflect.runtime.package$")
clazz.getMethod("universe").invoke(clazz.getField("MODULE$").get(null))
} catch {
case _: Exception =>
}
executorService.shutdown()
})
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy