Skip to content

Commit 9a54ce6

Browse files
authored
Merge pull request #54 from jcputney/master
Upgrading to Handlebars 4.4.0, Spring Boot 3, Spring Framework 6, JDK17
2 parents ca9cdd1 + 525d879 commit 9a54ce6

File tree

12 files changed

+41
-55
lines changed

12 files changed

+41
-55
lines changed

.github/workflows/gradle.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ jobs:
1414
with:
1515
fetch-depth: '2'
1616
- name: Set up JDK
17-
uses: actions/setup-java@v2
17+
uses: actions/setup-java@v4
1818
with:
19-
java-version: '8'
19+
java-version: '17'
2020
distribution: 'adopt'
2121
- name: Build with Gradle
2222
run: ./gradlew build

.github/workflows/publish.yml

+5-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,11 @@ jobs:
1515

1616
- uses: gradle/wrapper-validation-action@v1
1717

18-
- name: Set up JDK 1.8
19-
uses: actions/setup-java@v1
18+
- name: Set up JDK 17
19+
uses: actions/setup-java@v4
2020
with:
21-
java-version: 1.8
21+
java-version: 17
22+
distribution: 'adopt'
2223

2324
- name: Publish to maven central
2425
run: ./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
@@ -27,4 +28,4 @@ jobs:
2728
SONATYPE_PASSWORD: ${{ secrets.SONATYPE_PASSWORD }}
2829
GPG_KEY_ID: ${{ secrets.GPG_KEY_ID }}
2930
GPG_PRIVATE_KEY: ${{ secrets.GPG_PRIVATE_KEY }}
30-
GPG_PRIVATE_KEY_PASSWORD: ${{ secrets.GPG_PRIVATE_KEY_PASSWORD }}
31+
GPG_PRIVATE_KEY_PASSWORD: ${{ secrets.GPG_PRIVATE_KEY_PASSWORD }}

README.md

