Skip to content

Commit 7f41532

Browse files
committed
Make classLoader a property of WebJar
1 parent c588c94 commit 7f41532

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

build.scala

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -472,12 +472,11 @@ object KaTeX {
472472

473473
// Provides access to resources of a bundled WebJar.
474474
class WebJar(artifactId: String) {
475+
private val classLoader = classOf[WebJar].getClassLoader
476+
475477
private val version: String =
476478
val propsPath = s"META-INF/maven/org.webjars.npm/$artifactId/pom.properties"
477-
val stream = Thread
478-
.currentThread()
479-
.getContextClassLoader
480-
.getResourceAsStream(propsPath)
479+
val stream = classLoader.getResourceAsStream(propsPath)
481480
if stream == null then
482481
throw IllegalStateException(
483482
s"Could not find pom.properties for webjar '$artifactId' on the classpath."
@@ -489,10 +488,7 @@ class WebJar(artifactId: String) {
489488
// Load a resource from this WebJar as a String, uses relative paths.
490489
def load(path: String): String =
491490
val resourcePath = s"META-INF/resources/webjars/$artifactId/$version/$path"
492-
val stream = Thread
493-
.currentThread()
494-
.getContextClassLoader
495-
.getResourceAsStream(resourcePath)
491+
val stream = classLoader.getResourceAsStream(resourcePath)
496492
if stream == null then
497493
throw IllegalStateException(
498494
s"Could not find resource '$path' in webjar '$artifactId' ($version)."

0 commit comments

Comments
 (0)