diff --git a/api/src/main/groovy/com/jessebrault/ssg/DefaultStaticSiteGenerator.groovy b/api/src/main/groovy/com/jessebrault/ssg/DefaultStaticSiteGenerator.groovy index f572aed..3b9d9d3 100644 --- a/api/src/main/groovy/com/jessebrault/ssg/DefaultStaticSiteGenerator.groovy +++ b/api/src/main/groovy/com/jessebrault/ssg/DefaultStaticSiteGenerator.groovy @@ -71,7 +71,7 @@ class DefaultStaticSiteGenerator implements StaticSiteGenerator { } protected WvcCompiler getWvcCompiler() { - new WvcCompiler(new SimpleComponentTemplateClassFactory(this.groovyClassLoader)) + new WvcCompiler(this.groovyClassLoader, new SimpleComponentTemplateClassFactory(this.groovyClassLoader)) } protected WebViewComponentContext makeContext( diff --git a/api/src/main/groovy/com/jessebrault/ssg/view/WvcCompiler.groovy b/api/src/main/groovy/com/jessebrault/ssg/view/WvcCompiler.groovy index 851f1b7..d9e137c 100644 --- a/api/src/main/groovy/com/jessebrault/ssg/view/WvcCompiler.groovy +++ b/api/src/main/groovy/com/jessebrault/ssg/view/WvcCompiler.groovy @@ -12,6 +12,22 @@ import groowt.view.component.web.compiler.DefaultWebViewComponentTemplateCompile @TupleConstructor class WvcCompiler { + private static class SsgWvcTemplateCompileUnit extends DefaultWebViewComponentTemplateCompileUnit { + + SsgWvcTemplateCompileUnit( + String descriptiveName, + Class forClass, + ComponentTemplateSource source, + String defaultPackageName, + GroovyClassLoader groovyClassLoader + ) { + super(descriptiveName, forClass, source, defaultPackageName) + this.groovyCompilationUnit.setClassLoader(groovyClassLoader) + } + + } + + final GroovyClassLoader groovyClassLoader final ComponentTemplateClassFactory templateClassFactory Either compileTemplate( @@ -25,11 +41,12 @@ class WvcCompiler { )) } def source = ComponentTemplateSource.of(templateUrl) - def compileUnit = new DefaultWebViewComponentTemplateCompileUnit( + def compileUnit = new SsgWvcTemplateCompileUnit( source.descriptiveName, componentClass, source, - componentClass.packageName + componentClass.packageName, + this.groovyClassLoader ) def compileResult = compileUnit.compile() def templateClass = templateClassFactory.getTemplateClass(compileResult)