enable spotless

This commit is contained in:
Gavin King 2024-09-14 19:10:26 +02:00
parent de921ad473
commit a43bcd80a8
4 changed files with 26 additions and 0 deletions

View File

@ -25,6 +25,7 @@ plugins {
id 'org.hibernate.orm.database-service' apply false id 'org.hibernate.orm.database-service' apply false
id 'biz.aQute.bnd' version '7.0.0' apply false id 'biz.aQute.bnd' version '7.0.0' apply false
id 'com.diffplug.spotless' version '6.25.0'
id 'org.checkerframework' version '0.6.40' id 'org.checkerframework' version '0.6.40'
id 'org.hibernate.orm.build.jdks' id 'org.hibernate.orm.build.jdks'

View File

@ -33,6 +33,7 @@ apply plugin: 'org.hibernate.orm.build.java-module'
apply plugin: 'org.checkerframework' apply plugin: 'org.checkerframework'
apply plugin: 'de.thetaphi.forbiddenapis' apply plugin: 'de.thetaphi.forbiddenapis'
apply plugin: 'com.diffplug.spotless'
apply plugin: "jacoco" apply plugin: "jacoco"
apply plugin: 'checkstyle' apply plugin: 'checkstyle'
@ -194,6 +195,7 @@ tasks.withType( JavaCompile ) {
] ]
} }
tasks.compileJava.dependsOn spotlessApply
task compile(dependsOn: [compileJava, processResources, compileTestJava, processTestResources] ) task compile(dependsOn: [compileJava, processResources, compileTestJava, processTestResources] )
@ -466,6 +468,18 @@ task nonFatalCheckstyle(type:Checkstyle) {
configFile = rootProject.file( 'shared/config/checkstyle/checkstyle-non-fatal.xml' ) configFile = rootProject.file( 'shared/config/checkstyle/checkstyle-non-fatal.xml' )
} }
spotless {
//Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
enforceCheck false
java {
licenseHeaderFile rootProject.file('spotless.license.java')
removeUnusedImports()
trimTrailingWhitespace()
endWithNewline()
}
}
class CompilerStubsArgumentProvider implements CommandLineArgumentProvider { class CompilerStubsArgumentProvider implements CommandLineArgumentProvider {
@InputDirectory @InputDirectory

View File

@ -282,3 +282,8 @@ tasks.sourcesJar.dependsOn ':hibernate-core:generateGraphParser'
tasks.sourcesJar.dependsOn ':hibernate-core:generateHqlParser' tasks.sourcesJar.dependsOn ':hibernate-core:generateHqlParser'
tasks.sourcesJar.dependsOn ':hibernate-core:generateSqlScriptParser' tasks.sourcesJar.dependsOn ':hibernate-core:generateSqlScriptParser'
tasks.sourcesJar.dependsOn ':hibernate-core:generateOrderingParser' tasks.sourcesJar.dependsOn ':hibernate-core:generateOrderingParser'
tasks.spotlessJava.dependsOn ':hibernate-core:generateGraphParser'
tasks.spotlessJava.dependsOn ':hibernate-core:generateHqlParser'
tasks.spotlessJava.dependsOn ':hibernate-core:generateSqlScriptParser'
tasks.spotlessJava.dependsOn ':hibernate-core:generateOrderingParser'

6
spotless.license.java Normal file
View File

@ -0,0 +1,6 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/