diff --git a/.run/JteExample.run.xml b/.run/JteExample.run.xml new file mode 100644 index 0000000..7cf6d5d --- /dev/null +++ b/.run/JteExample.run.xml @@ -0,0 +1,25 @@ + + + + + \ No newline at end of file diff --git a/README.md b/README.md index b75b6b7..7a56f32 100644 --- a/README.md +++ b/README.md @@ -227,7 +227,7 @@ spring.view-component.local-development=true Gradle ```kotlin -implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.2") +implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.3") sourceSets { main { resources { @@ -249,7 +249,7 @@ sourceSets { de.tschuehly spring-view-component-thymeleaf - 0.8.2 + 0.8.3 @@ -286,7 +286,7 @@ plugins { id("gg.jte.gradle") version("3.1.12") } -implementation("de.tschuehly:spring-view-component-jte:0.8.2") +implementation("de.tschuehly:spring-view-component-jte:0.8.3") jte{ generate() @@ -305,7 +305,7 @@ jte{ de.tschuehly spring-view-component-jte - 0.8.2 + 0.8.3 @@ -343,7 +343,7 @@ jte{ Gradle ```kotlin -implementation("de.tschuehly:spring-view-component-kte:0.8.2") +implementation("de.tschuehly:spring-view-component-kte:0.8.3") jte{ generate() sourceDirectory = Path("src/main/kotlin") diff --git a/core/build.gradle.kts b/core/build.gradle.kts index a90ea6d..06aefb3 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -14,7 +14,7 @@ plugins { } group = "de.tschuehly" -version = "0.8.2" +version = "0.8.3" java.sourceCompatibility = JavaVersion.VERSION_17 repositories { diff --git a/examples/jte-example/build.gradle.kts b/examples/jte-example/build.gradle.kts index 0b8a6dc..8fa77c0 100644 --- a/examples/jte-example/build.gradle.kts +++ b/examples/jte-example/build.gradle.kts @@ -26,14 +26,14 @@ repositories { dependencies { implementation("org.springframework.boot:spring-boot-starter-web") - implementation("de.tschuehly:spring-view-component-jte:0.8.2") + implementation("de.tschuehly:spring-view-component-jte:0.8.3") implementation("org.webjars.npm:htmx.org:1.9.11") implementation("org.webjars:webjars-locator-core:0.58") testImplementation("org.springframework.boot:spring-boot-starter-test") testRuntimeOnly("org.springframework.boot:spring-boot-devtools") - testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.2")) + testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.3")) } tasks.withType { diff --git a/examples/jte-example/pom.xml b/examples/jte-example/pom.xml index 2799fd7..579b2b6 100644 --- a/examples/jte-example/pom.xml +++ b/examples/jte-example/pom.xml @@ -15,7 +15,7 @@ JTE Example 17 - 0.8.2 + 0.8.3 diff --git a/examples/kte-example/build.gradle.kts b/examples/kte-example/build.gradle.kts index 113374f..9d05668 100644 --- a/examples/kte-example/build.gradle.kts +++ b/examples/kte-example/build.gradle.kts @@ -31,8 +31,8 @@ repositories { } dependencies { - implementation("de.tschuehly:spring-view-component-kte:0.8.2") - implementation("de.tschuehly:spring-view-component-core:0.8.2") + implementation("de.tschuehly:spring-view-component-kte:0.8.3") + implementation("de.tschuehly:spring-view-component-core:0.8.3") implementation("io.github.wimdeblauwe:htmx-spring-boot:3.1.1") implementation("org.webjars.npm:htmx.org:1.9.11") @@ -47,7 +47,7 @@ dependencies { testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.springframework.boot:spring-boot-devtools") - testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.2")) + testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.3")) } tasks.withType { diff --git a/examples/thymeleaf-java-example/build.gradle.kts b/examples/thymeleaf-java-example/build.gradle.kts index 7f7ee1f..b742010 100644 --- a/examples/thymeleaf-java-example/build.gradle.kts +++ b/examples/thymeleaf-java-example/build.gradle.kts @@ -29,14 +29,14 @@ repositories { dependencies { implementation("org.springframework.boot:spring-boot-starter-web") - implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.2") + implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.3") implementation("org.webjars.npm:htmx.org:1.9.11") implementation("org.webjars:webjars-locator-core:0.58") testImplementation("org.springframework.boot:spring-boot-starter-test") testImplementation("org.springframework.boot:spring-boot-devtools") - testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.2")) + testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.3")) } tasks.withType { diff --git a/examples/thymeleaf-java-example/pom.xml b/examples/thymeleaf-java-example/pom.xml index eaaac31..fe9d89e 100644 --- a/examples/thymeleaf-java-example/pom.xml +++ b/examples/thymeleaf-java-example/pom.xml @@ -15,7 +15,7 @@ Thymeleaf Java Example 17 - 0.8.2 + 0.8.3 diff --git a/examples/thymeleaf-kotlin-example/build.gradle.kts b/examples/thymeleaf-kotlin-example/build.gradle.kts index 652e14f..9546dc0 100644 --- a/examples/thymeleaf-kotlin-example/build.gradle.kts +++ b/examples/thymeleaf-kotlin-example/build.gradle.kts @@ -18,8 +18,8 @@ repositories { } dependencies { - implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.2") - implementation("de.tschuehly:spring-view-component-core:0.8.2") + implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.3") + implementation("de.tschuehly:spring-view-component-core:0.8.3") implementation("org.webjars.npm:htmx.org:1.9.2") implementation("org.webjars:webjars-locator:0.47") @@ -35,7 +35,7 @@ dependencies { implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8") testImplementation("org.springframework.boot:spring-boot-devtools") - testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.2")) + testImplementation(testFixtures("de.tschuehly:spring-view-component-core:0.8.3")) } tasks.withType { diff --git a/jte/build.gradle.kts b/jte/build.gradle.kts index 83a4894..1536577 100644 --- a/jte/build.gradle.kts +++ b/jte/build.gradle.kts @@ -13,7 +13,7 @@ plugins { } group = "de.tschuehly" -version = "0.8.2" +version = "0.8.3" java.sourceCompatibility = JavaVersion.VERSION_17 repositories { @@ -22,7 +22,7 @@ repositories { } dependencies { api("gg.jte:jte:3.1.12") - api("de.tschuehly:spring-view-component-core:0.8.2") + api("de.tschuehly:spring-view-component-core:0.8.3") implementation("gg.jte:jte-spring-boot-starter-3:3.1.12") implementation("org.springframework.boot:spring-boot-starter-web") diff --git a/jte/src/main/kotlin/de/tschuehly/spring/viewcomponent/jte/JteConfiguration.kt b/jte/src/main/kotlin/de/tschuehly/spring/viewcomponent/jte/JteConfiguration.kt index fc086ea..b473768 100644 --- a/jte/src/main/kotlin/de/tschuehly/spring/viewcomponent/jte/JteConfiguration.kt +++ b/jte/src/main/kotlin/de/tschuehly/spring/viewcomponent/jte/JteConfiguration.kt @@ -5,6 +5,7 @@ import gg.jte.ContentType import gg.jte.TemplateEngine import gg.jte.resolve.DirectoryCodeResolver import gg.jte.springframework.boot.autoconfigure.JteProperties +import org.springframework.beans.factory.BeanClassLoaderAware import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean import org.springframework.context.ApplicationContext import org.springframework.context.annotation.Bean @@ -15,7 +16,8 @@ import java.nio.file.Path import java.nio.file.Paths @Configuration -class JteConfiguration { +class JteConfiguration : BeanClassLoaderAware{ + var classLoader: ClassLoader? = null; @Bean fun jteViewContextAspect(templateEngine: TemplateEngine, jteProperties: JteProperties): JteViewContextAspect { @@ -27,9 +29,9 @@ class JteConfiguration { fun jteTemplateEngine(viewComponentProperties: ViewComponentProperties,applicationContext: ApplicationContext): TemplateEngine { if (!viewComponentProperties.localDevelopment) { return TemplateEngine.createPrecompiled( - /* classDirectory = */ Path.of(this.javaClass.classLoader.getResource("").toURI()), + /* classDirectory = */ Path.of(classLoader?.getResource("")?.toURI() ?: throw RuntimeException("ClassLoader is null")), /* contentType = */ ContentType.Html, - /* parentClassLoader = */ this.javaClass.classLoader + /* parentClassLoader = */ classLoader ) } val split = viewComponentProperties.viewComponentRoot.split("/").toTypedArray() @@ -38,7 +40,7 @@ class JteConfiguration { codeResolver, Paths.get("jte-classes"), ContentType.Html, - Thread.currentThread().contextClassLoader + classLoader ) } @@ -49,4 +51,8 @@ class JteConfiguration { it.templateLocation = viewComponentProperties.viewComponentRoot it.isDevelopmentMode = viewComponentProperties.localDevelopment } + + override fun setBeanClassLoader(classLoader: ClassLoader) { + this.classLoader = classLoader + } } \ No newline at end of file diff --git a/kte/build.gradle.kts b/kte/build.gradle.kts index 8b37a60..345f4e0 100644 --- a/kte/build.gradle.kts +++ b/kte/build.gradle.kts @@ -13,7 +13,7 @@ plugins { } group = "de.tschuehly" -version = "0.8.2" +version = "0.8.3" java.sourceCompatibility = JavaVersion.VERSION_17 repositories { @@ -21,7 +21,7 @@ repositories { } dependencies { api("gg.jte:jte-kotlin:3.1.12") - api("de.tschuehly:spring-view-component-core:0.8.2") + api("de.tschuehly:spring-view-component-core:0.8.3") implementation("gg.jte:jte-spring-boot-starter-3:3.1.12") implementation("org.springframework.boot:spring-boot-starter-web") diff --git a/thymeleaf/build.gradle.kts b/thymeleaf/build.gradle.kts index e6ab146..09f6a6d 100644 --- a/thymeleaf/build.gradle.kts +++ b/thymeleaf/build.gradle.kts @@ -13,7 +13,7 @@ plugins { } group = "de.tschuehly" -version = "0.8.2" +version = "0.8.3" java.sourceCompatibility = JavaVersion.VERSION_17 repositories { @@ -21,7 +21,7 @@ repositories { } dependencies { - api("de.tschuehly:spring-view-component-core:0.8.2") + api("de.tschuehly:spring-view-component-core:0.8.3") api("org.springframework.boot:spring-boot-devtools") implementation("org.springframework.boot:spring-boot-starter-web") implementation("org.springframework.boot:spring-boot-starter-thymeleaf")