From b70b6ee67ce7772be6729bce8d51143bdceb8c54 Mon Sep 17 00:00:00 2001 From: mokamoto12 Date: Wed, 30 Aug 2023 14:05:02 +0900 Subject: [PATCH 1/4] Support google-java-format's skip-javadoc-formatting option Add configuration option to switch the option of the googleJavaFormat step. Default to format javadoc for backwards compatibility. Fixes https://github.com/diffplug/spotless/issues/1287 --- .../java/GoogleJavaFormatFormatterFunc.java | 10 ++++--- .../spotless/java/GoogleJavaFormatStep.java | 21 ++++++++++----- .../gradle/spotless/JavaExtension.java | 14 +++++++++- .../GoogleJavaFormatIntegrationTest.java | 26 +++++++++++++++++++ .../spotless/maven/java/GoogleJavaFormat.java | 6 ++++- .../maven/java/GoogleJavaFormatTest.java | 11 ++++++++ .../googlejavaformat/JavaCodeFormatted.test | 1 + .../googlejavaformat/JavaCodeFormatted18.test | 1 + .../JavaCodeFormattedAOSP.test | 1 + .../JavaCodeFormattedReflowLongStrings.test | 1 + ...avaCodeFormattedSkipJavadocFormatting.test | 14 ++++++++++ .../googlejavaformat/JavaCodeUnformatted.test | 3 +++ .../java/GoogleJavaFormatStepTest.java | 10 +++++++ 13 files changed, 106 insertions(+), 13 deletions(-) create mode 100644 testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedSkipJavadocFormatting.test diff --git a/lib/src/googleJavaFormat/java/com/diffplug/spotless/glue/java/GoogleJavaFormatFormatterFunc.java b/lib/src/googleJavaFormat/java/com/diffplug/spotless/glue/java/GoogleJavaFormatFormatterFunc.java index 8c6aa42575..d13f8d9d40 100644 --- a/lib/src/googleJavaFormat/java/com/diffplug/spotless/glue/java/GoogleJavaFormatFormatterFunc.java +++ b/lib/src/googleJavaFormat/java/com/diffplug/spotless/glue/java/GoogleJavaFormatFormatterFunc.java @@ -46,15 +46,17 @@ public class GoogleJavaFormatFormatterFunc implements FormatterFunc { private final boolean reorderImports; - public GoogleJavaFormatFormatterFunc(@Nonnull String version, @Nonnull String style, boolean reflowStrings, boolean reorderImports) { + public GoogleJavaFormatFormatterFunc(@Nonnull String version, @Nonnull String style, boolean reflowStrings, boolean reorderImports, boolean formatJavadoc) { this.version = Objects.requireNonNull(version); this.formatterStyle = Style.valueOf(Objects.requireNonNull(style)); this.reflowStrings = reflowStrings; this.reorderImports = reorderImports; - this.formatter = new Formatter(JavaFormatterOptions.builder() - .style(formatterStyle) - .build()); + JavaFormatterOptions.Builder builder = JavaFormatterOptions.builder().style(formatterStyle); + if (!formatJavadoc) { + builder = builder.formatJavadoc(false); + } + this.formatter = new Formatter(builder.build()); } @Override diff --git a/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java b/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java index a0f796af4d..b2424cbe2a 100644 --- a/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java +++ b/lib/src/main/java/com/diffplug/spotless/java/GoogleJavaFormatStep.java @@ -33,6 +33,7 @@ private GoogleJavaFormatStep() {} private static final String DEFAULT_STYLE = "GOOGLE"; private static final boolean DEFAULT_REFLOW_LONG_STRINGS = false; private static final boolean DEFAULT_REORDER_IMPORTS = false; + private static final boolean DEFAULT_FORMAT_JAVADOC = true; static final String NAME = "google-java-format"; static final String MAVEN_COORDINATE = "com.google.googlejavaformat:google-java-format"; @@ -57,11 +58,11 @@ public static FormatterStep create(String version, String style, Provisioner pro } public static FormatterStep create(String groupArtifact, String version, String style, Provisioner provisioner, boolean reflowLongStrings) { - return create(groupArtifact, version, style, provisioner, reflowLongStrings, false); + return create(groupArtifact, version, style, provisioner, reflowLongStrings, false, DEFAULT_FORMAT_JAVADOC); } /** Creates a step which formats everything - groupArtifact, code, import order, and unused imports - and optionally reflows long strings. */ - public static FormatterStep create(String groupArtifact, String version, String style, Provisioner provisioner, boolean reflowLongStrings, boolean reorderImports) { + public static FormatterStep create(String groupArtifact, String version, String style, Provisioner provisioner, boolean reflowLongStrings, boolean reorderImports, boolean formatJavadoc) { Objects.requireNonNull(groupArtifact, "groupArtifact"); if (groupArtifact.chars().filter(ch -> ch == ':').count() != 1) { throw new IllegalArgumentException("groupArtifact must be in the form 'groupId:artifactId'"); @@ -70,7 +71,7 @@ public static FormatterStep create(String groupArtifact, String version, String Objects.requireNonNull(style, "style"); Objects.requireNonNull(provisioner, "provisioner"); return FormatterStep.createLazy(NAME, - () -> new State(NAME, groupArtifact, version, style, provisioner, reflowLongStrings, reorderImports), + () -> new State(NAME, groupArtifact, version, style, provisioner, reflowLongStrings, reorderImports, formatJavadoc), State::createFormat); } @@ -101,6 +102,10 @@ public static boolean defaultReorderImports() { return DEFAULT_REORDER_IMPORTS; } + public static boolean defaultFormatJavadoc() { + return DEFAULT_FORMAT_JAVADOC; + } + static final class State implements Serializable { private static final long serialVersionUID = 1L; @@ -111,6 +116,7 @@ static final class State implements Serializable { final String style; final boolean reflowLongStrings; final boolean reorderImports; + final boolean formatJavadoc; State(String stepName, String version, Provisioner provisioner) throws Exception { this(stepName, version, DEFAULT_STYLE, provisioner); @@ -121,10 +127,10 @@ static final class State implements Serializable { } State(String stepName, String version, String style, Provisioner provisioner, boolean reflowLongStrings) throws Exception { - this(stepName, MAVEN_COORDINATE, version, style, provisioner, reflowLongStrings, DEFAULT_REORDER_IMPORTS); + this(stepName, MAVEN_COORDINATE, version, style, provisioner, reflowLongStrings, DEFAULT_REORDER_IMPORTS, DEFAULT_FORMAT_JAVADOC); } - State(String stepName, String groupArtifact, String version, String style, Provisioner provisioner, boolean reflowLongStrings, boolean reorderImports) throws Exception { + State(String stepName, String groupArtifact, String version, String style, Provisioner provisioner, boolean reflowLongStrings, boolean reorderImports, boolean formatJavadoc) throws Exception { JVM_SUPPORT.assertFormatterSupported(version); ModuleHelper.doOpenInternalPackagesIfRequired(); this.jarState = JarState.from(groupArtifact + ":" + version, provisioner); @@ -133,13 +139,14 @@ static final class State implements Serializable { this.style = style; this.reflowLongStrings = reflowLongStrings; this.reorderImports = reorderImports; + this.formatJavadoc = formatJavadoc; } FormatterFunc createFormat() throws Exception { final ClassLoader classLoader = jarState.getClassLoader(); Class formatterFunc = classLoader.loadClass("com.diffplug.spotless.glue.java.GoogleJavaFormatFormatterFunc"); - Constructor constructor = formatterFunc.getConstructor(String.class, String.class, boolean.class, boolean.class); - FormatterFunc googleJavaFormatFormatterFunc = (FormatterFunc) constructor.newInstance(version, style, reflowLongStrings, reorderImports); + Constructor constructor = formatterFunc.getConstructor(String.class, String.class, boolean.class, boolean.class, boolean.class); + FormatterFunc googleJavaFormatFormatterFunc = (FormatterFunc) constructor.newInstance(version, style, reflowLongStrings, reorderImports, formatJavadoc); return JVM_SUPPORT.suggestLaterVersionOnError(version, googleJavaFormatFormatterFunc); } diff --git a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JavaExtension.java b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JavaExtension.java index fcd1a0d105..c576eb7da8 100644 --- a/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JavaExtension.java +++ b/plugin-gradle/src/main/java/com/diffplug/gradle/spotless/JavaExtension.java @@ -174,6 +174,7 @@ public class GoogleJavaFormatConfig { String style; boolean reflowLongStrings; boolean reorderImports; + boolean formatJavadoc = true; GoogleJavaFormatConfig(String version) { this.version = Objects.requireNonNull(version); @@ -213,6 +214,16 @@ public GoogleJavaFormatConfig reorderImports(boolean reorderImports) { return this; } + public GoogleJavaFormatConfig skipJavadocFormatting() { + return formatJavadoc(false); + } + + public GoogleJavaFormatConfig formatJavadoc(boolean formatJavadoc) { + this.formatJavadoc = formatJavadoc; + replaceStep(createStep()); + return this; + } + private FormatterStep createStep() { return GoogleJavaFormatStep.create( groupArtifact, @@ -220,7 +231,8 @@ private FormatterStep createStep() { style, provisioner(), reflowLongStrings, - reorderImports); + reorderImports, + formatJavadoc); } } diff --git a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GoogleJavaFormatIntegrationTest.java b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GoogleJavaFormatIntegrationTest.java index 5c7fe54f59..42d9f4314a 100644 --- a/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GoogleJavaFormatIntegrationTest.java +++ b/plugin-gradle/src/test/java/com/diffplug/gradle/spotless/GoogleJavaFormatIntegrationTest.java @@ -45,4 +45,30 @@ void integration() throws IOException { "googleJavaFormat()"); checkRunsThenUpToDate(); } + + @Test + void integrationWithSkipJavadocFormatting() throws IOException { + setFile("build.gradle").toLines( + "plugins {", + " id 'com.diffplug.spotless'", + "}", + "repositories { mavenCentral() }", + "", + "spotless {", + " java {", + " target file('test.java')", + " googleJavaFormat('1.12.0').skipJavadocFormatting()", + " }", + "}"); + + setFile("test.java").toResource("java/googlejavaformat/JavaCodeUnformatted.test"); + gradleRunner().withArguments("spotlessApply").build(); + assertFile("test.java").sameAsResource("java/googlejavaformat/JavaCodeFormattedSkipJavadocFormatting.test"); + + checkRunsThenUpToDate(); + replace("build.gradle", + "googleJavaFormat('1.12.0')", + "googleJavaFormat()"); + checkRunsThenUpToDate(); + } } diff --git a/plugin-maven/src/main/java/com/diffplug/spotless/maven/java/GoogleJavaFormat.java b/plugin-maven/src/main/java/com/diffplug/spotless/maven/java/GoogleJavaFormat.java index 98296beb5f..d0a2b24954 100644 --- a/plugin-maven/src/main/java/com/diffplug/spotless/maven/java/GoogleJavaFormat.java +++ b/plugin-maven/src/main/java/com/diffplug/spotless/maven/java/GoogleJavaFormat.java @@ -38,6 +38,9 @@ public class GoogleJavaFormat implements FormatterStepFactory { @Parameter private Boolean reorderImports; + @Parameter + private Boolean formatJavadoc; + @Override public FormatterStep newFormatterStep(FormatterStepConfig config) { String groupArtifact = this.groupArtifact != null ? this.groupArtifact : GoogleJavaFormatStep.defaultGroupArtifact(); @@ -45,6 +48,7 @@ public FormatterStep newFormatterStep(FormatterStepConfig config) { String style = this.style != null ? this.style : GoogleJavaFormatStep.defaultStyle(); boolean reflowLongStrings = this.reflowLongStrings != null ? this.reflowLongStrings : GoogleJavaFormatStep.defaultReflowLongStrings(); boolean reorderImports = this.reorderImports != null ? this.reorderImports : GoogleJavaFormatStep.defaultReorderImports(); - return GoogleJavaFormatStep.create(groupArtifact, version, style, config.getProvisioner(), reflowLongStrings, reorderImports); + boolean formatJavadoc = this.formatJavadoc != null ? this.formatJavadoc : GoogleJavaFormatStep.defaultFormatJavadoc(); + return GoogleJavaFormatStep.create(groupArtifact, version, style, config.getProvisioner(), reflowLongStrings, reorderImports, formatJavadoc); } } diff --git a/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/GoogleJavaFormatTest.java b/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/GoogleJavaFormatTest.java index 407d089999..76b2c40fd3 100644 --- a/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/GoogleJavaFormatTest.java +++ b/plugin-maven/src/test/java/com/diffplug/spotless/maven/java/GoogleJavaFormatTest.java @@ -52,6 +52,17 @@ void specificVersionReflowLongStrings() throws Exception { runTest("java/googlejavaformat/JavaCodeFormattedReflowLongStrings.test"); } + @Test + void specificVersionSkipJavadocFormatting() throws Exception { + writePomWithJavaSteps( + "", + " 1.12.0", + " false", + ""); + + runTest("java/googlejavaformat/JavaCodeFormattedSkipJavadocFormatting.test"); + } + private void runTest(String targetResource) throws Exception { String path = "src/main/java/test.java"; setFile(path).toResource("java/googlejavaformat/JavaCodeUnformatted.test"); diff --git a/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormatted.test b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormatted.test index 7a83a0a12c..a0aeb21d0e 100644 --- a/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormatted.test +++ b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormatted.test @@ -2,6 +2,7 @@ import mylib.UsedA; import mylib.UsedB; public class Java { + /** Some javadoc. */ public static void main(String[] args) { System.out.println( "A very very very very very very very very very very very very very very very very very very very very very long string that goes beyond the 100-character line length."); diff --git a/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormatted18.test b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormatted18.test index 7a83a0a12c..a0aeb21d0e 100644 --- a/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormatted18.test +++ b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormatted18.test @@ -2,6 +2,7 @@ import mylib.UsedA; import mylib.UsedB; public class Java { + /** Some javadoc. */ public static void main(String[] args) { System.out.println( "A very very very very very very very very very very very very very very very very very very very very very long string that goes beyond the 100-character line length."); diff --git a/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedAOSP.test b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedAOSP.test index 25ccbc25f5..6b65d1f897 100644 --- a/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedAOSP.test +++ b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedAOSP.test @@ -2,6 +2,7 @@ import mylib.UsedA; import mylib.UsedB; public class Java { + /** Some javadoc. */ public static void main(String[] args) { System.out.println( "A very very very very very very very very very very very very very very very very very very very very very long string that goes beyond the 100-character line length."); diff --git a/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedReflowLongStrings.test b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedReflowLongStrings.test index 24e91a2ac8..8751e7e2d9 100644 --- a/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedReflowLongStrings.test +++ b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedReflowLongStrings.test @@ -2,6 +2,7 @@ import mylib.UsedA; import mylib.UsedB; public class Java { + /** Some javadoc. */ public static void main(String[] args) { System.out.println( "A very very very very very very very very very very very very very very very very very" diff --git a/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedSkipJavadocFormatting.test b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedSkipJavadocFormatting.test new file mode 100644 index 0000000000..b3d1793729 --- /dev/null +++ b/testlib/src/main/resources/java/googlejavaformat/JavaCodeFormattedSkipJavadocFormatting.test @@ -0,0 +1,14 @@ +import mylib.UsedA; +import mylib.UsedB; + +public class Java { + /** + * Some javadoc. + */ + public static void main(String[] args) { + System.out.println( + "A very very very very very very very very very very very very very very very very very very very very very long string that goes beyond the 100-character line length."); + UsedB.someMethod(); + UsedA.someMethod(); + } +} diff --git a/testlib/src/main/resources/java/googlejavaformat/JavaCodeUnformatted.test b/testlib/src/main/resources/java/googlejavaformat/JavaCodeUnformatted.test index 18f2aca0e2..8e66776be8 100644 --- a/testlib/src/main/resources/java/googlejavaformat/JavaCodeUnformatted.test +++ b/testlib/src/main/resources/java/googlejavaformat/JavaCodeUnformatted.test @@ -4,6 +4,9 @@ import mylib.UsedB; import mylib.UsedA; public class Java { +/** + * Some javadoc. + */ public static void main(String[] args) { System.out.println("A very very very very very very very very very very very very very very very very very very very very very long string that goes beyond the 100-character line length."); UsedB.someMethod(); diff --git a/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java b/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java index 694e390727..df08c483df 100644 --- a/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/java/GoogleJavaFormatStepTest.java @@ -99,6 +99,16 @@ void behaviorWithReflowLongStrings() throws Exception { } } + @Test + void behaviorWithSkipFormatJavadoc() throws Exception { + try (StepHarness step = StepHarness.forStep(GoogleJavaFormatStep.create(GoogleJavaFormatStep.defaultGroupArtifact(), GoogleJavaFormatStep.defaultVersion(), GoogleJavaFormatStep.defaultStyle(), TestProvisioner.mavenCentral(), GoogleJavaFormatStep.defaultReflowLongStrings(), GoogleJavaFormatStep.defaultReorderImports(), false))) { + step.testResource("java/googlejavaformat/JavaCodeUnformatted.test", "java/googlejavaformat/JavaCodeFormattedSkipJavadocFormatting.test") + .testResource("java/googlejavaformat/JavaCodeWithLicenseUnformatted.test", "java/googlejavaformat/JavaCodeWithLicenseFormatted.test") + .testResource("java/googlejavaformat/JavaCodeWithLicensePackageUnformatted.test", "java/googlejavaformat/JavaCodeWithLicensePackageFormatted.test") + .testResource("java/googlejavaformat/JavaCodeWithPackageUnformatted.test", "java/googlejavaformat/JavaCodeWithPackageFormatted.test"); + } + } + @Test void behaviorWithCustomGroupArtifact() throws Exception { FormatterStep step = GoogleJavaFormatStep.create(GoogleJavaFormatStep.defaultGroupArtifact(), "1.10.0", GoogleJavaFormatStep.defaultStyle(), TestProvisioner.mavenCentral(), false); From a045b46c617418db780b719d70450bce3a817393 Mon Sep 17 00:00:00 2001 From: mokamoto12 Date: Wed, 30 Aug 2023 14:22:51 +0900 Subject: [PATCH 2/4] Update CHANGES.md --- CHANGES.md | 1 + plugin-gradle/CHANGES.md | 1 + plugin-maven/CHANGES.md | 1 + 3 files changed, 3 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 12b8609f82..caa8398cc5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -13,6 +13,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Added * Add a `jsonPatch` step to `json` formatter configurations. This allows patching of JSON documents using [JSON Patches](https://jsonpatch.com). ([#1753](https://github.com/diffplug/spotless/pull/1753)) * Support GJF own import order. ([#1780](https://github.com/diffplug/spotless/pull/1780)) +* Added support for `google-java-format`'s `skip-javadoc-formatting` option ([#1793](https://github.com/diffplug/spotless/pull/1793)) ### Fixed * Use latest versions of popular style guides for `eslint` tests to fix failing `useEslintXoStandardRules` test. ([#1761](https://github.com/diffplug/spotless/pull/1761), [#1756](https://github.com/diffplug/spotless/issues/1756)) * Add support for `prettier` version `3.0.0` and newer. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1751](https://github.com/diffplug/spotless/issues/1751)) diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 4d9832ebf5..8c08195359 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -6,6 +6,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Added * Add a `jsonPatch` step to `json` formatter configurations. This allows patching of JSON documents using [JSON Patches](https://jsonpatch.com). ([#1753](https://github.com/diffplug/spotless/pull/1753)) * Support GJF own import order. ([#1780](https://github.com/diffplug/spotless/pull/1780)) +* Added support for `google-java-format`'s `skip-javadoc-formatting` option ([#1793](https://github.com/diffplug/spotless/pull/1793)) ### Fixed * Add support for `prettier` version `3.0.0` and newer. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1751](https://github.com/diffplug/spotless/issues/1751)) * Fix npm install calls when npm cache is not up-to-date. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1750](https://github.com/diffplug/spotless/issues/1750)) diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index 8278e16792..354c287b34 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -6,6 +6,7 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Added * Add a `jsonPatch` step to `json` formatter configurations. This allows patching of JSON documents using [JSON Patches](https://jsonpatch.com). ([#1753](https://github.com/diffplug/spotless/pull/1753)) * Support GJF own import order. ([#1780](https://github.com/diffplug/spotless/pull/1780)) +* Added support for `google-java-format`'s `skip-javadoc-formatting` option ([#1793](https://github.com/diffplug/spotless/pull/1793)) ### Fixed * Add support for `prettier` version `3.0.0` and newer. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1751](https://github.com/diffplug/spotless/issues/1751)) * Fix npm install calls when npm cache is not up-to-date. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1750](https://github.com/diffplug/spotless/issues/1750)) From d74264b425272a8fb037f3ae2cbc137f0a339c31 Mon Sep 17 00:00:00 2001 From: mokamoto12 Date: Wed, 30 Aug 2023 14:52:20 +0900 Subject: [PATCH 3/4] Update README.md --- plugin-gradle/README.md | 4 ++-- plugin-maven/README.md | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/plugin-gradle/README.md b/plugin-gradle/README.md index dbc61207e5..be3df8be98 100644 --- a/plugin-gradle/README.md +++ b/plugin-gradle/README.md @@ -115,7 +115,7 @@ spotless { // don't need to set target, it is inferred from java // apply a specific flavor of google-java-format - googleJavaFormat('1.8').aosp().reflowLongStrings() + googleJavaFormat('1.8').aosp().reflowLongStrings().skipJavadocFormatting() // fix formatting of type annotations formatAnnotations() // make sure every file has the following copyright header. @@ -206,7 +206,7 @@ spotless { // optional: you can specify a specific version (>= 1.8) and/or switch to AOSP style // and/or reflow long strings // and/or use custom group artifact (you probably don't need this) - googleJavaFormat('1.8').aosp().reflowLongStrings().reorderImports(false).groupArtifact('com.google.googlejavaformat:google-java-format') + googleJavaFormat('1.8').aosp().reflowLongStrings().formatJavadoc(false).reorderImports(false).groupArtifact('com.google.googlejavaformat:google-java-format') ``` ### palantir-java-format diff --git a/plugin-maven/README.md b/plugin-maven/README.md index cb770099ac..097bfe9eb5 100644 --- a/plugin-maven/README.md +++ b/plugin-maven/README.md @@ -109,6 +109,7 @@ To use it in your pom, just [add the Spotless dependency](https://search.maven.o 1.8 true + false true + false com.google.googlejavaformat:google-java-format From c3f286224947ae53a94d6618a877c564866852e6 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Wed, 13 Sep 2023 22:31:29 -0700 Subject: [PATCH 4/4] Move the changelog entries to the right place. --- CHANGES.md | 4 ++-- plugin-gradle/CHANGES.md | 4 ++-- plugin-maven/CHANGES.md | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 52db59e7bd..2112f3aa2c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -10,7 +10,8 @@ This document is intended for Spotless developers. We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] - +### Added +* Added support for `google-java-format`'s `skip-javadoc-formatting` option. ([#1793](https://github.com/diffplug/spotless/pull/1793)) ### Fixed * Added support for plugins when using Prettier version `3.0.0` and newer. ([#1802](https://github.com/diffplug/spotless/pull/1802)) @@ -18,7 +19,6 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Added * Add a `jsonPatch` step to `json` formatter configurations. This allows patching of JSON documents using [JSON Patches](https://jsonpatch.com). ([#1753](https://github.com/diffplug/spotless/pull/1753)) * Support GJF own import order. ([#1780](https://github.com/diffplug/spotless/pull/1780)) -* Added support for `google-java-format`'s `skip-javadoc-formatting` option ([#1793](https://github.com/diffplug/spotless/pull/1793)) ### Fixed * Use latest versions of popular style guides for `eslint` tests to fix failing `useEslintXoStandardRules` test. ([#1761](https://github.com/diffplug/spotless/pull/1761), [#1756](https://github.com/diffplug/spotless/issues/1756)) * Add support for `prettier` version `3.0.0` and newer. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1751](https://github.com/diffplug/spotless/issues/1751)) diff --git a/plugin-gradle/CHANGES.md b/plugin-gradle/CHANGES.md index 7ca1fd168e..e4360b02bb 100644 --- a/plugin-gradle/CHANGES.md +++ b/plugin-gradle/CHANGES.md @@ -3,7 +3,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `3.27.0`). ## [Unreleased] - +### Added +* Added support for `google-java-format`'s `skip-javadoc-formatting` option ([#1793](https://github.com/diffplug/spotless/pull/1793)) ### Fixed * Added support for plugins when using Prettier version `3.0.0` and newer. ([#1802](https://github.com/diffplug/spotless/pull/1802)) @@ -11,7 +12,6 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Added * Add a `jsonPatch` step to `json` formatter configurations. This allows patching of JSON documents using [JSON Patches](https://jsonpatch.com). ([#1753](https://github.com/diffplug/spotless/pull/1753)) * Support GJF own import order. ([#1780](https://github.com/diffplug/spotless/pull/1780)) -* Added support for `google-java-format`'s `skip-javadoc-formatting` option ([#1793](https://github.com/diffplug/spotless/pull/1793)) ### Fixed * Add support for `prettier` version `3.0.0` and newer. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1751](https://github.com/diffplug/spotless/issues/1751)) * Fix npm install calls when npm cache is not up-to-date. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1750](https://github.com/diffplug/spotless/issues/1750)) diff --git a/plugin-maven/CHANGES.md b/plugin-maven/CHANGES.md index e8e4081019..3bcc396f8d 100644 --- a/plugin-maven/CHANGES.md +++ b/plugin-maven/CHANGES.md @@ -3,7 +3,8 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format (starting after version `1.27.0`). ## [Unreleased] - +### Added +* Added support for `google-java-format`'s `skip-javadoc-formatting` option ([#1793](https://github.com/diffplug/spotless/pull/1793)) ### Fixed * Added support for plugins when using Prettier version `3.0.0` and newer. ([#1802](https://github.com/diffplug/spotless/pull/1802)) @@ -11,7 +12,6 @@ We adhere to the [keepachangelog](https://keepachangelog.com/en/1.0.0/) format ( ### Added * Add a `jsonPatch` step to `json` formatter configurations. This allows patching of JSON documents using [JSON Patches](https://jsonpatch.com). ([#1753](https://github.com/diffplug/spotless/pull/1753)) * Support GJF own import order. ([#1780](https://github.com/diffplug/spotless/pull/1780)) -* Added support for `google-java-format`'s `skip-javadoc-formatting` option ([#1793](https://github.com/diffplug/spotless/pull/1793)) ### Fixed * Add support for `prettier` version `3.0.0` and newer. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1751](https://github.com/diffplug/spotless/issues/1751)) * Fix npm install calls when npm cache is not up-to-date. ([#1760](https://github.com/diffplug/spotless/pull/1760), [#1750](https://github.com/diffplug/spotless/issues/1750))