Skip to content

Commit

Permalink
Release v0.7.2 (#15)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
tschuehly and tschuehly authored Nov 15, 2023
1 parent 1c69d69 commit ca6d4cc
Show file tree
Hide file tree
Showing 26 changed files with 323 additions and 150 deletions.
97 changes: 86 additions & 11 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ name: Publish package to the Maven Central Repository
on:
push:
pull_request:
branches: [ main ]
branches: [ master ]
jobs:
test:
build:

runs-on: ubuntu-latest
outputs:
cacheKey: ${{ steps.cacheKey.outputs.cacheKey }}
steps:
- run: echo "CACHE_KEY=maven-de-tschuehly-$(date +%s)" >> $GITHUB_ENV
- uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
Expand All @@ -17,36 +21,107 @@ jobs:
run: chmod +x ./gradlew
- name: publishToMavenLocal
run: ./gradlew :core:publishToMavenLocal :thymeleaf:publishToMavenLocal :jte:publishToMavenLocal :jte-compiler:publishToMavenLocal
- name: Cache local Maven repository
uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ env.CACHE_KEY }}
- id: cacheKey
run: echo "cacheKey=${{ env.CACHE_KEY }}" >> $GITHUB_OUTPUT
test-thymeleaf-kotlin:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: run thymeleaf kotlin tests
run: |
cd ./examples/thymeleaf-kotlin-example
chmod +x ./gradlew
./gradlew test
test-thymeleaf-java:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: run thymeleaf java tests
run: |
cd ./examples/thymeleaf-java-example
chmod +x ./mvnw
./mvnw test
chmod +x ./mvnw
./mvnw test
- name: run kte kotlin tests
run: |
cd ./examples/kte-example
chmod +x ./gradlew
./gradlew test
test-jte:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- uses: actions/checkout@v3
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: run jte java tests
run: |
cd ./examples/jte-example
chmod +x ./gradlew
./gradlew test
chmod +x ./mvnw
./mvnw test
test-kte:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- name: Set up Java
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
- name: run kte kotlin tests
run: |
cd ./examples/kte-example
chmod +x ./gradlew
./gradlew test
publish:
needs: test
needs: [test-jte,test-kte, test-thymeleaf-kotlin,test-thymeleaf-java]
if: github.ref_type == 'tag' || contains(github.ref_name, 'SNAPSHOT')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: checkout
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: ~/.m2/repository
key: ${{ needs.build.outputs.cacheKey }}
- name: Set up Java
uses: actions/setup-java@v3
with:
Expand Down
4 changes: 2 additions & 2 deletions core/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.7.1"
version = "0.7.2"
java.sourceCompatibility = JavaVersion.VERSION_17

repositories {
Expand All @@ -22,7 +22,7 @@ repositories {
}

dependencies {
implementation("de.tschuehly:spring-view-component-jte-compiler:0.7.1")
implementation("de.tschuehly:spring-view-component-jte-compiler:0.7.2")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter-aop")
implementation("org.springframework.boot:spring-boot-devtools")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ import org.springframework.boot.context.properties.ConfigurationProperties
@ConfigurationProperties("spring.view-component")
data class ViewComponentProperties(
val localDevelopment: Boolean = false,
val templateSuffix: String = ".html"
val jteTemplateDirectories: List<String> = listOf("src/main/java","src/main/kotlin"),
val jteTemplateSuffix: String = ".jte"
)
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import de.tschuehly.spring.viewcomponent.core.component.ViewComponent
import org.slf4j.LoggerFactory
import org.springframework.aop.framework.Advised
import org.springframework.aop.support.AopUtils
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent
import org.springframework.boot.devtools.filewatch.ChangedFiles
import org.springframework.boot.devtools.filewatch.FileChangeListener
import org.springframework.context.ApplicationContext
import org.springframework.context.ApplicationEventPublisher
import org.springframework.context.event.ContextRefreshedEvent


class ViewComponentChangeListener(
Expand Down Expand Up @@ -39,11 +39,7 @@ class ViewComponentChangeListener(
viewComponentName = javaClass.simpleName.lowercase()
)
parser.parseFile(true)
if(srcFile.extension == "kte" || srcFile.extension == "jte"){
applicationEventPublisher.publishEvent(ClassPathChangedEvent(this, changeSet, true))
}else{
applicationEventPublisher.publishEvent(ClassPathChangedEvent(this, changeSet, false))
}
applicationEventPublisher.publishEvent(ContextRefreshedEvent(applicationContext))
}
}

Expand All @@ -57,29 +53,32 @@ class ViewComponentChangeListener(
}
}

private fun getViewActionMethods(javaClass: Class<Any>) =
javaClass.declaredMethods.mapNotNull { method ->
if (method.getAnnotation(GetViewAction::class.java) != null) {
val get = (method.getAnnotation(GetViewAction::class.java) as GetViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, GetViewAction::class.java)
}
if (method.getAnnotation(PostViewAction::class.java) != null) {
val get = (method.getAnnotation(PostViewAction::class.java) as PostViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PostViewAction::class.java)
}
if (method.getAnnotation(PutViewAction::class.java) != null) {
val get = (method.getAnnotation(PutViewAction::class.java) as PutViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PutViewAction::class.java)
}
if (method.getAnnotation(PatchViewAction::class.java) != null) {
val get = (method.getAnnotation(PatchViewAction::class.java) as PatchViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PatchViewAction::class.java)
companion object{
fun getViewActionMethods(javaClass: Class<Any>) =
javaClass.declaredMethods.mapNotNull { method ->
if (method.getAnnotation(GetViewAction::class.java) != null) {
val get = (method.getAnnotation(GetViewAction::class.java) as GetViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, GetViewAction::class.java)
}
if (method.getAnnotation(PostViewAction::class.java) != null) {
val get = (method.getAnnotation(PostViewAction::class.java) as PostViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PostViewAction::class.java)
}
if (method.getAnnotation(PutViewAction::class.java) != null) {
val get = (method.getAnnotation(PutViewAction::class.java) as PutViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PutViewAction::class.java)
}
if (method.getAnnotation(PatchViewAction::class.java) != null) {
val get = (method.getAnnotation(PatchViewAction::class.java) as PatchViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, PatchViewAction::class.java)
}
if (method.getAnnotation(DeleteViewAction::class.java) != null) {
val get = (method.getAnnotation(DeleteViewAction::class.java) as DeleteViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, DeleteViewAction::class.java)
}
return@mapNotNull null
}
if (method.getAnnotation(DeleteViewAction::class.java) != null) {
val get = (method.getAnnotation(DeleteViewAction::class.java) as DeleteViewAction)
return@mapNotNull ViewActionMethod(method.name.toString(), get.path, DeleteViewAction::class.java)
}
return@mapNotNull null
}

}

}
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,6 @@ class ViewComponentParser(
resourceHtmlFile.delete()
return file
}

