Skip to content

Commit a19a7cc

Browse files
committed
Create spring-boot-freemarker module
1 parent 395d1d7 commit a19a7cc

File tree

35 files changed

+127
-93
lines changed

35 files changed

+127
-93
lines changed

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ include "spring-boot-project:spring-boot-devtools"
5252
include "spring-boot-project:spring-boot-docker-compose"
5353
include "spring-boot-project:spring-boot-docs"
5454
include "spring-boot-project:spring-boot-flyway"
55+
include "spring-boot-project:spring-boot-freemarker"
5556
include "spring-boot-project:spring-boot-groovy-templates"
5657
include "spring-boot-project:spring-boot-jackson"
5758
include "spring-boot-project:spring-boot-jdbc"

spring-boot-project/spring-boot-autoconfigure-all/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ dependencies {
128128
optional("org.elasticsearch.client:elasticsearch-rest-client-sniffer") {
129129
exclude group: "commons-logging", module: "commons-logging"
130130
}
131-
optional("org.freemarker:freemarker")
132131
optional("org.glassfish.jersey.containers:jersey-container-servlet-core")
133132
optional("org.glassfish.jersey.containers:jersey-container-servlet")
134133
optional("org.glassfish.jersey.core:jersey-server")
@@ -234,6 +233,7 @@ dependencies {
234233
optional("org.thymeleaf.extras:thymeleaf-extras-springsecurity6")
235234
optional("redis.clients:jedis")
236235

236+
testImplementation(project(":spring-boot-project:spring-boot-freemarker"))
237237
testImplementation(project(":spring-boot-project:spring-boot-jetty"))
238238
testImplementation(project(":spring-boot-project:spring-boot-test"))
239239
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))

spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/additional-spring-configuration-metadata.json

