Skip to content

Commit fc938df

Browse files
committed
Add changes note, Fix style
1 parent a7f969c commit fc938df

File tree

4 files changed

+48
-7
lines changed

4 files changed

+48
-7
lines changed

plugin-maven/CHANGES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (
77
## [2.29.0] - 2023-01-02
88
### Added
99
* Added support for M2E's incremental compilation ([#1414](https://github.com/diffplug/spotless/pull/1414) fixes [#1413](https://github.com/diffplug/spotless/issues/1413))
10+
* Add JSON support ([#1446](https://github.com/diffplug/spotless/pull/1446))
1011
### Fixed
1112
* Improve memory usage when using git ratchet ([#1426](https://github.com/diffplug/spotless/pull/1426))
1213
* Support `ktlint` 0.48+ ([#1432](https://github.com/diffplug/spotless/pull/1432)) fixes ([#1430](https://github.com/diffplug/spotless/issues/1430))

plugin-maven/README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -724,8 +724,8 @@ Uses a JSON pretty-printer that optionally allows configuring the number of spac
724724

725725
```xml
726726
<simple>
727-
<indentSpaces>4</indentSpaces> <!-- optional: specify the number of spaces to use -->
728-
</simple>
727+
<indentSpaces>4</indentSpaces> <!-- optional: specify the number of spaces to use -->
728+
</simple>
729729
```
730730

731731
### Gson
@@ -734,10 +734,10 @@ Uses Google Gson to also allow sorting by keys besides custom indentation - usef
734734

735735
```xml
736736
<gson>
737-
<indentSpaces>4</indentSpaces> <!-- optional: specify the number of spaces to use -->
738-
<sortByKeys>false</sortByKeys> <!-- optional: sort JSON by its keys -->
739-
<escapeHtml>false</indentSpaces> <!-- optional: escape HTML in values -->
740-
<version>2.8.1</version> <!-- optional: specify version -->
737+
<indentSpaces>4</indentSpaces> <!-- optional: specify the number of spaces to use -->
738+
<sortByKeys>false</sortByKeys> <!-- optional: sort JSON by its keys -->
739+
<escapeHtml>false</indentSpaces> <!-- optional: escape HTML in values -->
740+
<version>2.8.1</version> <!-- optional: specify version -->
741741
</gson>
742742
```
743743

plugin-maven/src/main/java/com/diffplug/spotless/maven/json/Json.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
*/
2626
public class Json extends FormatterFactory {
2727
public static final int DEFAULT_INDENTATION = 4;
28-
28+
2929
@Override
3030
public Set<String> defaultIncludes() {
3131
return Collections.emptySet();
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright 2023 DiffPlug
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.diffplug.spotless.maven.json;
17+
18+
import org.junit.jupiter.api.Test;
19+
20+
import com.diffplug.spotless.maven.MavenIntegrationHarness;
21+
22+
public class JsonTest extends MavenIntegrationHarness {
23+
@Test
24+
public void testFormatJson_WithSimple_defaultConfig() throws Exception {
25+
writePomWithPomSteps("<json><simple/></json>");
26+
27+
setFile("json_test.json").toResource("json/json_dirty.json");
28+
mavenRunner().withArguments("spotless:apply").runNoError().error();
29+
assertFile("json_test.json").sameAsResource("json/json_clean_default.json");
30+
}
31+
32+
@Test
33+
public void testFormatJson_WithGson_defaultConfig() throws Exception {
34+
writePomWithPomSteps("<json><gson/></json>");
35+
36+
setFile("json_test.json").toResource("json/json_dirty.json");
37+
mavenRunner().withArguments("spotless:apply").runNoError().error();
38+
assertFile("json_test.json").sameAsResource("json/json_clean_default.json");
39+
}
40+
}

0 commit comments

Comments
 (0)