@@ -6,14 +6,17 @@ plugins {
66 id ' java'
77 id ' maven-publish'
88 id ' eclipse'
9+ id ' checkstyle'
910 id ' org.springframework.boot' version ' 2.6.2'
11+ id ' com.diffplug.spotless' version ' 6.19.0'
12+ id ' com.github.hierynomus.license' version ' 0.16.1'
13+ id ' com.github.jk1.dependency-license-report' version ' 2.1'
1014}
1115
1216repositories {
1317 // mavenLocal()
1418 maven {
1519 url = uri(' https://repo.maven.apache.org/maven2' )
16-
1720 }
1821 maven {
1922 url " https://fynarfin.jfrog.io/artifactory/fyn-libs-release-local"
@@ -24,6 +27,53 @@ repositories {
2427 }
2528}
2629
30+ apply plugin :' com.diffplug.spotless'
31+ spotless {
32+ format ' misc' , {
33+ target ' **/*.md' , ' **/*.properties' , ' **/.gitignore' , ' **/.openapi-generator-ignore' , ' **/*.yml' , ' **/*.xml' , ' **/**.json' , ' **/*.sql'
34+ targetExclude ' **/build/**' , ' **/bin/**' , ' **/.settings/**' , ' **/.idea/**' , ' **/.gradle/**' , ' **/gradlew.bat' , ' **/licenses/**' , ' **/banner.txt' , ' .vscode/**'
35+ indentWithSpaces(4 )
36+ endWithNewline()
37+ trimTrailingWhitespace()
38+ }
39+
40+ groovyGradle {
41+ target ' *.gradle' , ' **/*.gradle'
42+ targetExclude ' **/build/**'
43+ greclipse()
44+ indentWithSpaces(4 )
45+ endWithNewline()
46+ trimTrailingWhitespace()
47+ }
48+ lineEndings ' UNIX'
49+ }
50+ // Configuration for Gradle license plug-in
51+ // https://github.com/hierynomus/license-gradle-plugin
52+ license {
53+ header rootProject. file(" $rootDir /LICENSE.md" )
54+ excludes([
55+ " **/gradlew*" ,
56+ " **/git.properties" ,
57+ " **/*.html" ,
58+ " **/templates/**" ,
59+ " **/features/**" ,
60+ " **/results/**" ,
61+ " **/package-info.java" ,
62+ " **/keystore.jks" ,
63+ " **/legacy-docs/**" ,
64+ " **/banner.txt" ,
65+ " **/build.gradle.mustache" ,
66+ " **/pom.mustache" ,
67+ " **/avro/**/*.java" ,
68+ " **/org/apache/fineract/client/**/*.java"
69+ ])
70+ strictCheck true
71+ }
72+
73+ licenseReport {
74+ outputDir = " $projectDir /licenses"
75+ }
76+
2777ext {
2878 camelVersion = ' 3.4.0'
2979 springBootVersion = ' 2.6.2'
@@ -72,12 +122,119 @@ dependencies {
72122 implementation ' org.apache.commons:commons-io:1.3.2'
73123 implementation " org.projectlombok:lombok:$lambokVersion "
74124 annotationProcessor " org.projectlombok:lombok:$lambokVersion "
125+ checkstyle ' com.puppycrawl.tools:checkstyle:10.9.3'
126+ checkstyle ' com.github.sevntu-checkstyle:sevntu-checks:1.44.1'
127+ implementation ' com.diffplug.gradle.spotless:spotless:2.4.1'
75128
76129 // miscellaneous test dependency
77130 testImplementation " com.google.truth:truth:1.1.3"
78131 testImplementation ' com.google.code.gson:gson:2.9.0'
79132}
80133
134+ configure(this ) {
135+ // NOTE: order matters!
136+ apply plugin : ' java'
137+ apply plugin : ' idea'
138+ apply plugin : ' eclipse'
139+ apply plugin : ' checkstyle'
140+ apply plugin : ' com.diffplug.spotless'
141+ apply plugin : ' com.github.hierynomus.license'
142+ apply plugin : ' project-report'
143+ apply plugin : ' com.github.jk1.dependency-license-report'
144+ configurations {
145+ implementation. setCanBeResolved(true )
146+ api. setCanBeResolved(true )
147+ }
148+ tasks. withType(JavaCompile ) {
149+ options. compilerArgs + = [
150+ " -Xlint:unchecked" ,
151+ " -Xlint:cast" ,
152+ " -Xlint:auxiliaryclass" ,
153+ " -Xlint:deprecation" ,
154+ " -Xlint:dep-ann" ,
155+ " -Xlint:divzero" ,
156+ " -Xlint:empty" ,
157+ " -Xlint:exports" ,
158+ " -Xlint:fallthrough" ,
159+ " -Xlint:finally" ,
160+ " -Xlint:module" ,
161+ " -Xlint:opens" ,
162+ " -Xlint:options" ,
163+ " -Xlint:overloads" ,
164+ " -Xlint:overrides" ,
165+ " -Xlint:path" ,
166+ " -Xlint:processing" ,
167+ " -Xlint:removal" ,
168+ " -Xlint:requires-automatic" ,
169+ " -Xlint:requires-transitive-automatic" ,
170+ " -Xlint:try" ,
171+ " -Xlint:varargs" ,
172+ " -Xlint:preview" ,
173+ " -Xlint:static" ,
174+ // -Werror needs to be disabled because EclipseLink's static weaving doesn't generate warning-free code
175+ // and during an IntelliJ recompilation, it fails
176+ // "-Werror",
177+ " -Xmaxwarns" ,
178+ 1500 ,
179+ " -Xmaxerrs" ,
180+ 1500
181+ ]
182+ options. deprecation = true
183+ }
184+ // Configuration for the spotless plugin
185+ // https://github.com/diffplug/spotless/tree/main/plugin-gradle
186+ spotless {
187+ java {
188+ targetExclude ' **/build/**' , ' **/bin/**' , ' **/out/**'
189+ importOrder() // sort imports alphabetically
190+ removeUnusedImports()
191+ eclipse(). configFile " $rootDir /config/bulk-formatter.xml"
192+ endWithNewline()
193+ trimTrailingWhitespace()
194+ // Enforce style modifier order
195+ custom ' Modifier ordering' , {
196+ def modifierRanking = [
197+ public : 1 ,
198+ protected : 2 ,
199+ private : 3 ,
200+ abstract : 4 ,
201+ default : 5 ,
202+ static : 6 ,
203+ final : 7 ,
204+ transient : 8 ,
205+ volatile : 9 ,
206+ synchronized : 10 ,
207+ native : 11 ,
208+ strictfp : 12 ]
209+ // Find any instance of multiple modifiers. Lead with a non-word character to avoid
210+ // accidental matching against for instance, "an alternative default value"
211+ it. replaceAll(/ \W (?:public |protected |private |abstract |default |static |final |transient |volatile |synchronized |native |strictfp ){2,}/ , {
212+ // Do not replace the leading non-word character. Identify the modifiers
213+ it. replaceAll(/ (?:public |protected |private |abstract |default |static |final |transient |volatile |synchronized |native |strictfp ){2,}/ , {
214+ // Sort the modifiers according to the ranking above
215+ it. split(). sort({ modifierRanking[it] }). join(' ' ) + ' '
216+ }
217+ )
218+ }
219+ )
220+ }
221+ }
222+ lineEndings ' UNIX'
223+ }
224+ // If we are running Gradle within Eclipse to enhance classes,
225+ // set the classes directory to point to Eclipse's default build directory
226+ if (project. hasProperty(' env' ) && project. getProperty(' env' ) == ' eclipse' ) {
227+ sourceSets. main. java. outputDir = file(" $projectDir /bin/main" )
228+ }
229+ // Configuration for the Checkstyle plugin
230+ // https://docs.gradle.org/current/userguide/checkstyle_plugin.html
231+ dependencies {
232+ checkstyle ' com.puppycrawl.tools:checkstyle:10.3.1'
233+ checkstyle ' com.github.sevntu-checkstyle:sevntu-checks:1.42.0'
234+ }
235+ }
236+
237+
81238group = ' org.mifos'
82239version = ' 0.0.1-SNAPSHOT'
83240description = ' ph-ee-processor-bulk'
0 commit comments