2020-12-17 07:11:54 -05:00
|
|
|
/*
|
|
|
|
* 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 {
|
|
|
|
// TODO: work out how to have multiple different header files (we have
|
|
|
|
// classes in the codebase that have original headers).
|
|
|
|
// licenseHeaderFile file("${resources}/asl-header.txt"), '^(\\s*package)'
|
2020-12-28 06:26:13 -05:00
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
lineEndings 'UNIX'
|
|
|
|
endWithNewline()
|
|
|
|
googleJavaFormat('1.9')
|
|
|
|
|
|
|
|
switch (project.path) {
|
|
|
|
// These modules are complete - all sources scanned.
|
|
|
|
case ":lucene:core":
|
2020-12-18 07:02:08 -05:00
|
|
|
target "src/java/**/*.java",
|
|
|
|
"src/test/**/*.java"
|
2020-12-17 07:11:54 -05:00
|
|
|
targetExclude "**/resources/**", "**/StandardTokenizerImpl.java"
|
2020-12-28 06:26:13 -05:00
|
|
|
break
|
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
case ":lucene:highlighter":
|
2020-12-18 07:02:08 -05:00
|
|
|
target "src/java/**/*.java",
|
|
|
|
"src/test/**/*.java"
|
2020-12-17 07:11:54 -05:00
|
|
|
targetExclude "**/resources/**"
|
2020-12-18 07:02:08 -05:00
|
|
|
break
|
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
case ":lucene:queries":
|
|
|
|
target "src/java/**/*.java",
|
|
|
|
"src/test/**/*.java"
|
|
|
|
targetExclude "**/resources/**"
|
2020-12-18 07:02:08 -05:00
|
|
|
break
|
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
case ":lucene:analysis:common":
|
|
|
|
target "src/**/*.java"
|
|
|
|
targetExclude "**/resources/**",
|
|
|
|
"**/HTMLStripCharFilter.java",
|
|
|
|
"**/UAX29URLEmailTokenizerImpl.java",
|
|
|
|
"**/tartarus/**"
|
2020-12-18 07:02:08 -05:00
|
|
|
break
|
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
case ":lucene:demo":
|
|
|
|
case ":lucene:analysis:morfologik":
|
|
|
|
case ":lucene:analysis:icu":
|
|
|
|
case ":lucene:analysis:kuromoji":
|
|
|
|
case ":lucene:memory":
|
|
|
|
case ":lucene:benchmark":
|
|
|
|
case ":lucene:analysis:nori":
|
|
|
|
case ":lucene:analysis:opennlp":
|
|
|
|
case ":lucene:analysis:phonetic":
|
|
|
|
case ":lucene:analysis:smartcn":
|
|
|
|
case ":lucene:analysis:stempel":
|
|
|
|
case ":lucene:classification":
|
|
|
|
case ":lucene:backward-codecs":
|
|
|
|
case ":lucene:codecs":
|
|
|
|
case ":lucene:join":
|
|
|
|
target "src/**/*.java"
|
|
|
|
targetExclude "**/resources/**"
|
2021-01-03 15:46:01 -05:00
|
|
|
break
|
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
case ":lucene:expressions":
|
|
|
|
target "src/**/*.java"
|
|
|
|
targetExclude "**/resources/**", "**/JavascriptLexer.java", "**/JavascriptParser.java",
|
|
|
|
"**/JavascriptVisitor.java"
|
2021-01-03 15:46:01 -05:00
|
|
|
break
|
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
// Partially complete.
|
2021-01-03 15:46:01 -05:00
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
case ":lucene:facet":
|
|
|
|
target "src/**/*.java"
|
|
|
|
targetExclude "**/taxonomy.8.6.3-cfs.zip"
|
2021-01-03 15:46:01 -05:00
|
|
|
break
|
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
// All others - disable reformatting/ checks for now.
|
|
|
|
case ":lucene:grouping":
|
|
|
|
case ":lucene:luke":
|
|
|
|
case ":lucene:misc":
|
|
|
|
case ":lucene:monitor":
|
|
|
|
case ":lucene:queryparser":
|
|
|
|
case ":lucene:replicator":
|
|
|
|
case ":lucene:sandbox":
|
|
|
|
case ":lucene:spatial3d":
|
|
|
|
case ":lucene:spatial-extras":
|
|
|
|
case ":lucene:suggest":
|
|
|
|
case ":lucene:test-framework":
|
2020-12-23 06:41:23 -05:00
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
default:
|
|
|
|
target 'non-existing/**'
|
|
|
|
break
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-01-03 15:46:01 -05:00
|
|
|
|
2020-12-17 07:11:54 -05:00
|
|
|
spotlessJava {
|
2021-01-03 15:46:01 -05:00
|
|
|
doFirst {
|
2020-12-17 07:11:54 -05:00
|
|
|
project.mkdir("${buildDir}/spotless/spotlessJava")
|
2021-01-03 15:46:01 -05:00
|
|
|
}
|
|
|
|
}
|
2020-12-17 07:11:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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
|
|
|
|
}
|
|
|
|
}
|