lucene/gradle/validation/spotless.gradle

Failed to ignore revisions in .git-blame-ignore-revs.

81 lines
2.6 KiB
Groovy
Raw Normal View History

/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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
*
* http://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.
*/
/*
* LUCENE-9564: This adds automatic (and enforced) code formatting.
*/
def resources = scriptResources(buildscript)
allprojects { prj ->
plugins.withType(JavaPlugin) {
prj.apply plugin: 'com.diffplug.spotless'
spotless {
java {
licenseHeaderFile file("${resources}/asl-header.txt"), '^(\\s*package)'
lineEndings 'UNIX'
endWithNewline()
googleJavaFormat('1.9')
switch (project.path) {
// These modules are complete - all sources scanned.
case ":lucene:highlighter":
target "src/**"
targetExclude "**/resources/**", "**/CambridgeMA.utf8", "**/overview.html"
break
// Partially complete.
case ":lucene:core":
target "src/**/org/apache/lucene/analysis/standard/**",
"src/**/org/apache/lucene/analysis/tokenattributes/**"
targetExclude "**/resources/**", "**/StandardTokenizerImpl.jflex", "**/StandardTokenizerImpl.java"
break
case ":lucene:analysis:common":
target "src/**/org/apache/lucene/analysis/ar/**",
"src/**/org/apache/lucene/collation/**"
targetExclude "**/resources/**"
break
// All others - disable reformatting/ checks for now.
default:
target 'non-existing/**'
break
}
}
}
}
}
// Add an alias to 'spotlessApply' simply called 'tidy' and add
// spotlessCheck to check.
allprojects { prj ->
task tidy() {
description "Applies formatters and cleanups to sources."
group "verification"
}
tasks.matching { task -> task.name == "spotlessApply" }.configureEach { v ->
tidy.dependsOn v
}
tasks.matching { task -> task.name == "spotlessCheck" }.configureEach { v ->
check.dependsOn v
}
}