@@ -39,20 +39,25 @@ apply<PublishingHelperPlugin>()
39
39
40
40
tasks.withType(JavaCompile ::class .java).configureEach {
41
41
options.compilerArgs.addAll(listOf (" -Xlint:unchecked" , " -Xlint:deprecation" ))
42
- options.errorprone.disableAllWarnings = true
43
- options.errorprone.disableWarningsInGeneratedCode = true
44
- options.errorprone.excludedPaths =
45
- " .*/${project.layout.buildDirectory.get().asFile.relativeTo(projectDir)} /generated/.*"
46
- options.errorprone.error(
47
- " DefaultCharset" ,
48
- " FallThrough" ,
49
- " MissingCasesInEnumSwitch" ,
50
- " MissingOverride" ,
51
- " ModifiedButNotUsed" ,
52
- " OrphanedFormatString" ,
53
- " PatternMatchingInstanceof" ,
54
- " StringCaseLocaleUsage" ,
55
- )
42
+
43
+ if (project.extra.has(" reused-project-dir" )) {
44
+ options.errorprone.disableAllChecks = true
45
+ } else {
46
+ options.errorprone.disableAllWarnings = true
47
+ options.errorprone.disableWarningsInGeneratedCode = true
48
+ options.errorprone.excludedPaths =
49
+ " .*/${project.layout.buildDirectory.get().asFile.relativeTo(projectDir)} /generated/.*"
50
+ options.errorprone.error(
51
+ " DefaultCharset" ,
52
+ " FallThrough" ,
53
+ " MissingCasesInEnumSwitch" ,
54
+ " MissingOverride" ,
55
+ " ModifiedButNotUsed" ,
56
+ " OrphanedFormatString" ,
57
+ " PatternMatchingInstanceof" ,
58
+ " StringCaseLocaleUsage" ,
59
+ )
60
+ }
56
61
}
57
62
58
63
tasks.register(" compileAll" ).configure {
@@ -150,42 +155,53 @@ tasks.withType(Jar::class).configureEach {
150
155
}
151
156
}
152
157
153
- spotless {
154
- java {
155
- target(" src/*/java/**/*.java" )
156
- googleJavaFormat()
157
- licenseHeaderFile(rootProject.file(" codestyle/copyright-header-java.txt" ))
158
- endWithNewline()
159
- custom(
160
- " disallowWildcardImports" ,
161
- object : Serializable , FormatterFunc {
162
- override fun apply (text : String ): String {
163
- val regex = " ~/import .*\\ .\\ *;/" .toRegex()
164
- if (regex.matches(text)) {
165
- throw GradleException (" Wildcard imports disallowed - ${regex.findAll(text)} " )
158
+ if (! project.extra.has(" reused-project-dir" ) && ! gradle.ideSyncActive()) {
159
+ spotless {
160
+ java {
161
+ target(" src/*/java/**/*.java" )
162
+ googleJavaFormat()
163
+ licenseHeaderFile(rootProject.file(" codestyle/copyright-header-java.txt" ))
164
+ endWithNewline()
165
+ custom(
166
+ " disallowWildcardImports" ,
167
+ object : Serializable , FormatterFunc {
168
+ override fun apply (text : String ): String {
169
+ val regex = " ~/import .*\\ .\\ *;/" .toRegex()
170
+ if (regex.matches(text)) {
171
+ throw GradleException (" Wildcard imports disallowed - ${regex.findAll(text)} " )
172
+ }
173
+ return text
166
174
}
167
- return text
168
- }
169
- },
170
- )
171
- toggleOffOn()
172
- }
173
- kotlinGradle {
174
- ktfmt().googleStyle()
175
- licenseHeaderFile(rootProject.file(" codestyle/copyright-header-java.txt" ), " $" )
176
- target(" *.gradle.kts" )
177
- }
178
- format(" xml" ) {
179
- target(" src/**/*.xml" , " src/**/*.xsd" )
180
- targetExclude(" codestyle/copyright-header.xml" )
181
- eclipseWtp(com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep .XML )
182
- .configFile(rootProject.file(" codestyle/org.eclipse.wst.xml.core.prefs" ))
183
- // getting the license-header delimiter right is a bit tricky.
184
- // licenseHeaderFile(rootProject.file("codestyle/copyright-header.xml"), '<^[!?].*$')
175
+ },
176
+ )
177
+ toggleOffOn()
178
+ }
179
+ scala {
180
+ scalafmt(requiredDependencyVersion(" scalafmt" ))
181
+ .configFile(rootProject.file(" codestyle/scalafmt.conf" ).toString())
182
+ licenseHeaderFile(
183
+ rootProject.file(" codestyle/copyright-header-java.txt" ),
184
+ " ^(package|import) .*$" ,
185
+ )
186
+ target(" src/**/scala/**/*.scala" )
187
+ }
188
+ kotlinGradle {
189
+ ktfmt().googleStyle()
190
+ licenseHeaderFile(rootProject.file(" codestyle/copyright-header-java.txt" ), " $" )
191
+ target(" *.gradle.kts" )
192
+ }
193
+ format(" xml" ) {
194
+ target(" src/**/*.xml" , " src/**/*.xsd" )
195
+ targetExclude(" codestyle/copyright-header.xml" )
196
+ eclipseWtp(com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep .XML )
197
+ .configFile(rootProject.file(" codestyle/org.eclipse.wst.xml.core.prefs" ))
198
+ // getting the license-header delimiter right is a bit tricky.
199
+ // licenseHeaderFile(rootProject.file("codestyle/copyright-header.xml"), '<^[!?].*$')
200
+ }
185
201
}
186
202
}
187
203
188
- dependencies { errorprone(versionCatalogs.named( " libs " ).findLibrary( " errorprone" ).get( )) }
204
+ dependencies { errorprone(requiredDependency( " errorprone" )) }
189
205
190
206
java {
191
207
withJavadocJar()
0 commit comments