Fix bug with compileUnit not seeing all ssg-gradle found classpath.

This commit is contained in:
Jesse Brault 2025-05-31 23:07:06 -05:00
parent 82a8be76b5
commit ab5b678920
2 changed files with 20 additions and 3 deletions

View File

@ -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(

View File

@ -12,6 +12,22 @@ import groowt.view.component.web.compiler.DefaultWebViewComponentTemplateCompile
@TupleConstructor
class WvcCompiler {
private static class SsgWvcTemplateCompileUnit extends DefaultWebViewComponentTemplateCompileUnit {
SsgWvcTemplateCompileUnit(
String descriptiveName,
Class<? extends ViewComponent> forClass,
ComponentTemplateSource source,
String defaultPackageName,
GroovyClassLoader groovyClassLoader
) {
super(descriptiveName, forClass, source, defaultPackageName)
this.groovyCompilationUnit.setClassLoader(groovyClassLoader)
}
}
final GroovyClassLoader groovyClassLoader
final ComponentTemplateClassFactory templateClassFactory
Either<Diagnostic, ComponentTemplate> 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)