Skip to content

Commit

Permalink
HCANN-114 Introduce Spotless Gradle plugin to verify headers format
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed Nov 18, 2020
1 parent f8ad889 commit dfa2cc6
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
20 changes: 20 additions & 0 deletions build.gradle
@@ -1,11 +1,15 @@
buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'org.hibernate.build.gradle:gradle-maven-publish-auth:2.0.1'
classpath 'org.hibernate.build.gradle:version-injection-plugin:1.0.0'
classpath 'org.hibernate.build.gradle:gradle-animalSniffer-plugin:1.0.1.Final'
classpath "com.diffplug.spotless:spotless-plugin-gradle:4.5.1"
}
}

Expand All @@ -16,6 +20,7 @@ repositories {
apply plugin: 'java'
apply plugin: 'osgi'

apply plugin: 'com.diffplug.gradle.spotless'
apply plugin: 'version-injection'

apply plugin: 'maven-publish'
Expand Down Expand Up @@ -176,6 +181,21 @@ wrapper {
distributionType = Wrapper.DistributionType.ALL
}

spotless {
//Only apply on files added, compared to this git source:
ratchetFrom 'origin/master'
//Don't fail during the check: rather than enforcing guidelines, we use this plugin to fix mistakes automatically.
enforceCheck false
java {
licenseHeaderFile 'spotless.license.java'
removeUnusedImports()
importOrder()
trimTrailingWhitespace()
endWithNewline()
}
}
tasks.compileJava.dependsOn(spotlessApply)


// OSGi manifest helpers ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down
6 changes: 6 additions & 0 deletions spotless.license.java
@@ -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>.
*/

0 comments on commit dfa2cc6

Please sign in to comment.