Skip to content

Commit fed2f4f

Browse files
committed
Create spring-boot-gson module
1 parent bc18b55 commit fed2f4f

File tree

20 files changed

+51
-29
lines changed

20 files changed

+51
-29
lines changed

settings.gradle

+1
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ include "spring-boot-project:spring-boot-elasticsearch"
6262
include "spring-boot-project:spring-boot-flyway"
6363
include "spring-boot-project:spring-boot-freemarker"
6464
include "spring-boot-project:spring-boot-groovy-templates"
65+
include "spring-boot-project:spring-boot-gson"
6566
include "spring-boot-project:spring-boot-hazelcast"
6667
include "spring-boot-project:spring-boot-integration"
6768
include "spring-boot-project:spring-boot-jackson"

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ dependencies {
6969
optional("com.fasterxml.jackson.datatype:jackson-datatype-jsr310")
7070
optional("com.fasterxml.jackson.module:jackson-module-jakarta-xmlbind-annotations")
7171
optional("com.fasterxml.jackson.module:jackson-module-parameter-names")
72-
optional("com.google.code.gson:gson")
7372
optional("com.hazelcast:hazelcast-spring")
7473
optional("com.h2database:h2")
7574
optional("com.nimbusds:oauth2-oidc-sdk")
@@ -218,6 +217,7 @@ dependencies {
218217
optional("redis.clients:jedis")
219218

220219
testImplementation(project(":spring-boot-project:spring-boot-freemarker"))
220+
testImplementation(project(":spring-boot-project:spring-boot-gson"))
221221
testImplementation(project(":spring-boot-project:spring-boot-jetty"))
222222
testImplementation(project(":spring-boot-project:spring-boot-test"))
223223
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))

