xref: /Lucene/gradle/help.gradle (revision 780846a732b9c3f9c8b0abeae7d1d2c19df524e4)
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements.  See the NOTICE file distributed with
4 * this work for additional information regarding copyright ownership.
5 * The ASF licenses this file to You under the Apache License, Version 2.0
6 * (the "License"); you may not use this file except in compliance with
7 * the License.  You may obtain a copy of the License at
8 *
9 *     http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS,
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 * See the License for the specific language governing permissions and
15 * limitations under the License.
16 */
17
18// Add "help" tasks which display plain text files under 'help' folder.
19
20configure(rootProject) {
21  def helpFiles = [
22      ["Workflow", "help/workflow.txt", "Typical workflow commands."],
23      ["Tests", "help/tests.txt", "Tests, filtering, beasting, etc."],
24      ["Formatting", "help/formatting.txt", "Code formatting conventions."],
25      ["Jvms", "help/jvms.txt", "Using alternative or EA JVM toolchains."],
26      ["Deps", "help/dependencies.txt", "Declaring, inspecting and excluding dependencies."],
27      ["ForbiddenApis", "help/forbiddenApis.txt", "How to add/apply rules for forbidden APIs."],
28      ["LocalSettings", "help/localSettings.txt", "Local settings, overrides and build performance tweaks."],
29      ["Regeneration", "help/regeneration.txt", "How to refresh generated and derived resources."],
30      ["Git", "help/git.txt", "Git assistance and guides."],
31      ["IDEs", "help/IDEs.txt", "IDE support."],
32      ["Publishing", "help/publishing.txt", "Maven and other artifact publishing, signing, etc."],
33  ]
34
35  helpFiles.each { section, path, sectionInfo ->
36    task "help${section}" {
37      group = 'Help (developer guides and hints)'
38      description = sectionInfo
39      doFirst {
40        println "\n" + rootProject.file(path).getText("UTF-8")
41      }
42    }
43  }
44
45  help {
46    doLast {
47      println ""
48      println "This is an experimental Lucene/Solr gradle build. See some"
49      println "guidelines, ant-equivalent commands etc. under help/*; or type:"
50      println ""
51      helpFiles.each { section, path, sectionInfo ->
52        println String.format(Locale.ROOT,
53            "  gradlew :help%-16s # %s", section, sectionInfo)
54      }
55      println ""
56      println "For the impatient, build the project with 'gradlew assemble'"
57    }
58  }
59
60  task allHelpFilesExit() {
61    doFirst {
62      helpFiles.each { section, path, sectionInfo ->
63        if (!rootProject.file(path).exists()) {
64          throw new GradleException("Help file missing: ${path} (correct help.gradle)")
65        }
66      }
67    }
68  }
69
70  check.dependsOn allHelpFilesExit
71}
72