Skip to content

Commit

Permalink
release: v0.8.3: JTE DevTools fix
Browse files Browse the repository at this point in the history
Also added `BeanClassLoaderAware` implementation to `JteConfiguration` to handle class loader assignment.
  • Loading branch information
tschuehly committed Aug 12, 2024
1 parent 02a9eea commit 69c8580
Show file tree
Hide file tree
Showing 13 changed files with 59 additions and 28 deletions.
25 changes: 25 additions & 0 deletions .run/JteExample.run.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="JteExample" type="SpringBootApplicationConfigurationType" factoryName="Spring Boot" nameIsGenerated="true">
<module name="jte-example.main" />
<option name="SPRING_BOOT_MAIN_CLASS" value="de.tschuehly.example.jte.JteExample" />
<extension name="coverage">
<pattern>
<option name="PATTERN" value="de.tschuehly.example.jte.*" />
<option name="ENABLED" value="true" />
</pattern>
</extension>
<extension name="net.ashald.envfile">
<option name="IS_ENABLED" value="false" />
<option name="IS_SUBST" value="false" />
<option name="IS_PATH_MACRO_SUPPORTED" value="false" />
<option name="IS_IGNORE_MISSING_FILES" value="false" />
<option name="IS_ENABLE_EXPERIMENTAL_INTEGRATIONS" value="false" />
<ENTRIES>
<ENTRY IS_ENABLED="true" PARSER="runconfig" IS_EXECUTABLE="false" />
</ENTRIES>
</extension>
<method v="2">
<option name="Make" enabled="true" />
</method>
</configuration>
</component>
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ spring.view-component.local-development=true
<summary>Gradle</summary>

```kotlin
implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.2")
implementation("de.tschuehly:spring-view-component-thymeleaf:0.8.3")
sourceSets {
main {
resources {
Expand All @@ -249,7 +249,7 @@ sourceSets {
<dependency>
<groupId>de.tschuehly</groupId>
<artifactId>spring-view-component-thymeleaf</artifactId>
<version>0.8.2</version>
<version>0.8.3</version>
</dependency>
</dependencies>
<build>
Expand Down Expand Up @@ -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()
Expand All @@ -305,7 +305,7 @@ jte{
<dependency>
<groupId>de.tschuehly</groupId>
<artifactId>spring-view-component-jte</artifactId>
<version>0.8.2</version>
<version>0.8.3</version>
</dependency>
</dependencies>
<build>
Expand Down Expand Up @@ -343,7 +343,7 @@ jte{
<summary>Gradle</summary>

```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")
Expand Down
2 changes: 1 addition & 1 deletion core/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
}

group = "de.tschuehly"
version = "0.8.2"
version = "0.8.3"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
Expand Down
4 changes: 2 additions & 2 deletions examples/jte-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Test> {
Expand Down
2 changes: 1 addition & 1 deletion examples/jte-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<description>JTE Example</description>
<properties>
<java.version>17</java.version>
<view.component.version>0.8.2</view.component.version>
<view.component.version>0.8.3</view.component.version>
</properties>
<dependencies>
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions examples/kte-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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<KotlinCompile> {
Expand Down
4 changes: 2 additions & 2 deletions examples/thymeleaf-java-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Test> {
Expand Down
2 changes: 1 addition & 1 deletion examples/thymeleaf-java-example/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<description>Thymeleaf Java Example</description>
<properties>
<java.version>17</java.version>
<view.component.version>0.8.2</view.component.version>
<view.component.version>0.8.3</view.component.version>
</properties>
<dependencies>
<dependency>
Expand Down
6 changes: 3 additions & 3 deletions examples/thymeleaf-kotlin-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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<KotlinCompile> {
Expand Down
4 changes: 2 additions & 2 deletions jte/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ plugins {
}

group = "de.tschuehly"
version = "0.8.2"
version = "0.8.3"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
Expand All @@ -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")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 {
Expand All @@ -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()
Expand All @@ -38,7 +40,7 @@ class JteConfiguration {
codeResolver,
Paths.get("jte-classes"),
ContentType.Html,
Thread.currentThread().contextClassLoader
classLoader
)
}

Expand All @@ -49,4 +51,8 @@ class JteConfiguration {
it.templateLocation = viewComponentProperties.viewComponentRoot
it.isDevelopmentMode = viewComponentProperties.localDevelopment
}

override fun setBeanClassLoader(classLoader: ClassLoader) {
this.classLoader = classLoader
}
}
4 changes: 2 additions & 2 deletions kte/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ plugins {
}

group = "de.tschuehly"
version = "0.8.2"
version = "0.8.3"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
mavenCentral()
}
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")
Expand Down
4 changes: 2 additions & 2 deletions thymeleaf/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@ plugins {
}

group = "de.tschuehly"
version = "0.8.2"
version = "0.8.3"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
mavenCentral()
}

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")
Expand Down

0 comments on commit 69c8580

Please sign in to comment.