| /* |
| * 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. |
| */ |
| |
| import org.apache.lucene.gradle.CheckWorkingCopy |
| import org.apache.lucene.gradle.LuceneSolrForbiddenApisPlugin |
| import org.apache.commons.io.FilenameUtils |
| |
| plugins { |
| id "com.palantir.consistent-versions" version "1.8.0" |
| } |
| |
| buildDir = file("build") |
| |
| // define lucene-solr project lists that exclude buildSrc |
| def luceneSolrProjects = allprojects.findAll { project -> project.name != 'buildSrc'}; |
| def luceneSolrSubProjects = subprojects.findAll { project -> project.name != 'buildSrc'} |
| |
| def rootProjectDir = project.rootProject.projectDir; |
| |
| // setup some basics - for other allproject work see below |
| allprojects { |
| // make sure ant task logging shows up by default |
| ant.lifecycleLogLevel = "INFO" |
| // sugare file path handler - to deal with path.separator on string paths |
| ext.filePath = { path -> file(path).getAbsolutePath() } |
| // sugar multi part File |
| ext.mfile = { file1, file2 -> new File(file(file1), file2.toString()) } |
| } |
| |
| apply from: mfile(rootProjectDir, 'buildSrc/common/build-help.gradle') |
| |
| // TOC |
| // -> lucene-solr all project config |
| // -> lucene-solr sub module config |
| // -> lucene-solr root project config |
| // -> all projects config |
| // -> lucene-solr IDE config |
| // -> dependencies |
| // -> other config |
| |
| // -> lucene-solr all module config - configure all lucene-solr projects, including root project |
| configure(luceneSolrProjects) { |
| buildDir = file("build") |
| |
| // setup repositories |
| apply from: mfile(rootProjectDir, 'buildSrc/common/configure-repositories.gradle') |
| |
| apply plugin: 'idea' |
| apply plugin: 'eclipse' |
| |
| task ratSources(type: org.apache.lucene.gradle.RatSources) { |
| group = 'Verification' |
| description = "Checks source files for proper license headers." |
| excludes = ['**/TODO', '**/*.txt,', '**/*.iml'] |
| check.dependsOn ratSources |
| } |
| |
| task checkSourcePatterns(type: org.apache.lucene.gradle.CheckSourcePatterns) { |
| group = 'Verification' |
| description = "Checks source files for project violations." |
| baseDir = projectDir |
| check.dependsOn checkSourcePatterns |
| } |
| |
| task checkMissingJavaDocs { |
| group = 'Verification' |
| description = "Checks for missing JavaDocs." |
| |
| doLast { |
| project.exec { |
| workingDir project.projectDir.getAbsolutePath() |
| executable "${python_exe}" |
| args = ['-B', rootProjectDir.getAbsolutePath() + '/dev-tools/scripts/checkJavaDocs.py', project.projectDir.getAbsolutePath(), 'class'] |
| } |
| } |
| } |
| |
| // TODO: check.dependsOn checkMissingJavaDocs |
| |
| } |
| |
| // -> lucene-solr sub module config - configure all lucene-solr modules (excludes the root project) |
| configure(luceneSolrSubProjects) { |
| |
| plugins.withType(JavaPlugin) { |
| |
| project.plugins.apply(LuceneSolrForbiddenApisPlugin) |
| |
| sourceCompatibility = "11" |
| targetCompatibility = "11" |
| |
| // Use UTF-8, don't rely on local platform encoding. |
| project.compileJava.options.encoding = "UTF-8" |
| project.compileTestJava.options.encoding = "UTF-8" |
| |
| project.sourceSets { |
| main.java.srcDirs = ['src/java'] |
| main.resources.srcDirs = ['src/resources'] |
| test.java.srcDirs = ['src/test'] |
| test.resources.srcDirs = ['src/test-files'] |
| } |
| |
| // configure tests |
| project.apply from: mfile(rootProjectDir, 'buildSrc/common/configure-test.gradle') |
| |
| task sourceJar(type: Jar) { |
| classifier 'sources' |
| from sourceSets.main.allJava |
| } |
| |
| // configure maven |
| if (project.getPlugins().hasPlugin('publish-maven')) { |
| publishing { |
| publications { |
| mavenJava(MavenPublication) { |
| from components.java |
| artifact tasks.sourceJar |
| } |
| } |
| } |
| } |
| } |
| } |
| |
| // -> lucene-solr root project config - configure the root project |
| configure(rootProject) { |
| |
| // root project config |
| |
| // TODO: enable the modified files checking only for jenkins runs! sysprop? |
| tasks.create('checkWorkingCopy', CheckWorkingCopy, false) |
| |
| |
| task testTimes(type: org.apache.lucene.gradle.JUnit4) { |
| group = 'Tests' |
| description = "Show the slowest tests (averages)." |
| } |
| |
| task pristineClean(type: org.apache.lucene.gradle.PristineClean) {} |
| } |
| |
| // -> all projects config |
| configure(allprojects) { |
| |
| // -> lucene-solr IDE config - setup eclipse and idea |
| |
| apply plugin: 'eclipse' |
| apply plugin: 'idea' |
| |
| plugins.withType(JavaPlugin) { |
| project.apply from: mfile(rootProjectDir, 'buildSrc/ide/eclipse.gradle') |
| project.apply from: mfile(rootProjectDir, 'buildSrc/ide/idea.gradle') |
| } |
| |
| // dependencies block that applies to all projects |
| dependencies { |
| configurations.all { |
| // stax-api classes are in Java 11 |
| exclude group: 'javax.xml.stream', module: 'stax-api' |
| exclude group: 'stax', module: 'stax-api' |
| exclude group: 'stax', module: 'stax' |
| |
| // logging jars we don't want, we use slf4j |
| exclude group: 'log4j', module: 'log4j' |
| exclude group: 'commons-logging', module: 'commons-logging' |
| |
| // exclude annotation jars that come with guave |
| exclude group: 'com.google.code.findbugs', module: 'jsr305' |
| exclude group: 'org.checkerframework', module: 'checker-qual' |
| exclude group: 'com.google.errorprone', module: 'error_prone_annotations' |
| exclude group: 'com.google.j2objc', module: 'j2objc-annotations' |
| exclude group: 'org.codehaus.mojo', module: 'animal-sniffer-annotations' |
| |
| exclude group: 'org.apache.yetus', module: 'audience-annotations' // annotations jar brought in by zk |
| exclude group: 'org.slf4j', module: 'slf4j-log4j12' // zk and perhaps others can bring in log4j12 binding |
| } |
| |
| modules { |
| module("commons-logging:commons-logging") { replacedBy("org.slf4j:jcl-over-slf4j") } |
| module("log4j:log4j") { replacedBy("org.slf4j:log4j-over-slf4j") } |
| } |
| } |
| |
| File jdepsReportDir = mfile(project.buildDir, 'jdepsreport') |
| |
| plugins.withType(JavaPlugin) { |
| |
| task jdepsReport(type: org.apache.lucene.gradle.JdepsReport) { |
| target = jdepsReportDir |
| } |
| |
| task listDependencies(type: org.apache.lucene.gradle.ListDeps) { |
| group = 'Help' |
| description = "List sorted dependencies and counts for a module." |
| } |
| |
| task unusedDependencies { |
| group = 'Help' |
| description = "Lists dependencies that may be unused for a module." |
| task unusedDeps(type: org.apache.lucene.gradle.UnusedDeps) { |
| inputDirectory jdepsReportDir |
| } |
| unusedDeps.dependsOn jdepsReport |
| dependsOn unusedDeps |
| } |
| |
| task missingDependencies { |
| group = 'Help' |
| description = "Lists classes from this module with missing runtime dependencies (we ignore scanning some root deps (ie hadoop) and some violations (ie annotations)." |
| task missingDeps(type: org.apache.lucene.gradle.MissingDeps) { |
| inputDirectory jdepsReportDir |
| } |
| missingDeps.dependsOn jdepsReport |
| dependsOn missingDeps |
| } |
| } |
| } |
| |
| // -> other config |
| |
| |
| // Single JavaDocs for all modules |
| |
| def noJavaDocModules = ["buildSrc", "dev-tools","lucene", "solr", "solr-ref-guide", "lucene-analysis", "lucene-backward-codecs", "solr-contrib", "solr-example", "solr-example-DIH"] |
| def javaDocProjects = subprojects.findAll { project -> !noJavaDocModules.contains(project.name)} |
| |
| // project.afterEvaluate{ |
| // task javadocAll(type: Javadoc) { |
| // group = 'Documentation' |
| // description = "Generates single JavaDoc for all modules." |
| // javaDocProjects.each { println it.name;println it.sourceSets;evaluationDependsOn(it.path) } |
| // source javaDocProjects.collect { it.sourceSets.main.allJava } |
| // classpath = files(javaDocProjects.collect { it.sourceSets.main.compileClasspath }) |
| // destinationDir = file("${buildDir}/docs") |
| // } |
| // } |