Skip to content

Commit 3ef5c76

Browse files
committed
Upgrade to Jackson 3.0
1 parent 134b7ba commit 3ef5c76

File tree

19 files changed

+81
-137
lines changed

19 files changed

+81
-137
lines changed

gradle-palantir-java-format/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ dependencies {
2525
testImplementation project(':palantir-java-format')
2626
testImplementation 'org.junit.jupiter:junit-jupiter'
2727
testImplementation 'org.assertj:assertj-core'
28-
testImplementation 'com.fasterxml.jackson.dataformat:jackson-dataformat-xml'
28+
testImplementation 'tools.jackson.dataformat:jackson-dataformat-xml'
2929

3030
testRuntimeOnly 'org.junit.vintage:junit-vintage-engine'
3131

gradle-palantir-java-format/src/test/java/com/palantir/javaformat/gradle/PalantirJavaFormatIdeaPluginTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,6 @@
1919
import static org.assertj.core.api.Assertions.assertThat;
2020

2121
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
22-
import com.fasterxml.jackson.databind.ObjectMapper;
23-
import com.fasterxml.jackson.dataformat.xml.XmlMapper;
24-
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
25-
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
2622
import com.palantir.gradle.testing.execution.GradleInvoker;
2723
import com.palantir.gradle.testing.files.arbitrary.ArbitraryFile;
2824
import com.palantir.gradle.testing.junit.DisabledConfigurationCache;
@@ -34,6 +30,10 @@
3430
import java.util.Optional;
3531
import org.junit.jupiter.params.ParameterizedTest;
3632
import org.junit.jupiter.params.provider.ValueSource;
33+
import tools.jackson.databind.ObjectMapper;
34+
import tools.jackson.dataformat.xml.XmlMapper;
35+
import tools.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
36+
import tools.jackson.dataformat.xml.annotation.JacksonXmlProperty;
3737

3838
@GradlePluginTests
3939
@DisabledConfigurationCache

idea-plugin/build.gradle

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ dependencies {
6363
}
6464
implementation 'com.palantir.gradle.utils:platform'
6565

66+
// Avoids use of older jackson-annotations brought in by IntelliJ that is
67+
// incompaitble with Jackson 3.0.
68+
implementation 'com.fasterxml.jackson.core:jackson-annotations'
69+
6670
formatter project(':palantir-java-format')
6771

6872
testImplementation 'org.assertj:assertj-core'

palantir-java-format-jdk-bootstrap/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ dependencies {
1313

1414
api project(':palantir-java-format-spi')
1515
compileOnly 'org.immutables:value::annotations'
16-
implementation 'com.fasterxml.jackson.core:jackson-databind'
16+
implementation 'tools.jackson.core:jackson-databind'
1717

1818
// So that we have pjf on our test classpath
1919
testImplementation project(':palantir-java-format')
2020
testImplementation 'org.junit.jupiter:junit-jupiter'
2121
testImplementation 'org.assertj:assertj-core'
22-
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
22+
testImplementation 'tools.jackson.core:jackson-databind'
2323
formatterNativeImage(project(':palantir-java-format-native')) {
2424
attributes {
2525
attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, project.objects.named(LibraryElements, 'nativeImage'))

palantir-java-format-jdk-bootstrap/src/main/java/com/palantir/javaformat/bootstrap/BootstrappingFormatterService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
package com.palantir.javaformat.bootstrap;
1818

19-
import com.fasterxml.jackson.core.type.TypeReference;
20-
import com.fasterxml.jackson.databind.ObjectMapper;
21-
import com.fasterxml.jackson.databind.json.JsonMapper;
22-
import com.fasterxml.jackson.datatype.guava.GuavaModule;
2319
import com.google.common.base.Joiner;
2420
import com.google.common.collect.ImmutableList;
2521
import com.google.common.collect.Range;
@@ -34,6 +30,10 @@
3430
import java.util.Optional;
3531
import java.util.stream.Collectors;
3632
import org.immutables.value.Value;
33+
import tools.jackson.core.type.TypeReference;
34+
import tools.jackson.databind.ObjectMapper;
35+
import tools.jackson.databind.json.JsonMapper;
36+
import tools.jackson.datatype.guava.GuavaModule;
3737

3838
public final class BootstrappingFormatterService implements FormatterService {
3939
private static final ObjectMapper MAPPER =

palantir-java-format-jdk-bootstrap/src/main/java/com/palantir/javaformat/bootstrap/NativeImageFormatterService.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616

1717
package com.palantir.javaformat.bootstrap;
1818

19-
import com.fasterxml.jackson.core.type.TypeReference;
20-
import com.fasterxml.jackson.databind.ObjectMapper;
21-
import com.fasterxml.jackson.databind.json.JsonMapper;
22-
import com.fasterxml.jackson.datatype.guava.GuavaModule;
2319
import com.google.common.base.Joiner;
2420
import com.google.common.collect.ImmutableList;
2521
import com.google.common.collect.Range;
@@ -33,6 +29,10 @@
3329
import java.util.Optional;
3430
import java.util.stream.Collectors;
3531
import org.immutables.value.Value;
32+
import tools.jackson.core.type.TypeReference;
33+
import tools.jackson.databind.ObjectMapper;
34+
import tools.jackson.databind.json.JsonMapper;
35+
import tools.jackson.datatype.guava.GuavaModule;
3636

3737
public class NativeImageFormatterService implements FormatterService {
3838
private static final ObjectMapper MAPPER =

palantir-java-format-native/src/main/resources/META-INF/native-image/reachability-metadata.json

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,7 @@
11
{
22
"reflection": [
33
{
4-
"type": "[Lcom.fasterxml.jackson.databind.deser.Deserializers;"
5-
},
6-
{
7-
"type": "[Lcom.fasterxml.jackson.databind.ser.BeanSerializerModifier;"
8-
},
9-
{
10-
"type": "[Lcom.fasterxml.jackson.databind.ser.Serializers;"
11-
},
12-
{
13-
"type": "[Ljava.lang.Object;"
14-
},
15-
{
16-
"type": "com.fasterxml.jackson.databind.ext.Java7SupportImpl",
17-
"methods": [
18-
{
19-
"name": "<init>",
20-
"parameterTypes": []
21-
}
22-
]
23-
},
24-
{
25-
"type": "com.fasterxml.jackson.datatype.guava.deser.util.RangeHelper$RangeProperties",
4+
"type": "tools.jackson.datatype.guava.deser.util.RangeHelper$RangeProperties",
265
"fields": [
276
{
287
"name": "lowerBoundType"
@@ -204,4 +183,4 @@
204183
]
205184
}
206185
]
207-
}
186+
}

palantir-java-format-spi/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ apply plugin: 'com.palantir.external-publish-jar'
55
dependencies {
66
api 'com.google.guava:guava'
77
api 'com.fasterxml.jackson.core:jackson-annotations'
8-
api 'com.fasterxml.jackson.datatype:jackson-datatype-guava'
8+
api 'tools.jackson.datatype:jackson-datatype-guava'
99

1010
testImplementation 'org.assertj:assertj-core'
1111
testImplementation 'org.junit.jupiter:junit-jupiter'
12-
testImplementation 'com.fasterxml.jackson.core:jackson-databind'
12+
testImplementation 'tools.jackson.core:jackson-databind'
1313
}
1414

1515
tasks.withType(JavaCompile).named('compileJava') {

palantir-java-format/build.gradle

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ dependencies {
99
api project(':palantir-java-format-spi')
1010
api 'com.google.guava:guava'
1111
implementation 'org.functionaljava:functionaljava'
12-
implementation 'com.fasterxml.jackson.core:jackson-core'
13-
implementation 'com.fasterxml.jackson.core:jackson-databind'
14-
implementation 'com.fasterxml.jackson.datatype:jackson-datatype-jdk8'
15-
implementation 'com.fasterxml.jackson.module:jackson-module-parameter-names'
12+
implementation 'tools.jackson.core:jackson-core'
13+
implementation 'tools.jackson.core:jackson-databind'
1614

1715
testImplementation 'com.google.guava:guava-testlib'
1816
testImplementation 'com.google.testing.compile:compile-testing'

palantir-java-format/src/main/java/com/palantir/javaformat/BreakBehaviour.java

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,15 @@
1515
*/
1616
package com.palantir.javaformat;
1717

18-
import com.fasterxml.jackson.core.JsonGenerator;
19-
import com.fasterxml.jackson.databind.JsonSerializer;
20-
import com.fasterxml.jackson.databind.SerializerProvider;
21-
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
2218
import com.google.errorprone.annotations.Immutable;
2319
import com.palantir.javaformat.doc.Doc;
2420
import com.palantir.javaformat.doc.Level;
25-
import java.io.IOException;
26-
import java.io.UncheckedIOException;
2721
import org.derive4j.ArgOption;
2822
import org.derive4j.Data;
23+
import tools.jackson.core.JsonGenerator;
24+
import tools.jackson.databind.SerializationContext;
25+
import tools.jackson.databind.ValueSerializer;
26+
import tools.jackson.databind.annotation.JsonSerialize;
2927

3028
@Data(arguments = ArgOption.checkedNotNull)
3129
@Immutable
@@ -72,45 +70,28 @@ public interface Cases<R> {
7270
* This is gross but just wanted to get something working. See https://github.com/derive4j/derive4j/issues/51 for a
7371
* potential better implementation.
7472
*/
75-
static class Json extends JsonSerializer<BreakBehaviour> {
73+
static class Json extends ValueSerializer<BreakBehaviour> {
7674

7775
@Override
78-
public void serialize(BreakBehaviour value, JsonGenerator gen, SerializerProvider serializers)
79-
throws IOException {
76+
public void serialize(BreakBehaviour value, JsonGenerator gen, SerializationContext serializers) {
8077
gen.writeStartObject();
8178
BreakBehaviours.caseOf(value)
8279
.breakThisLevel(() -> {
83-
try {
84-
gen.writeObjectField("type", "breakThisLevel");
85-
} catch (IOException e) {
86-
throw new UncheckedIOException(e);
87-
}
80+
gen.writeStringProperty("type", "breakThisLevel");
8881
return null;
8982
})
9083
.preferBreakingLastInnerLevel(keepIndentWhenInlined -> {
91-
try {
92-
gen.writeObjectField("type", "preferBreakingLastInnerLevel");
93-
gen.writeObjectField("keepIndentWhenInlined", keepIndentWhenInlined);
94-
} catch (IOException e) {
95-
throw new UncheckedIOException(e);
96-
}
84+
gen.writeStringProperty("type", "preferBreakingLastInnerLevel");
85+
gen.writeBooleanProperty("keepIndentWhenInlined", keepIndentWhenInlined);
9786
return null;
9887
})
9988
.inlineSuffix(() -> {
100-
try {
101-
gen.writeObjectField("type", "inlineSuffix");
102-
} catch (IOException e) {
103-
throw new UncheckedIOException(e);
104-
}
89+
gen.writeStringProperty("type", "inlineSuffix");
10590
return null;
10691
})
10792
.breakOnlyIfInnerLevelsThenFitOnOneLine(keepIndentWhenInlined -> {
108-
try {
109-
gen.writeObjectField("type", "breakOnlyIfInnerLevelsThenFitOnOneLine");
110-
gen.writeObjectField("keepIndentWhenInlined", keepIndentWhenInlined);
111-
} catch (IOException e) {
112-
throw new UncheckedIOException(e);
113-
}
93+
gen.writeStringProperty("type", "breakOnlyIfInnerLevelsThenFitOnOneLine");
94+
gen.writeBooleanProperty("keepIndentWhenInlined", keepIndentWhenInlined);
11495
return null;
11596
});
11697
gen.writeEndObject();

0 commit comments

Comments
 (0)