11plugins {
22 id " base-information"
33 id " java-library"
4-
5- id " com.diffplug.spotless"
6- id " jacoco"
74}
85
96dependencies {
@@ -14,13 +11,6 @@ dependencies {
1411 annotationProcessor libs. loggingProcessor
1512 annotationProcessor libs. logging
1613 annotationProcessor libs. loggingAnnotations
17-
18- testImplementation jakartaLibs. jpa
19- testImplementation testLibs. junit5Api
20- testImplementation testLibs. assertjCore
21-
22- testRuntimeOnly testLibs. junit5Engine
23- testRuntimeOnly testLibs. log4j
2414}
2515
2616
@@ -31,13 +21,6 @@ dependencies {
3121java {
3222 sourceCompatibility = jdks. versions. baseline. get() as int
3323 targetCompatibility = jdks. versions. baseline. get() as int
34-
35- withJavadocJar()
36- withSourcesJar()
37- }
38-
39- test {
40- useJUnitPlatform()
4124}
4225
4326// create a single "compile" task
@@ -49,8 +32,6 @@ tasks.register( "compile" ).configure {
4932tasks. withType( JavaCompile ). configureEach {javaCompile->
5033 options. encoding = " UTF-8"
5134 options. warnings false
52-
53- dependsOn tasks. named( " spotlessApply" )
5435}
5536
5637// To force the build produce the same byte-for-byte archives and hence make Hibernate Models build reproducible.
@@ -60,103 +41,3 @@ tasks.withType( AbstractArchiveTask ).configureEach {
6041 reproducibleFileOrder = true
6142}
6243
63- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
64- // Javadoc
65- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
66-
67- tasks. named( " javadoc" , Javadoc ) {
68- options {
69- use = true
70- encoding = " UTF-8"
71-
72- addStringOption( " Xdoclint:none" , " -quiet" )
73-
74- tags(
75- " todo:X" ,
76- " apiNote:a:API Note:" ,
77- " implSpec:a:Implementation Specification:" ,
78- " implNote:a:Implementation Note:"
79- )
80- }
81- }
82-
83-
84- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
85- // Spotless
86- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
87-
88- spotless {
89- // Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
90- enforceCheck false
91- java {
92- licenseHeaderFile rootProject. file( ' config/spotless/license.java' )
93- removeUnusedImports()
94- indentWithTabs( 4 )
95- trimTrailingWhitespace()
96- endWithNewline()
97- }
98- }
99-
100-
101- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
102- // Enforced rules
103- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
104-
105- def enforceRulesTask = tasks. register( " enforceRules" ) {
106- description " Enforces some formatting rules to src/main/java files"
107- doLast {
108- def illegalImport = ~/ ^import (sun|java.awt|org.slf4j)/
109- def missingNewline = ~/ ^\s *}\s *(else|catch|finally)/
110- def lowerEll = ~/ \b\d +l\b /
111- def errors = 0
112- def tree = fileTree( " src/main/java/" )
113- tree. include " **/*.java"
114- tree. each { file ->
115- def lineNum = 0
116- def shortName = file. path. substring( rootDir. path. length() )
117- file. eachLine { line ->
118- lineNum++
119- if ( line =~ illegalImport ) {
120- errors++
121- logger. error( " Illegal import in ${ shortName} \n ${ lineNum} : ${ line} " )
122- }
123- if ( line =~ missingNewline ) {
124- errors++
125- logger. error( " Missing newline in ${ shortName} \n ${ lineNum} : ${ line} " )
126- }
127- if ( line =~ lowerEll ) {
128- errors++
129- logger. error( " Lowercase long literal in ${ shortName} \n ${ lineNum} : ${ line} " )
130- }
131- }
132- }
133- if ( errors > 0 ) {
134- throw new GradleException ( " Code rules were violated ($errors problems)" )
135- }
136- }
137- }
138-
139-
140-
141-
142- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143- // JaCoCo
144- // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
145-
146- def jacocoReportTask = tasks. named( " jacocoTestReport" ) {
147- dependsOn tasks. named( " test" )
148- }
149-
150- jacocoTestReport {
151- reports {
152- xml. required = false
153- csv. required = false
154- html. outputLocation = layout. buildDirectory. dir( " jacocoHtml" )
155- }
156- }
157-
158- tasks. named( " check" ) {
159- dependsOn enforceRulesTask
160- dependsOn tasks. named( " spotlessCheck" )
161- dependsOn jacocoReportTask
162- }
0 commit comments