@@ -25,37 +25,40 @@ import org.gradle.api.GradleException
2525
2626plugins { id(" com.diffplug.spotless" ) }
2727
28- spotless {
29- java {
30- target(" src/*/java/**/*.java" )
31- googleJavaFormat()
32- licenseHeaderFile(rootProject.file(" codestyle/copyright-header-java.txt" ))
33- endWithNewline()
34- custom(
35- " disallowWildcardImports" ,
36- object : Serializable , FormatterFunc {
37- override fun apply (text : String ): String {
38- val regex = " ~/import .*\\ .\\ *;/" .toRegex()
39- if (regex.matches(text)) {
40- throw GradleException (" Wildcard imports disallowed - ${regex.findAll(text)} " )
28+ // skip spotless check for duplicated projects
29+ if (! project.extra.has(" duplicated-project-sources" )) {
30+ spotless {
31+ java {
32+ target(" src/*/java/**/*.java" )
33+ googleJavaFormat()
34+ licenseHeaderFile(rootProject.file(" codestyle/copyright-header-java.txt" ))
35+ endWithNewline()
36+ custom(
37+ " disallowWildcardImports" ,
38+ object : Serializable , FormatterFunc {
39+ override fun apply (text : String ): String {
40+ val regex = " ~/import .*\\ .\\ *;/" .toRegex()
41+ if (regex.matches(text)) {
42+ throw GradleException (" Wildcard imports disallowed - ${regex.findAll(text)} " )
43+ }
44+ return text
4145 }
42- return text
43- }
44- },
45- )
46- toggleOffOn()
47- }
48- kotlinGradle {
49- ktfmt().googleStyle()
50- licenseHeaderFile(rootProject.file(" codestyle/copyright-header-java.txt" ), " $" )
51- target(" *.gradle.kts" )
52- }
53- format(" xml" ) {
54- target(" src/**/*.xml" , " src/**/*.xsd" )
55- targetExclude(" codestyle/copyright-header.xml" )
56- eclipseWtp(com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep .XML )
57- .configFile(rootProject.file(" codestyle/org.eclipse.wst.xml.core.prefs" ))
58- // getting the license-header delimiter right is a bit tricky.
59- // licenseHeaderFile(rootProject.file("codestyle/copyright-header.xml"), '<^[!?].*$')
46+ },
47+ )
48+ toggleOffOn()
49+ }
50+ kotlinGradle {
51+ ktfmt().googleStyle()
52+ licenseHeaderFile(rootProject.file(" codestyle/copyright-header-java.txt" ), " $" )
53+ target(" *.gradle.kts" )
54+ }
55+ format(" xml" ) {
56+ target(" src/**/*.xml" , " src/**/*.xsd" )
57+ targetExclude(" codestyle/copyright-header.xml" )
58+ eclipseWtp(com.diffplug.spotless.extra.wtp.EclipseWtpFormatterStep .XML )
59+ .configFile(rootProject.file(" codestyle/org.eclipse.wst.xml.core.prefs" ))
60+ // getting the license-header delimiter right is a bit tricky.
61+ // licenseHeaderFile(rootProject.file("codestyle/copyright-header.xml"), '<^[!?].*$')
62+ }
6063 }
6164}
0 commit comments