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 {
|
|
|
|
licenseHeaderFile file("${resources}/asl-header.txt"), '^(\\s*package)'
|
|
|
|
lineEndings 'UNIX'
|
|
|
|
endWithNewline()
|
|
|
|
googleJavaFormat('1.9')
|
|
|
|
|
|
|
|
switch (project.path) {
|
2020-12-18 07:02:08 -05:00
|
|
|
// 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.
|
2020-12-17 07:11:54 -05:00
|
|
|
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
|
|
|
|
}
|
|
|
|
}
|