Skip to content

Commit a06ac6d

Browse files
stephen-crawfordsamuelcostae
authored andcommitted
Updates the style of all java files under the */dlic/util/ dir. (opensearch-project#2823)
* rebase Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Update java style under **/auth Signed-off-by: Stephen Crawford <steecraw@amazon.com> * Update Util dir Signed-off-by: Stephen Crawford <steecraw@amazon.com> * readd formatting Signed-off-by: Stephen Crawford <steecraw@amazon.com> --------- Signed-off-by: Stephen Crawford <steecraw@amazon.com>
1 parent 0d4ca33 commit a06ac6d

1 file changed

Lines changed: 51 additions & 1 deletion

File tree

build.gradle

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
*/
1111

1212

13+
import com.diffplug.gradle.spotless.JavaExtension
1314
import org.opensearch.gradle.test.RestIntegTestTask
1415

1516
buildscript {
@@ -69,7 +70,56 @@ apply plugin: 'opensearch.opensearchplugin'
6970
apply plugin: 'opensearch.pluginzip'
7071
apply plugin: 'opensearch.rest-test'
7172
apply plugin: 'opensearch.testclusters'
72-
apply from: 'gradle/formatting.gradle'
73+
//apply from: 'gradle/formatting.gradle'
74+
75+
spotless {
76+
java {
77+
// Normally this isn't necessary, but we have Java sources in
78+
// non-standard places
79+
target '**/com/amazon/dlic/**/*.java'
80+
81+
removeUnusedImports()
82+
eclipse().configFile rootProject.file('formatter/formatterConfig.xml')
83+
trimTrailingWhitespace()
84+
endWithNewline();
85+
86+
// note: you can use an empty string for all the imports you didn't specify explicitly, and '\\#` prefix for static imports
87+
importOrder('java', 'javax', '', 'com.amazon', 'org.opensearch', '\\#')
88+
89+
custom 'Refuse wildcard imports', {
90+
// Wildcard imports can't be resolved; fail the build
91+
if (it =~ /\s+import .*\*;/) {
92+
throw new AssertionError("Do not use wildcard imports. 'spotlessApply' cannot resolve this issue.")
93+
}
94+
}
95+
96+
// See DEVELOPER_GUIDE.md for details of when to enable this.
97+
if (System.getProperty('spotless.paddedcell') != null) {
98+
paddedCell()
99+
}
100+
}
101+
format 'misc', {
102+
target '*.md', '*.gradle', '**/*.json', '**/*.yaml', '**/*.yml', '**/*.svg'
103+
104+
trimTrailingWhitespace()
105+
endWithNewline()
106+
}
107+
format('javaFoo', JavaExtension) {
108+
109+
importOrder('java', 'javax', '', 'com.amazon', 'org.opensearch', '\\#')
110+
target '**/*.java'
111+
targetExclude '**/com/amazon/dlic/**/*.java'
112+
targetExclude('src/integrationTest/**')
113+
114+
trimTrailingWhitespace()
115+
endWithNewline();
116+
}
117+
format("integrationTest", JavaExtension) {
118+
target('src/integrationTest/java/**/*.java')
119+
importOrder('java', 'javax', '', 'com.amazon', 'org.opensearch', '\\#')
120+
indentWithTabs(4)
121+
}
122+
}
73123

74124
licenseFile = rootProject.file('LICENSE.txt')
75125
noticeFile = rootProject.file('NOTICE.txt')

0 commit comments

Comments
 (0)