Skip to content

Commit ca6d4cc

Browse files
authored
Release v0.7.2 (#15)
* bump version to 0.7.2-SNAPSHOT for further development * parallel ci * trigger livereload after updating classes * cache-key * output cache-key * save * working livereload with jte coderesolver * working jte proccessor * jte coderesolver works in multi module project * delete application properties * bump to 0.7.2 stable --------- Co-authored-by: tschuehly <tschuehly@outlook.com>
1 parent 1c69d69 commit ca6d4cc

26 files changed

Lines changed: 323 additions & 150 deletions

File tree

.github/workflows/release.yml

Lines changed: 86 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ name: Publish package to the Maven Central Repository
22
on:
33
push:
44
pull_request:
5-
branches: [ main ]
5+
branches: [ master ]
66
jobs:
7-
test:
7+
build:
8+
89
runs-on: ubuntu-latest
10+
outputs:
11+
cacheKey: ${{ steps.cacheKey.outputs.cacheKey }}
912
steps:
13+
- run: echo "CACHE_KEY=maven-de-tschuehly-$(date +%s)" >> $GITHUB_ENV
1014
- uses: actions/checkout@v3
1115
- name: Set up Java
1216
uses: actions/setup-java@v3
@@ -17,36 +21,107 @@ jobs:
1721
run: chmod +x ./gradlew
1822
- name: publishToMavenLocal
1923
run: ./gradlew :core:publishToMavenLocal :thymeleaf:publishToMavenLocal :jte:publishToMavenLocal :jte-compiler:publishToMavenLocal
24+
- name: Cache local Maven repository
25+
uses: actions/cache@v3
26+
with:
27+
path: ~/.m2/repository
28+
key: ${{ env.CACHE_KEY }}
29+
- id: cacheKey
30+
run: echo "cacheKey=${{ env.CACHE_KEY }}" >> $GITHUB_OUTPUT
31+
test-thymeleaf-kotlin:
32+
needs: build
33+
runs-on: ubuntu-latest
34+
steps:
35+
- name: checkout
36+
uses: actions/checkout@v3
37+
- uses: actions/cache@v3
38+
with:
39+
path: ~/.m2/repository
40+
key: ${{ needs.build.outputs.cacheKey }}
41+
- name: Set up Java
42+
uses: actions/setup-java@v3
43+
with:
44+
java-version: '17'
45+
distribution: 'temurin'
2046
- name: run thymeleaf kotlin tests
2147
run: |
2248
cd ./examples/thymeleaf-kotlin-example
2349
chmod +x ./gradlew
2450
./gradlew test
51+
test-thymeleaf-java:
52+
needs: build
53+
runs-on: ubuntu-latest
54+
steps:
55+
- name: checkout
56+
uses: actions/checkout@v3
57+
- uses: actions/cache@v3
58+
with:
59+
path: ~/.m2/repository
60+
key: ${{ needs.build.outputs.cacheKey }}
61+
- name: Set up Java
62+
uses: actions/setup-java@v3
63+
with:
64+
java-version: '17'
65+
distribution: 'temurin'
2566
- name: run thymeleaf java tests
2667
run: |
2768
cd ./examples/thymeleaf-java-example
2869
chmod +x ./mvnw
2970
./mvnw test
30-
chmod +x ./mvnw
31-
./mvnw test
32-
- name: run kte kotlin tests
33-
run: |
34-
cd ./examples/kte-example
35-
chmod +x ./gradlew
36-
./gradlew test
71+
test-jte:
72+
needs: build
73+
runs-on: ubuntu-latest
74+
steps:
75+
- name: checkout
76+
uses: actions/checkout@v3
77+
- uses: actions/cache@v3
78+
with:
79+
path: ~/.m2/repository
80+
key: ${{ needs.build.outputs.cacheKey }}
81+
- uses: actions/checkout@v3
82+
- name: Set up Java
83+
uses: actions/setup-java@v3
84+
with:
85+
java-version: '17'
86+
distribution: 'temurin'
3787
- name: run jte java tests
3888
run: |
3989
cd ./examples/jte-example
4090
chmod +x ./gradlew
4191
./gradlew test
4292
chmod +x ./mvnw
4393
./mvnw test
94+
test-kte:
95+
needs: build
96+
runs-on: ubuntu-latest
97+
steps:
98+
- name: checkout
99+
uses: actions/checkout@v3
100+
- uses: actions/cache@v3
101+
with:
102+
path: ~/.m2/repository
103+
key: ${{ needs.build.outputs.cacheKey }}
104+
- name: Set up Java
105+
uses: actions/setup-java@v3
106+
with:
107+
java-version: '17'
108+
distribution: 'temurin'
109+
- name: run kte kotlin tests
110+
run: |
111+
cd ./examples/kte-example
112+
chmod +x ./gradlew
113+
./gradlew test
44114
publish:
45-
needs: test
115+
needs: [test-jte,test-kte, test-thymeleaf-kotlin,test-thymeleaf-java]
46116
if: github.ref_type == 'tag' || contains(github.ref_name, 'SNAPSHOT')
47117
runs-on: ubuntu-latest
48118
steps:
49-
- uses: actions/checkout@v3
119+
- name: checkout
120+
uses: actions/checkout@v3
121+
- uses: actions/cache@v3
122+
with:
123+
path: ~/.m2/repository
124+
key: ${{ needs.build.outputs.cacheKey }}
50125
- name: Set up Java
51126
uses: actions/setup-java@v3
52127
with:

core/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ plugins {
1313
}
1414

1515
group = "de.tschuehly"
16-
version = "0.7.1"
16+
version = "0.7.2"
1717
java.sourceCompatibility = JavaVersion.VERSION_17
1818

1919
repositories {
@@ -22,7 +22,7 @@ repositories {
2222
}
2323

2424
dependencies {
25-
implementation("de.tschuehly:spring-view-component-jte-compiler:0.7.1")
25+
implementation("de.tschuehly:spring-view-component-jte-compiler:0.7.2")
2626
implementation("org.springframework.boot:spring-boot-starter-web")
2727
implementation("org.springframework.boot:spring-boot-starter-aop")
2828
implementation("org.springframework.boot:spring-boot-devtools")

core/src/main/kotlin/de/tschuehly/spring/viewcomponent/core/component/ViewComponentProperties.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties
55
@ConfigurationProperties("spring.view-component")
66
data class ViewComponentProperties(
77
val localDevelopment: Boolean = false,
8-
val templateSuffix: String = ".html"
8+
val jteTemplateDirectories: List<String> = listOf("src/main/java","src/main/kotlin"),
9+
val jteTemplateSuffix: String = ".jte"
910
)

core/src/main/kotlin/de/tschuehly/spring/viewcomponent/core/processor/ViewComponentChangeListener.kt

Lines changed: 28 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ import de.tschuehly.spring.viewcomponent.core.component.ViewComponent
55
import org.slf4j.LoggerFactory
66
import org.springframework.aop.framework.Advised
77
import org.springframework.aop.support.AopUtils
8-
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent
98
import org.springframework.boot.devtools.filewatch.ChangedFiles
109
import org.springframework.boot.devtools.filewatch.FileChangeListener
1110
import org.springframework.context.ApplicationContext
1211
import org.springframework.context.ApplicationEventPublisher
12+
import org.springframework.context.event.ContextRefreshedEvent
1313

1414

1515
class ViewComponentChangeListener(
@@ -39,11 +39,7 @@ class ViewComponentChangeListener(
3939
viewComponentName = javaClass.simpleName.lowercase()
4040
)
4141
parser.parseFile(true)
42-
if(srcFile.extension == "kte" || srcFile.extension == "jte"){
43-
applicationEventPublisher.publishEvent(ClassPathChangedEvent(this, changeSet, true))
44-
}else{
45-
applicationEventPublisher.publishEvent(ClassPathChangedEvent(this, changeSet, false))
46-
}
42+
applicationEventPublisher.publishEvent(ContextRefreshedEvent(applicationContext))
4743
}
4844
}
4945

@@ -57,29 +53,32 @@ class ViewComponentChangeListener(
5753
}
5854
}
5955

60-
private fun getViewActionMethods(javaClass: Class<Any>) =
61-
javaClass.declaredMethods.mapNotNull { method ->
62-
if (method.getAnnotation(GetViewAction::class.java) != null) {
63-
val get = (method.getAnnotation(GetViewAction::class.java) as GetViewAction)
64-
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, GetViewAction::class.java)
65-
}
66-
if (method.getAnnotation(PostViewAction::class.java) != null) {
67-
val get = (method.getAnnotation(PostViewAction::class.java) as PostViewAction)
68-
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PostViewAction::class.java)
69-
}
70-
if (method.getAnnotation(PutViewAction::class.java) != null) {
71-
val get = (method.getAnnotation(PutViewAction::class.java) as PutViewAction)
72-
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PutViewAction::class.java)
73-
}
74-
if (method.getAnnotation(PatchViewAction::class.java) != null) {
75-
val get = (method.getAnnotation(PatchViewAction::class.java) as PatchViewAction)
76-
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PatchViewAction::class.java)
56+
companion object{
57+
fun getViewActionMethods(javaClass: Class<Any>) =
58+
javaClass.declaredMethods.mapNotNull { method ->
59+
if (method.getAnnotation(GetViewAction::class.java) != null) {
60+
val get = (method.getAnnotation(GetViewAction::class.java) as GetViewAction)
61+
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, GetViewAction::class.java)
62+
}
63+
if (method.getAnnotation(PostViewAction::class.java) != null) {
64+
val get = (method.getAnnotation(PostViewAction::class.java) as PostViewAction)
65+
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PostViewAction::class.java)
66+
}
67+
if (method.getAnnotation(PutViewAction::class.java) != null) {
68+
val get = (method.getAnnotation(PutViewAction::class.java) as PutViewAction)
69+
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PutViewAction::class.java)
70+
}
71+
if (method.getAnnotation(PatchViewAction::class.java) != null) {
72+
val get = (method.getAnnotation(PatchViewAction::class.java) as PatchViewAction)
73+
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PatchViewAction::class.java)
74+
}
75+
if (method.getAnnotation(DeleteViewAction::class.java) != null) {
76+
val get = (method.getAnnotation(DeleteViewAction::class.java) as DeleteViewAction)
77+
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, DeleteViewAction::class.java)
78+
}
79+
return@mapNotNull null
7780
}
78-
if (method.getAnnotation(DeleteViewAction::class.java) != null) {
79-
val get = (method.getAnnotation(DeleteViewAction::class.java) as DeleteViewAction)
80-
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, DeleteViewAction::class.java)
81-
}
82-
return@mapNotNull null
83-
}
81+
82+
}
8483