-36
Original file line numberDiff line numberDiff line change
@@ -845,42 +845,6 @@
845845
"reason": "Reactive Elasticsearch client no longer uses WebClient."
846846
}
847847
},
848-
{
849-
"name": "spring.freemarker.allow-request-override",
850-
"description": "Whether HttpServletRequest attributes are allowed to override (hide) controller generated model attributes of the same name. Only supported with Spring MVC."
851-
},
852-
{
853-
"name": "spring.freemarker.allow-session-override",
854-
"description": "Whether HttpSession attributes are allowed to override (hide) controller generated model attributes of the same name. Only supported with Spring MVC."
855-
},
856-
{
857-
"name": "spring.freemarker.cache",
858-
"description": "Whether to enable template caching. Only supported with Spring MVC."
859-
},
860-
{
861-
"name": "spring.freemarker.content-type",
862-
"description": "Content-Type value. Only supported with Spring MVC."
863-
},
864-
{
865-
"name": "spring.freemarker.expose-request-attributes",
866-
"description": "Whether all request attributes should be added to the model prior to merging with the template. Only supported with Spring MVC."
867-
},
868-
{
869-
"name": "spring.freemarker.expose-session-attributes",
870-
"description": "Whether all HttpSession attributes should be added to the model prior to merging with the template. Only supported with Spring MVC."
871-
},
872-
{
873-
"name": "spring.freemarker.expose-spring-macro-helpers",
874-
"description": "Whether to expose a RequestContext for use by Spring's macro library, under the name \"springMacroRequestContext\". Only supported with Spring MVC."
875-
},
876-
{
877-
"name": "spring.freemarker.prefix",
878-
"defaultValue": ""
879-
},
880-
{
881-
"name": "spring.freemarker.suffix",
882-
"defaultValue": ".ftlh"
883-
},
884848
{
885849
"name": "spring.graphql.schema.file-extensions",
886850
"defaultValue": ".graphqls,.gqls"

spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring.factories

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ org.springframework.boot.autoconfigure.r2dbc.NoConnectionFactoryBeanFailureAnaly
1818

1919
# Template Availability Providers
2020
org.springframework.boot.autoconfigure.template.TemplateAvailabilityProvider=\
21-
org.springframework.boot.autoconfigure.freemarker.FreeMarkerTemplateAvailabilityProvider,\
2221
org.springframework.boot.autoconfigure.mustache.MustacheTemplateAvailabilityProvider,\
2322
org.springframework.boot.autoconfigure.thymeleaf.ThymeleafTemplateAvailabilityProvider,\
2423
org.springframework.boot.autoconfigure.web.servlet.JspTemplateAvailabilityProvider

spring-boot-project/spring-boot-autoconfigure-all/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ org.springframework.boot.autoconfigure.data.web.SpringDataWebAutoConfiguration
3636
org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchClientAutoConfiguration
3737
org.springframework.boot.autoconfigure.elasticsearch.ElasticsearchRestClientAutoConfiguration
3838
org.springframework.boot.autoconfigure.elasticsearch.ReactiveElasticsearchClientAutoConfiguration
39-
org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration
4039
org.springframework.boot.autoconfigure.graphql.GraphQlAutoConfiguration
4140
org.springframework.boot.autoconfigure.graphql.data.GraphQlReactiveQueryByExampleAutoConfiguration
4241
org.springframework.boot.autoconfigure.graphql.data.GraphQlReactiveQuerydslAutoConfiguration

spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/web/servlet/error/BasicErrorControllerIntegrationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,11 @@
3939
import org.springframework.boot.SpringApplication;
4040
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
4141
import org.springframework.boot.autoconfigure.context.PropertyPlaceholderAutoConfiguration;
42-
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
4342
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration;
4443
import org.springframework.boot.autoconfigure.web.ServerProperties;
4544
import org.springframework.boot.autoconfigure.web.servlet.DispatcherServletAutoConfiguration;
4645
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
46+
import org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration;
4747
import org.springframework.boot.test.web.client.TestRestTemplate;
4848
import org.springframework.boot.testsupport.classpath.resources.WithResource;
4949
import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;

spring-boot-project/spring-boot-dependencies/build.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -2031,6 +2031,7 @@ bom {
20312031
"spring-boot-devtools",
20322032
"spring-boot-docker-compose",
20332033
"spring-boot-flyway",
2034+
"spring-boot-freemarker",
20342035
"spring-boot-groovy-templates",
20352036
"spring-boot-jackson",
20362037
"spring-boot-jarmode-tools",

spring-boot-project/spring-boot-devtools/build.gradle

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ dependencies {
5050
optional("org.springframework.data:spring-data-redis")
5151
optional("org.springframework.session:spring-session-core")
5252

53+
testImplementation(project(":spring-boot-project:spring-boot-freemarker"))
5354
testImplementation(project(":spring-boot-project:spring-boot-test"))
5455
testImplementation(project(":spring-boot-project:spring-boot-tomcat"))
5556
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
@@ -68,7 +69,6 @@ dependencies {
6869
testImplementation("org.springframework:spring-websocket")
6970
testImplementation("org.springframework.hateoas:spring-hateoas")
7071
testImplementation("org.springframework.security:spring-security-test")
71-
testImplementation("org.freemarker:freemarker")
7272

7373
testRuntimeOnly("org.aspectj:aspectjweaver")
7474
testRuntimeOnly("org.yaml:snakeyaml")

spring-boot-project/spring-boot-devtools/src/test/java/org/springframework/boot/devtools/autoconfigure/LocalDevToolsAutoConfigurationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
3434
import org.springframework.boot.SpringApplication;
3535
import org.springframework.boot.autoconfigure.ImportAutoConfiguration;
36-
import org.springframework.boot.autoconfigure.freemarker.FreeMarkerAutoConfiguration;
3736
import org.springframework.boot.autoconfigure.web.WebProperties;
3837
import org.springframework.boot.autoconfigure.web.WebProperties.Resources;
3938
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
@@ -43,6 +42,7 @@
4342
import org.springframework.boot.devtools.restart.MockRestartInitializer;
4443
import org.springframework.boot.devtools.restart.MockRestarter;
4544
import org.springframework.boot.devtools.restart.Restarter;
45+
import org.springframework.boot.freemarker.autoconfigure.FreeMarkerAutoConfiguration;
4646
import org.springframework.boot.tomcat.TomcatWebServer;
4747
import org.springframework.boot.tomcat.autoconfigure.servlet.TomcatServletWebServerAutoConfiguration;
4848
import org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext;

spring-boot-project/spring-boot-docs/build.gradle

+2
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ dependencies {
5858
autoConfiguration(project(path: ":spring-boot-project:spring-boot-autoconfigure-all", configuration: "autoConfigurationMetadata"))
5959
autoConfiguration(project(path: ":spring-boot-project:spring-boot-devtools", configuration: "autoConfigurationMetadata"))
6060
autoConfiguration(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "autoConfigurationMetadata"))
61+
autoConfiguration(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "autoConfigurationMetadata"))
6162
autoConfiguration(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "autoConfigurationMetadata"))
6263
autoConfiguration(project(path: ":spring-boot-project:spring-boot-jdbc", configuration: "autoConfigurationMetadata"))
6364
autoConfiguration(project(path: ":spring-boot-project:spring-boot-jetty", configuration: "autoConfigurationMetadata"))
@@ -83,6 +84,7 @@ dependencies {
8384
configurationProperties(project(path: ":spring-boot-project:spring-boot-devtools", configuration: "configurationPropertiesMetadata"))
8485
configurationProperties(project(path: ":spring-boot-project:spring-boot-docker-compose", configuration: "configurationPropertiesMetadata"))
8586
configurationProperties(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "configurationPropertiesMetadata"))
87+
configurationProperties(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "configurationPropertiesMetadata"))
8688
configurationProperties(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "configurationPropertiesMetadata"))
8789
configurationProperties(project(path: ":spring-boot-project:spring-boot-jdbc", configuration: "configurationPropertiesMetadata"))
8890
configurationProperties(project(path: ":spring-boot-project:spring-boot-jetty", configuration: "configurationPropertiesMetadata"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
plugins {
2+
id "java-library"
3+
id "org.springframework.boot.auto-configuration"
4+
id "org.springframework.boot.configuration-properties"
5+
id "org.springframework.boot.deployed"
6+
id "org.springframework.boot.optional-dependencies"
7+
}
8+
9+
description = "Spring Boot Freemarker"
10+
11+
dependencies {
12+
api(project(":spring-boot-project:spring-boot"))
13+
api("org.freemarker:freemarker")
14+
api("org.springframework:spring-context-support")
15+
16+
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
17+
optional("org.springframework:spring-webmvc")
18+
optional("org.springframework:spring-webflux")
19+
optional("jakarta.servlet:jakarta.servlet-api")
20+
21+
testImplementation(project(":spring-boot-project:spring-boot-test"))
22+
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
23+
24+
testRuntimeOnly("ch.qos.logback:logback-classic")
25+
}
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.freemarker;
17+
package org.springframework.boot.freemarker.autoconfigure;
1818

1919
import java.util.HashMap;
2020
import java.util.List;
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.freemarker;
17+
package org.springframework.boot.freemarker.autoconfigure;
1818

1919
import java.util.ArrayList;
2020
import java.util.List;
@@ -37,7 +37,7 @@
3737
* @author Andy Wilkinson
3838
* @author Dave Syer
3939
* @author Kazuki Shimizu
40-
* @since 1.1.0
40+
* @since 4.0.0
4141
*/
4242
@AutoConfiguration
4343
@ConditionalOnClass({ freemarker.template.Configuration.class, FreeMarkerConfigurationFactory.class })
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.freemarker;
17+
package org.springframework.boot.freemarker.autoconfigure;
1818

1919
import org.springframework.beans.factory.ObjectProvider;
2020
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.freemarker;
17+
package org.springframework.boot.freemarker.autoconfigure;
1818

1919
import java.nio.charset.Charset;
2020
import java.nio.charset.StandardCharsets;
@@ -33,7 +33,7 @@
3333
*
3434
* @author Dave Syer
3535
* @author Andy Wilkinson
36-
* @since 1.1.0
36+
* @since 4.0.0
3737
*/
3838
@ConfigurationProperties("spring.freemarker")
3939
public class FreeMarkerProperties {
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,14 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.freemarker;
17+
package org.springframework.boot.freemarker.autoconfigure;
1818

1919
import org.springframework.beans.factory.ObjectProvider;
2020
import org.springframework.boot.autoconfigure.AutoConfigureAfter;
2121
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
22+
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
2223
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
2324
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
24-
import org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration;
2525
import org.springframework.context.annotation.Bean;
2626
import org.springframework.context.annotation.Configuration;
2727
import org.springframework.web.reactive.result.view.freemarker.FreeMarkerConfig;
@@ -36,7 +36,8 @@
3636
*/
3737
@Configuration(proxyBeanMethods = false)
3838
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.REACTIVE)
39-
@AutoConfigureAfter(WebFluxAutoConfiguration.class)
39+
@ConditionalOnClass(FreeMarkerConfigurer.class)
40+
@AutoConfigureAfter(name = "org.springframework.boot.autoconfigure.web.reactive.WebFluxAutoConfiguration")
4041
class FreeMarkerReactiveWebConfiguration extends AbstractFreeMarkerConfiguration {
4142

4243
FreeMarkerReactiveWebConfiguration(FreeMarkerProperties properties,
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.freemarker;
17+
package org.springframework.boot.freemarker.autoconfigure;
1818

1919
import jakarta.servlet.DispatcherType;
2020
import jakarta.servlet.Servlet;
@@ -27,7 +27,6 @@
2727
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingFilterBean;
2828
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
2929
import org.springframework.boot.autoconfigure.web.ConditionalOnEnabledResourceChain;
30-
import org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration;
3130
import org.springframework.boot.web.servlet.FilterRegistrationBean;
3231
import org.springframework.context.annotation.Bean;
3332
import org.springframework.context.annotation.Configuration;
@@ -45,7 +44,7 @@
4544
@Configuration(proxyBeanMethods = false)
4645
@ConditionalOnWebApplication(type = ConditionalOnWebApplication.Type.SERVLET)
4746
@ConditionalOnClass({ Servlet.class, FreeMarkerConfigurer.class })
48-
@AutoConfigureAfter(WebMvcAutoConfiguration.class)
47+
@AutoConfigureAfter(name = "org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration")
4948
class FreeMarkerServletWebConfiguration extends AbstractFreeMarkerConfiguration {
5049

5150
protected FreeMarkerServletWebConfiguration(FreeMarkerProperties properties,
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.freemarker;
17+
package org.springframework.boot.freemarker.autoconfigure;
1818

1919
import java.util.ArrayList;
2020
import java.util.Arrays;
@@ -32,7 +32,7 @@
3232
* FreeMarker view templates.
3333
*
3434
* @author Andy Wilkinson
35-
* @since 1.1.0
35+
* @since 4.0.0
3636
*/
3737
public class FreeMarkerTemplateAvailabilityProvider extends PathBasedTemplateAvailabilityProvider {
3838

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2024 the original author or authors.
2+
* Copyright 2012-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -14,7 +14,7 @@
1414
* limitations under the License.
1515
*/
1616

17-
package org.springframework.boot.autoconfigure.freemarker;
17+
package org.springframework.boot.freemarker.autoconfigure;
1818

1919
import java.util.Map;
2020

@@ -28,7 +28,7 @@
2828
* before it is used by an auto-configured {@link FreeMarkerConfigurationFactory}.
2929
*
3030
* @author Stephane Nicoll
31-
* @since 3.4.0
31+
* @since 4.0.0
3232
*/
3333
@FunctionalInterface
3434
public interface FreeMarkerVariablesCustomizer {
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@
1717
/**
1818
* Auto-configuration for FreeMarker.
1919
*/
20-
package org.springframework.boot.autoconfigure.freemarker;
20+
package org.springframework.boot.freemarker.autoconfigure;

0 commit comments

Comments
 (0)