Skip to content

Commit

Permalink
Add spotless plugin and enforce header for java files (#2722)
Browse files Browse the repository at this point in the history
This only applies to .java files changed compared to the origin base
branch (3.3.x):

 - Ensure tab indentation is used, with regexp fix for comment blocks
 - Trim trailing whitespaces
 - Ensure files end with a blank line
 - Remove unused imports
 - Enfore license header with up-to-date end year
  • Loading branch information
simonbasle committed Jun 24, 2021
1 parent 8da7d59 commit c97ec8c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ plugins {
id 'biz.aQute.bnd.builder' version '5.0.1' apply false
id 'io.spring.nohttp' version '0.0.5.RELEASE'
id "io.github.reyerizo.gradle.jcstress" version "0.8.11" apply false
id "com.diffplug.spotless" version "5.14.0"
}

apply plugin: "io.reactor.gradle.detect-ci"
Expand Down Expand Up @@ -106,6 +107,20 @@ nohttp {
allowlistFile = project.file('codequality/nohttp/allowlist.lines')
}

spotless {
ratchetFrom 'origin/pivotalToVmware' //FIXME switch to 3.3.x once other PR is merged, and `main` once forward-merged
java {
target '**/*.java'
indentWithTabs()
replaceRegex 'class-level javadoc indentation fix', /^\*/, ' *'
replaceRegex 'method-level javadoc indentation fix', /\t\*/, '\t *'
trimTrailingWhitespace()
endWithNewline()
removeUnusedImports()
licenseHeaderFile('codequality/spotless/licenseJava.txt')
}
}

configure(subprojects) { p ->
apply plugin: 'java'
apply plugin: 'jacoco'
Expand Down
15 changes: 15 additions & 0 deletions codequality/spotless/licenseJava.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright (c) 2011-$YEAR VMware Inc. or its affiliates, All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

0 comments on commit c97ec8c

Please sign in to comment.