spring-boot-project/spring-boot-autoconfigure-all/src/main/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfiguration.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
2727
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication.Type;
2828
import org.springframework.boot.autoconfigure.condition.NoneNestedConditions;
29-
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
3029
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration.HttpMessageConvertersAutoConfigurationRuntimeHints;
3130
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration.NotReactiveWebApplicationCondition;
3231
import org.springframework.boot.context.properties.bind.BindableRuntimeHintsRegistrar;
@@ -55,9 +54,9 @@
5554
* @author Eddú Meléndez
5655
* @since 2.0.0
5756
*/
58-
@AutoConfiguration(after = { GsonAutoConfiguration.class },
59-
afterName = { "org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration",
60-
"org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration" })
57+
@AutoConfiguration(afterName = { "org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration",
58+
"org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration",
59+
"org.springframework.boot.gson.autoconfigure.GsonAutoConfiguration" })
6160
@ConditionalOnClass(HttpMessageConverter.class)
6261
@Conditional(NotReactiveWebApplicationCondition.class)
6362
@Import({ JacksonHttpMessageConvertersConfiguration.class, GsonHttpMessageConvertersConfiguration.class,

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
@@ -39,7 +39,6 @@ org.springframework.boot.autoconfigure.graphql.rsocket.RSocketGraphQlClientAutoC
3939
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebFluxSecurityAutoConfiguration
4040
org.springframework.boot.autoconfigure.graphql.security.GraphQlWebMvcSecurityAutoConfiguration
4141
org.springframework.boot.autoconfigure.graphql.servlet.GraphQlWebMvcAutoConfiguration
42-
org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration
4342
org.springframework.boot.autoconfigure.h2.H2ConsoleAutoConfiguration
4443
org.springframework.boot.autoconfigure.hateoas.HypermediaAutoConfiguration
4544
org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration

spring-boot-project/spring-boot-autoconfigure-all/src/test/java/org/springframework/boot/autoconfigure/http/HttpMessageConvertersAutoConfigurationTests.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@
2727
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
2828
import org.springframework.beans.factory.config.BeanDefinition;
2929
import org.springframework.boot.autoconfigure.AutoConfigurations;
30-
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
3130
import org.springframework.boot.autoconfigure.http.HttpMessageConvertersAutoConfiguration.HttpMessageConvertersAutoConfigurationRuntimeHints;
3231
import org.springframework.boot.autoconfigure.http.JacksonHttpMessageConvertersConfiguration.MappingJackson2HttpMessageConverterConfiguration;
3332
import org.springframework.boot.autoconfigure.web.ServerProperties;
33+
import org.springframework.boot.gson.autoconfigure.GsonAutoConfiguration;
3434
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
3535
import org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration;
3636
import org.springframework.boot.test.context.FilteredClassLoader;

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

+1
Original file line numberDiff line numberDiff line change
@@ -2039,6 +2039,7 @@ bom {
20392039
"spring-boot-flyway",
20402040
"spring-boot-freemarker",
20412041
"spring-boot-groovy-templates",
2042+
"spring-boot-gson",
20422043
"spring-boot-hazelcast",
20432044
"spring-boot-integration",
20442045
"spring-boot-jackson",

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

+2
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ dependencies {
6565
autoConfiguration(project(path: ":spring-boot-project:spring-boot-elasticsearch", configuration: "autoConfigurationMetadata"))
6666
autoConfiguration(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "autoConfigurationMetadata"))
6767
autoConfiguration(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "autoConfigurationMetadata"))
68+
autoConfiguration(project(path: ":spring-boot-project:spring-boot-gson", configuration: "autoConfigurationMetadata"))
6869
autoConfiguration(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "autoConfigurationMetadata"))
6970
autoConfiguration(project(path: ":spring-boot-project:spring-boot-integration", configuration: "autoConfigurationMetadata"))
7071
autoConfiguration(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "autoConfigurationMetadata"))
@@ -111,6 +112,7 @@ dependencies {
111112
configurationProperties(project(path: ":spring-boot-project:spring-boot-elasticsearch", configuration: "configurationPropertiesMetadata"))
112113
configurationProperties(project(path: ":spring-boot-project:spring-boot-flyway", configuration: "configurationPropertiesMetadata"))
113114
configurationProperties(project(path: ":spring-boot-project:spring-boot-freemarker", configuration: "configurationPropertiesMetadata"))
115+
configurationProperties(project(path: ":spring-boot-project:spring-boot-gson", configuration: "configurationPropertiesMetadata"))
114116
configurationProperties(project(path: ":spring-boot-project:spring-boot-hazelcast", configuration: "configurationPropertiesMetadata"))
115117
configurationProperties(project(path: ":spring-boot-project:spring-boot-integration", configuration: "configurationPropertiesMetadata"))
116118
configurationProperties(project(path: ":spring-boot-project:spring-boot-jackson", configuration: "configurationPropertiesMetadata"))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 GSON"
10+
11+
dependencies {
12+
api(project(":spring-boot-project:spring-boot"))
13+
api("com.google.code.gson:gson")
14+
15+
optional(project(":spring-boot-project:spring-boot-autoconfigure"))
16+
17+
testImplementation(project(":spring-boot-project:spring-boot-test"))
18+
testImplementation(project(":spring-boot-project:spring-boot-tools:spring-boot-test-support"))
19+
20+
testRuntimeOnly("ch.qos.logback:logback-classic")
21+
}
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.gson;
17+
package org.springframework.boot.gson.autoconfigure;
1818

1919
import java.util.List;
2020
import java.util.function.Consumer;
@@ -38,7 +38,7 @@
3838
*
3939
* @author David Liu
4040
* @author Ivan Golovko
41-
* @since 1.2.0
41+
* @since 4.0.0
4242
*/
4343
@AutoConfiguration
4444
@ConditionalOnClass(Gson.class)
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2023 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.gson;
17+
package org.springframework.boot.gson.autoconfigure;
1818

1919
import com.google.gson.Gson;
2020
import com.google.gson.GsonBuilder;
@@ -24,7 +24,7 @@
2424
* {@link Gson} through {@link GsonBuilder} retaining its default auto-configuration.
2525
*
2626
* @author Ivan Golovko
27-
* @since 2.0.0
27+
* @since 4.0.0
2828
*/
2929
@FunctionalInterface
3030
public interface GsonBuilderCustomizer {
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.gson;
17+
package org.springframework.boot.gson.autoconfigure;
1818

1919
import com.google.gson.FieldNamingPolicy;
2020
import com.google.gson.Gson;
@@ -27,7 +27,7 @@
2727
* Configuration properties to configure {@link Gson}.
2828
*
2929
* @author Ivan Golovko
30-
* @since 2.0.0
30+
* @since 4.0.0
3131
*/
3232
@ConfigurationProperties("spring.gson")
3333
public class GsonProperties {
@@ -193,8 +193,6 @@ public void setDateFormat(String dateFormat) {
193193
* Enumeration of levels of strictness. Values are the same as those on
194194
* {@link com.google.gson.Strictness} that was introduced in Gson 2.11. To maximize
195195
* backwards compatibility, the Gson enum is not used directly.
196-
*
197-
* @since 3.4.2
198196
*/
199197
public enum Strictness {
200198

Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2019 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.
@@ -17,4 +17,4 @@
1717
/**
1818
* Auto-configuration for GSON.
1919
*/
20-
package org.springframework.boot.autoconfigure.gson;
20+
package org.springframework.boot.gson.autoconfigure;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
org.springframework.boot.gson.autoconfigure.GsonAutoConfiguration
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.gson;
17+
package org.springframework.boot.gson.autoconfigure;
1818

1919
import com.google.gson.Gson;
2020
import org.junit.jupiter.api.Test;
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.gson;
17+
package org.springframework.boot.gson.autoconfigure;
1818

1919
import java.time.ZoneId;
2020
import java.time.ZonedDateTime;
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.gson;
17+
package org.springframework.boot.gson.autoconfigure;
1818

1919
import java.util.List;
2020
import java.util.stream.Stream;

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

+1
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ dependencies {
105105
testImplementation(project(":spring-boot-project:spring-boot-actuator"))
106106
testImplementation(project(":spring-boot-project:spring-boot-actuator-autoconfigure"))
107107
testImplementation(project(":spring-boot-project:spring-boot-freemarker"))
108+
testImplementation(project(":spring-boot-project:spring-boot-gson"))
108109
testImplementation(project(":spring-boot-project:spring-boot-mustache"))
109110
testImplementation(project(":spring-boot-project:spring-boot-testcontainers"))
110111
testImplementation(project(":spring-boot-project:spring-boot-thymeleaf"))

spring-boot-project/spring-boot-test-autoconfigure/src/main/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfiguration.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
3939
import org.springframework.boot.autoconfigure.condition.ConditionalOnBooleanProperty;
4040
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
41-
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
4241
import org.springframework.boot.test.json.AbstractJsonMarshalTester;
4342
import org.springframework.boot.test.json.BasicJsonTester;
4443
import org.springframework.boot.test.json.GsonTester;
@@ -60,9 +59,9 @@
6059
* @since 1.4.0
6160
* @see AutoConfigureJsonTesters
6261
*/
63-
@AutoConfiguration(after = { GsonAutoConfiguration.class },
64-
afterName = { "org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration",
65-
"org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration" })
62+
@AutoConfiguration(afterName = { "org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration",
63+
"org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration",
64+
"org.springframework.boot.gson.autoconfigure.GsonAutoConfiguration" })
6665
@ConditionalOnClass(name = "org.assertj.core.api.Assert")
6766
@ConditionalOnBooleanProperty("spring.test.jsontesters.enabled")
6867
public class JsonTestersAutoConfiguration {
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
# AutoConfigureJson auto-configuration imports
2-
org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration
2+
optional:org.springframework.boot.gson.autoconfigure.GsonAutoConfiguration
33
org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration
44
optional:org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration

spring-boot-project/spring-boot-test-autoconfigure/src/test/java/org/springframework/boot/test/autoconfigure/json/JsonTestersAutoConfigurationTests.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2012-2022 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.
@@ -24,7 +24,7 @@
2424
import org.springframework.aot.hint.predicate.ReflectionHintsPredicates;
2525
import org.springframework.aot.hint.predicate.RuntimeHintsPredicates;
2626
import org.springframework.aot.test.generate.TestGenerationContext;
27-
import org.springframework.boot.autoconfigure.gson.GsonAutoConfiguration;
27+
import org.springframework.boot.gson.autoconfigure.GsonAutoConfiguration;
2828
import org.springframework.boot.jackson.autoconfigure.JacksonAutoConfiguration;
2929
import org.springframework.boot.jsonb.autoconfigure.JsonbAutoConfiguration;
3030
import org.springframework.boot.test.json.BasicJsonTester;

0 commit comments

Comments
 (0)