You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by so...@apache.org on 2020/06/03 19:13:38 UTC
[lucene-solr] 09/47: LUCENE-9374: Add checkBrokenLinks gradle task
(#1522)
This is an automated email from the ASF dual-hosted git repository.
sokolov pushed a commit to branch jira/lucene-8962
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
commit d00f79c7bf92e5478193713448b66a87c2dd348a
Author: Tomoko Uchida <to...@apache.org>
AuthorDate: Wed May 20 23:23:24 2020 +0900
LUCENE-9374: Add checkBrokenLinks gradle task (#1522)
---
build.gradle | 1 +
gradle/validation/check-broken-links.gradle | 71 +++++++++++++++++++++++++++++
2 files changed, 72 insertions(+)
diff --git a/build.gradle b/build.gradle
index 7e93c33..2e80ed8 100644
--- a/build.gradle
+++ b/build.gradle
@@ -115,6 +115,7 @@ apply from: file('gradle/validation/ecj-lint.gradle')
apply from: file('gradle/validation/gradlew-scripts-tweaked.gradle')
apply from: file('gradle/validation/missing-docs-check.gradle')
apply from: file('gradle/validation/validate-log-calls.gradle')
+apply from: file('gradle/validation/check-broken-links.gradle')
// Source or data regeneration tasks
apply from: file('gradle/generation/jflex.gradle')
diff --git a/gradle/validation/check-broken-links.gradle b/gradle/validation/check-broken-links.gradle
new file mode 100644
index 0000000..bebfe45
--- /dev/null
+++ b/gradle/validation/check-broken-links.gradle
@@ -0,0 +1,71 @@
+/*
+ * 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.
+ */
+
+configure(rootProject) {
+
+ task checkBrokenLinks {
+ group 'Verification'
+ description 'Check broken links in the entire documentation'
+
+ dependsOn ':lucene:checkBrokenLinks'
+ dependsOn ':solr:checkBrokenLinks'
+ }
+
+}
+configure(subprojects.findAll { it.path in [':lucene', ':solr'] }) {
+
+ task checkBrokenLinks(type: CheckBrokenLinksTask, 'dependsOn': 'documentation')
+
+ // TODO: uncomment this line after fixing all broken links.
+ // (we can't fix the cross-project links until ant build is disabled.)
+ // check.dependsOn checkBrokenLinks
+}
+
+class CheckBrokenLinksTask extends DefaultTask {
+
+ // wraps input directory location in DirectoryProperty so as to lazily evaluate 'docroot' property
+ // (see gradle/documentation/documentation.gradle)
+ @InputDirectory
+ final DirectoryProperty docsDir = project.objects.directoryProperty()
+ .fileProvider(project.providers.provider { project.docroot })
+
+ @InputFile
+ File script = project.rootProject.file("dev-tools/scripts/checkJavadocLinks.py")
+
+ @TaskAction
+ def check() {
+ def outputFile = project.file("${getTemporaryDir()}/check-broken-links-output.txt")
+ def result
+ outputFile.withOutputStream { output ->
+ result = project.exec {
+ executable "python3"
+ ignoreExitValue = true
+ standardOutput = output
+ errorOutput = output
+ args = [
+ "-B",
+ script.absolutePath,
+ docsDir.get().getAsFile()
+ ]
+ }
+ }
+
+ if (result.getExitValue() != 0) {
+ throw new GradleException("Broken links check failed. Command output at: ${outputFile}")
+ }
+ }
+}