Skip to content

Commit 8df95d4

Browse files
committed
Fix #91 Add formatJavadoc configurable support
1 parent 5a4d0ec commit 8df95d4

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

README.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,15 @@ The plugin allows you to tweak Google Java Format options :
100100
</dependencies>
101101
<configuration>
102102
<formatterOptions>
103+
<!-- Use AOSP style instead of Google Style (4-space indentation). -->
103104
<googleJavaFormat.aosp>false</googleJavaFormat.aosp>
105+
<!-- Format the javadoc -->
106+
<googleJavaFormat.formatJavadoc>true</googleJavaFormat.formatJavadoc>
107+
<!-- Fix import order and remove any unused imports, but do no other formatting. -->
104108
<googleJavaFormat.fixImportsOnly>false</googleJavaFormat.fixImportsOnly>
109+
<!-- Do not fix the import order. Unused imports will still be removed. -->
105110
<googleJavaFormat.skipSortingImports>false</googleJavaFormat.skipSortingImports>
111+
<!-- Do not remove unused imports. Imports will still be sorted. -->
106112
<googleJavaFormat.skipRemovingUnusedImports>false</googleJavaFormat.skipRemovingUnusedImports>
107113
</formatterOptions>
108114
</configuration>
@@ -111,19 +117,6 @@ The plugin allows you to tweak Google Java Format options :
111117
</build>
112118
```
113119

114-
Documentation from the google-java-format CLI tool :
115-
116-
```
117-
--aosp, -aosp, -a
118-
Use AOSP style instead of Google Style (4-space indentation).
119-
--fix-imports-only
120-
Fix import order and remove any unused imports, but do no other formatting.
121-
--skip-sorting-imports
122-
Do not fix the import order. Unused imports will still be removed.
123-
--skip-removing-unused-imports
124-
Do not remove unused imports. Imports will still be sorted.
125-
```
126-
127120
## JDK 16+ peculiarities
128121

129122
Since google-java-format uses JDK internal apis, if you need to run the plugin with JDK 16+, you must pass some additional arguments to the JVM.

google-java-format/src/main/java/com/cosium/code/format_gjf/GoogleJavaFormatterOptions.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
class GoogleJavaFormatterOptions {
1313

1414
private final JavaFormatterOptions.Style style;
15+
private final boolean formatJavadoc;
1516
private final boolean fixImportsOnly;
1617
private final boolean skipSortingImports;
1718
private final boolean skipRemovingUnusedImports;
@@ -23,6 +24,7 @@ public GoogleJavaFormatterOptions(CodeFormatterConfiguration configuration) {
2324
} else {
2425
style = GOOGLE;
2526
}
27+
formatJavadoc = configuration.getValue("formatJavadoc").map(Boolean::parseBoolean).orElse(true);
2628
fixImportsOnly =
2729
configuration.getValue("fixImportsOnly").map(Boolean::parseBoolean).orElse(false);
2830
skipSortingImports =
@@ -35,7 +37,7 @@ public GoogleJavaFormatterOptions(CodeFormatterConfiguration configuration) {
3537
}
3638

3739
public JavaFormatterOptions javaFormatterOptions() {
38-
return JavaFormatterOptions.builder().style(style).build();
40+
return JavaFormatterOptions.builder().style(style).formatJavadoc(formatJavadoc).build();
3941
}
4042

4143
public boolean isFixImportsOnly() {

0 commit comments

Comments
 (0)