compiler.compile(
rootDir = resourceDirPath.toAbsolutePath(),
names = srcFile.name,
classDirectory = listOf(
getCompileDirectory(resourceHtmlFile, rootDir)
),
packageName
)
resourceHtmlFile.delete()
return null
}
Expand Down Expand Up @@ -131,13 +122,13 @@ class ViewComponentParser(
private fun getGeneratedSourcesDir(rootDir: String, language: Language): Path {
return if (buildType == BuildType.GRADLE && language == Language.KOTLIN) {
FileSystems.getDefault()
.getPath(rootDir, "build", "generated","source", "kapt","main")
} else if (buildType == BuildType.GRADLE && language == Language.JAVA){
.getPath(rootDir, "build", "generated", "source", "kapt", "main")
} else if (buildType == BuildType.GRADLE && language == Language.JAVA) {
FileSystems.getDefault()
.getPath(rootDir, "build", "generated", "sources", "annotationProcessor", "java", "main")
}else {
.getPath(rootDir, "build", "generated", "sources", "annotationProcessor", "java", "main")
} else {
FileSystems.getDefault()
.getPath(rootDir, "target", "generated-sources","annotations")
.getPath(rootDir, "target", "generated-sources", "annotations")
}
}

Expand Down Expand Up @@ -165,16 +156,16 @@ class ViewComponentParser(
return list[0] to list[1].split(srcFile.name)[0]
}

private fun parseSrcHtmlFile(): List<String> = srcFile.readLines().map { htmlLine ->
if (htmlLine.contains("<body")) {
return@map htmlLine.replace("<body", "<body id=\"$viewComponentName\"")
}
if (htmlLine.contains("view:action")) {
val newLine = htmlLine.parseViewActionHtmlLine()
return@map newLine
fun parseSrcHtmlFile(): List<String> = srcFile.readLines().map { htmlLine ->
if (htmlLine.contains("<body")) {
return@map htmlLine.replace("<body", "<body id=\"$viewComponentName\"")
}
if (htmlLine.contains("view:action")) {
val newLine = htmlLine.parseViewActionHtmlLine()
return@map newLine
}
htmlLine
}
htmlLine
}

private fun String.parseViewActionHtmlLine(): String {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import kotlin.io.path.exists
class ViewComponentProcessor : AbstractProcessor() {

override fun process(annotations: Set<TypeElement>, roundEnv: RoundEnvironment): Boolean {

for (annotation in annotations) {
for (element in roundEnv.getElementsAnnotatedWith(annotation)) {
val messager = processingEnv.messager
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@
"type": "java.lang.Boolean",
"description": "If set to true parses view:action properties to HTMX attributes",
"sourceType": "de.tschuehly.spring.viewcomponent.core.component.ViewComponentProperties"
},
{
"name": "spring.view-component.jte-template-directories",
"type": "java.lang.List",
"description": "Where are the jte templates located? Defaults to \"src/main/java\",\"src/main/kotlin\"",
"sourceType": "de.tschuehly.spring.viewcomponent.core.component.ViewComponentProperties"
},
{
"name": "spring.view-component.jte-template-suffix",
"type": "java.lang.String",
"description": "Defaults to \".jte\", if you want to use kte set it to \".kte\"",
"sourceType": "de.tschuehly.spring.viewcomponent.core.component.ViewComponentProperties"
}
],
"hints": []
Expand Down
1 change: 1 addition & 0 deletions examples/jte-example/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ build/

### VS Code ###
.vscode/
/jte-classes/
4 changes: 2 additions & 2 deletions examples/jte-example/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ repositories {
dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")

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

implementation("org.webjars.npm:htmx.org:1.9.2")
implementation("org.webjars:webjars-locator-core:0.53")
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.7.1</view.component.version>
<view.component.version>0.7.2</view.component.version>
</properties>
<dependencies>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@param de.tschuehly.example.jte.web.action.ActionViewComponent.ActionView actionView

<html>
<head>
<script src="http://localhost:35729/livereload.js"></script>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
spring.view-component.local-development=true
server.port=8082
server.port=8082
logging.level.org.springframework: DEBUG
4 changes: 2 additions & 2 deletions examples/kte-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-jte:0.7.1")
kapt("de.tschuehly:spring-view-component-core:0.7.1")
implementation("de.tschuehly:spring-view-component-jte:0.7.2")
kapt("de.tschuehly:spring-view-component-core:0.7.2")
implementation("io.github.wimdeblauwe:htmx-spring-boot:3.0.0")

implementation("org.webjars.npm:htmx.org:1.9.2")
Expand Down
Loading

0 comments on commit ca6d4cc

Please sign in to comment.