8584
}

core/src/main/kotlin/de/tschuehly/spring/viewcomponent/core/processor/ViewComponentParser.kt

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -66,15 +66,6 @@ class ViewComponentParser(
6666
resourceHtmlFile.delete()
6767
return file
6868
}
69-
70-
compiler.compile(
71-
rootDir = resourceDirPath.toAbsolutePath(),
72-
names = srcFile.name,
73-
classDirectory = listOf(
74-
getCompileDirectory(resourceHtmlFile, rootDir)
75-
),
76-
packageName
77-
)
7869
resourceHtmlFile.delete()
7970
return null
8071
}
@@ -131,13 +122,13 @@ class ViewComponentParser(
131122
private fun getGeneratedSourcesDir(rootDir: String, language: Language): Path {
132123
return if (buildType == BuildType.GRADLE && language == Language.KOTLIN) {
133124
FileSystems.getDefault()
134-
.getPath(rootDir, "build", "generated","source", "kapt","main")
135-
} else if (buildType == BuildType.GRADLE && language == Language.JAVA){
125+
.getPath(rootDir, "build", "generated", "source", "kapt", "main")
126+
} else if (buildType == BuildType.GRADLE && language == Language.JAVA) {
136127
FileSystems.getDefault()
137-
.getPath(rootDir, "build", "generated", "sources", "annotationProcessor", "java", "main")
138-
}else {
128+
.getPath(rootDir, "build", "generated", "sources", "annotationProcessor", "java", "main")
129+
} else {
139130
FileSystems.getDefault()
140-
.getPath(rootDir, "target", "generated-sources","annotations")
131+
.getPath(rootDir, "target", "generated-sources", "annotations")
141132
}
142133
}
143134

@@ -165,16 +156,16 @@ class ViewComponentParser(
165156
return list[0] to list[1].split(srcFile.name)[0]
166157
}
167158

168-
private fun parseSrcHtmlFile(): List<String> = srcFile.readLines().map { htmlLine ->
169-
if (htmlLine.contains("<body")) {
170-
return@map htmlLine.replace("<body", "<body id=\"$viewComponentName\"")
171-
}
172-
if (htmlLine.contains("view:action")) {
173-
val newLine = htmlLine.parseViewActionHtmlLine()
174-
return@map newLine
159+
fun parseSrcHtmlFile(): List<String> = srcFile.readLines().map { htmlLine ->
160+
if (htmlLine.contains("<body")) {
161+
return@map htmlLine.replace("<body", "<body id=\"$viewComponentName\"")
162+
}
163+
if (htmlLine.contains("view:action")) {
164+
val newLine = htmlLine.parseViewActionHtmlLine()
165+
return@map newLine
166+
}
167+
htmlLine
175168
}
176-
htmlLine
177-
}
178169

179170
private fun String.parseViewActionHtmlLine(): String {
180171

core/src/main/kotlin/de/tschuehly/spring/viewcomponent/core/processor/ViewComponentProcessor.kt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import kotlin.io.path.exists
2222
class ViewComponentProcessor : AbstractProcessor() {
2323

2424
override fun process(annotations: Set<TypeElement>, roundEnv: RoundEnvironment): Boolean {
25-
2625
for (annotation in annotations) {
2726
for (element in roundEnv.getElementsAnnotatedWith(annotation)) {
2827
val messager = processingEnv.messager

core/src/main/resources/META-INF/spring-configuration-metadata.json

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,18 @@
1818
"type": "java.lang.Boolean",
1919
"description": "If set to true parses view:action properties to HTMX attributes",
2020
"sourceType": "de.tschuehly.spring.viewcomponent.core.component.ViewComponentProperties"
21+
},
22+
{
23+
"name": "spring.view-component.jte-template-directories",
24+
"type": "java.lang.List",
25+
"description": "Where are the jte templates located? Defaults to \"src/main/java\",\"src/main/kotlin\"",
26+
"sourceType": "de.tschuehly.spring.viewcomponent.core.component.ViewComponentProperties"
27+
},
28+
{
29+
"name": "spring.view-component.jte-template-suffix",
30+
"type": "java.lang.String",
31+
"description": "Defaults to \".jte\", if you want to use kte set it to \".kte\"",
32+
"sourceType": "de.tschuehly.spring.viewcomponent.core.component.ViewComponentProperties"
2133
}
2234
],
2335
"hints": []

examples/jte-example/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,4 @@ build/
3131

3232
### VS Code ###
3333
.vscode/
34+
/jte-classes/

examples/jte-example/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ repositories {
1919
dependencies {
2020
implementation("org.springframework.boot:spring-boot-starter-web")
2121

22-
implementation("de.tschuehly:spring-view-component-jte:0.7.1")
23-
annotationProcessor("de.tschuehly:spring-view-component-core:0.7.1")
22+
implementation("de.tschuehly:spring-view-component-jte:0.7.2")
23+
annotationProcessor("de.tschuehly:spring-view-component-core:0.7.2")
2424

2525
implementation("org.webjars.npm:htmx.org:1.9.2")
2626
implementation("org.webjars:webjars-locator-core:0.53")

examples/jte-example/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<description>JTE Example</description>
1616
<properties>
1717
<java.version>17</java.version>
18-
<view.component.version>0.7.1</view.component.version>
18+
<view.component.version>0.7.2</view.component.version>
1919
</properties>
2020
<dependencies>
2121
<dependency>

0 commit comments

Comments
 (0)