+4-5
Original file line numberDiff line numberDiff line change
@@ -24,20 +24,19 @@ dependencies {
2424

2525
## Requirements
2626

27-
Since version 0.3.0 handlebars-spring-boot-starter requires Spring Boot 2.0, Spring Framework 5 and Java 8.
27+
Since version 0.5.0 handlebars-spring-boot-starter requires Spring Boot 3, Spring Framework 6 and Java 17.
2828

2929
## Helpers
3030

3131
Spring Boot Starter Handlebars will automatically register handlebars helpers based on project dependencies.
3232
Add any handlebars helper to dependencies and you can start using it.
3333
```gradle
3434
dependencies {
35-
compile 'com.github.jknack:handlebars-helpers:4.2.0',
36-
'com.github.jknack:handlebars-jackson2:4.2.0',
37-
'com.github.jknack:handlebars-humanize:4.2.0'
35+
compile 'com.github.jknack:handlebars-helpers:4.4.0',
36+
'com.github.jknack:handlebars-jackson:4.4.0'
3837
}
3938
```
40-
NOTE: Jackson2Helper will register with name `json`.
39+
NOTE: JacksonHelper will register with name `json`.
4140
Every other helper will register with its default name.
4241

4342
More information about available helpers can be found on

build.gradle

+10-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ buildscript {
77
plugins {
88
id 'pmd'
99
id 'jacoco'
10-
id 'com.github.spotbugs' version '4.7.1'
10+
id 'com.github.spotbugs' version '6.0.23'
1111
id 'codenarc'
1212
id 'checkstyle'
1313
id 'maven-publish'
@@ -27,18 +27,18 @@ project.group = 'pl.allegro.tech.boot'
2727
project.version = scmVersion.version
2828

2929
ext {
30-
jodaVersion = '2.12.5'
30+
jodaVersion = '2.13.0'
3131
spockVersion = '2.3-groovy-3.0'
32-
handlebarsVersion = '4.3.1'
33-
springBootVersion = '2.7.16'
32+
handlebarsVersion = '4.4.0'
33+
springBootVersion = '3.3.4'
3434
}
3535

3636
allprojects {
3737
repositories {
3838
mavenCentral()
3939
}
4040
apply plugin: 'groovy'
41-
sourceCompatibility = 1.8
41+
sourceCompatibility = 17
4242

4343
test {
4444
useJUnitPlatform()
@@ -51,8 +51,7 @@ dependencies {
5151

5252
api 'joda-time:joda-time:' + jodaVersion, optional
5353
api 'com.github.jknack:handlebars-helpers:' + handlebarsVersion, optional
54-
api 'com.github.jknack:handlebars-humanize:' + handlebarsVersion, optional
55-
api 'com.github.jknack:handlebars-jackson2:' + handlebarsVersion, optional
54+
api 'com.github.jknack:handlebars-jackson:' + handlebarsVersion, optional
5655
api 'org.springframework.boot:spring-boot-configuration-processor:' + springBootVersion, optional
5756

5857
testImplementation 'org.spockframework:spock-core:' + spockVersion,
@@ -61,10 +60,10 @@ dependencies {
6160
}
6261
compileJava.dependsOn(processResources)
6362

64-
checkstyle { toolVersion = '8.45' }
63+
checkstyle { toolVersion = '10.12.4' }
6564

6665
codenarc {
67-
toolVersion = '2.1.0'
66+
toolVersion = '3.5.0'
6867
configFile = new File("${projectDir}/config/codenarc/test-rules.groovy")
6968
}
7069

@@ -90,8 +89,8 @@ spotbugsTest {
9089

9190
jacocoTestReport {
9291
reports {
93-
xml.enabled = true
94-
html.enabled = true
92+
xml.required = true
93+
html.required = true
9594
}
9695
}
9796

config/codenarc/StarterRuleSet-AllRulesByCategory.groovy

+1-2
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,6 @@ ruleset {
359359
UnnecessarySelfAssignment
360360
UnnecessarySemicolon
361361
UnnecessaryStringInstantiation
362-
UnnecessarySubstring
363362
UnnecessaryTernaryExpression
364363
UnnecessaryToString
365364
UnnecessaryTransientModifier
@@ -374,4 +373,4 @@ ruleset {
374373
UnusedVariable
375374

376375

377-
}
376+
}
+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.3-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.4-bin.zip
44
networkTimeout=10000
55
zipStoreBase=GRADLE_USER_HOME
66
zipStorePath=wrapper/dists
7+
distributionSha256Sum=bed1da33cca0f557ab13691c77f38bb67388119e4794d113e051039b80af9bb1

src/main/java/pl/allegro/tech/boot/autoconfigure/handlebars/HandlebarsAutoConfiguration.java

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
package pl.allegro.tech.boot.autoconfigure.handlebars;
22

33
import com.github.jknack.handlebars.Template;
4-
import com.github.jknack.handlebars.cache.GuavaTemplateCache;
54
import com.github.jknack.handlebars.cache.TemplateCache;
5+
import com.github.jknack.handlebars.guava.GuavaTemplateCache;
66
import com.github.jknack.handlebars.io.TemplateLoader;
77
import com.github.jknack.handlebars.io.TemplateSource;
88
import com.github.jknack.handlebars.springmvc.HandlebarsViewResolver;
99
import org.springframework.beans.factory.annotation.Autowired;
10+
import org.springframework.boot.autoconfigure.AutoConfiguration;
1011
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
1112
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
1213
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
@@ -15,12 +16,12 @@
1516
import org.springframework.context.annotation.Bean;
1617
import org.springframework.context.annotation.Configuration;
1718

18-
import javax.annotation.PostConstruct;
19+
import jakarta.annotation.PostConstruct;
1920

2021
import static com.google.common.cache.CacheBuilder.newBuilder;
2122

23+
@AutoConfiguration
2224
@ConditionalOnProperty(prefix = "handlebars", value = "enabled", havingValue = "true", matchIfMissing = true)
23-
@Configuration
2425
@EnableConfigurationProperties(HandlebarsProperties.class)
2526
@ConditionalOnWebApplication
2627
public class HandlebarsAutoConfiguration {

src/main/java/pl/allegro/tech/boot/autoconfigure/handlebars/HandlebarsHelpersAutoConfiguration.java

+10-23
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
package pl.allegro.tech.boot.autoconfigure.handlebars;
22

3-
import com.github.jknack.handlebars.HumanizeHelper;
4-
import com.github.jknack.handlebars.Jackson2Helper;
5-
import com.github.jknack.handlebars.helper.AssignHelper;
6-
import com.github.jknack.handlebars.helper.IncludeHelper;
7-
import com.github.jknack.handlebars.helper.JodaHelper;
8-
import com.github.jknack.handlebars.helper.NumberHelper;
3+
import com.github.jknack.handlebars.helper.ext.AssignHelper;
4+
import com.github.jknack.handlebars.helper.ext.IncludeHelper;
5+
import com.github.jknack.handlebars.helper.ext.JodaHelper;
6+
import com.github.jknack.handlebars.helper.ext.NumberHelper;
97
import com.github.jknack.handlebars.helper.StringHelpers;
8+
import com.github.jknack.handlebars.jackson.JacksonHelper;
109
import com.github.jknack.handlebars.springmvc.HandlebarsViewResolver;
1110
import org.joda.time.format.DateTimeFormat;
1211
import org.springframework.beans.BeansException;
1312
import org.springframework.beans.factory.annotation.Autowired;
1413
import org.springframework.beans.factory.config.BeanPostProcessor;
14+
import org.springframework.boot.autoconfigure.AutoConfiguration;
1515
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
1616
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
1717
import org.springframework.context.annotation.Bean;
1818
import org.springframework.context.annotation.Configuration;
1919

20-
import javax.annotation.PostConstruct;
20+
import jakarta.annotation.PostConstruct;
2121

2222
import static org.springframework.core.annotation.AnnotationUtils.findAnnotation;
2323

24-
@Configuration
24+
@AutoConfiguration
2525
@ConditionalOnClass(HandlebarsViewResolver.class)
2626
@ConditionalOnWebApplication
2727
public class HandlebarsHelpersAutoConfiguration {
2828

2929
@Configuration
30-
@ConditionalOnClass(Jackson2Helper.class)
30+
@ConditionalOnClass(JacksonHelper.class)
3131
static class JsonHelperAutoConfiguration {
3232

3333
@Autowired
3434
private HandlebarsViewResolver handlebarsViewResolver;
3535

3636
@PostConstruct
3737
public void registerHelper() {
38-
handlebarsViewResolver.registerHelper("json", Jackson2Helper.INSTANCE);
38+
handlebarsViewResolver.registerHelper("json", JacksonHelper.INSTANCE);
3939
}
4040
}
4141

@@ -78,19 +78,6 @@ public void registerHelpers() {
7878
}
7979
}
8080

81-
@Configuration
82-
@ConditionalOnClass(HumanizeHelper.class)
83-
static class HumanizeHelpersAutoConfiguration {
84-
85-
@Autowired
86-
private HandlebarsViewResolver handlebarsViewResolver;
87-
88-
@PostConstruct
89-
public void registerHelpers() {
90-
HumanizeHelper.register(handlebarsViewResolver.getHandlebars());
91-
}
92-
}
93-
9481
@Configuration
9582
@ConditionalOnClass({JodaHelper.class, DateTimeFormat.class})
9683
static class JodaHelpersAutoConfiguration {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
pl.allegro.tech.boot.autoconfigure.handlebars.HandlebarsAutoConfiguration
2+
pl.allegro.tech.boot.autoconfigure.handlebars.HandlebarsHelpersAutoConfiguration

src/test/groovy/pl/allegro/tech/boot/autoconfigure/handlebars/HandlebarsAutoConfigurationSpec.groovy

+1-2
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ package pl.allegro.tech.boot.autoconfigure.handlebars
22

33
import static org.springframework.web.servlet.support.RequestContext.WEB_APPLICATION_CONTEXT_ATTRIBUTE
44

5-
import com.github.jknack.handlebars.cache.GuavaTemplateCache
5+
import com.github.jknack.handlebars.guava.GuavaTemplateCache
66
import com.github.jknack.handlebars.cache.HighConcurrencyTemplateCache
77
import com.github.jknack.handlebars.cache.NullTemplateCache
88
import com.github.jknack.handlebars.io.ClassPathTemplateLoader
99
import com.github.jknack.handlebars.springmvc.HandlebarsViewResolver
1010
import com.github.jknack.handlebars.springmvc.SpringTemplateLoader
1111
import org.springframework.beans.factory.NoSuchBeanDefinitionException
12-
import org.springframework.boot.test.util.TestPropertyValues
1312
import org.springframework.context.annotation.Bean
1413
import org.springframework.mock.web.MockHttpServletRequest
1514
import org.springframework.mock.web.MockHttpServletResponse

src/test/groovy/pl/allegro/tech/boot/autoconfigure/handlebars/HandlebarsHelpersAutoConfigurationSpec.groovy

-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ class HandlebarsHelpersAutoConfigurationSpec extends Specification {
3131
with(resolver) {
3232
helper('json')
3333
helper('assign')
34-
helper('camelize')
3534
helper('include')
3635
helper('stringFormat')
3736
}

test-dependencies/src/test/groovy/pl/allegro/tech/boot/autoconfigure/handlebars/HandlebarsHelpersDependenciesSpec.groovy

-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,5 @@ class HandlebarsHelpersDependenciesSpec extends Specification {
3131
resolver.helper('json')
3232
resolver.helper('assign')
3333
resolver.helper('include')
34-
resolver.helper('camelize')
3534
}
3635
}

0 commit comments

Comments
 (0)