Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

SOLR-15265: Use (unpacked) lucene javadoc jars from maven for local link checking in ref-guide

Chris Hostetter0626de4d6a25
diff --git a/build.gradle b/build.gradle
index 1756ffdc358..a3be7c0bee9 100644
--- a/build.gradle
+++ b/build.gradle
@@ -169,6 +169,7 @@ apply from: file('gradle/ant-compat/misc.gradle')
apply from: file('gradle/ant-compat/force-versions.gradle')
apply from: file('gradle/ant-compat/artifact-naming.gradle')
+apply from: file('gradle/documentation/pull-lucene-javadocs.gradle')
apply from: file('gradle/documentation/documentation.gradle')
apply from: file('gradle/documentation/changes-to-html.gradle')
apply from: file('gradle/documentation/markdown.gradle')
diff --git a/gradle/documentation/pull-lucene-javadocs.gradle b/gradle/documentation/pull-lucene-javadocs.gradle
new file mode 100644
index 00000000000..73700f0fc95
--- /dev/null
+++ b/gradle/documentation/pull-lucene-javadocs.gradle
@@ -0,0 +1,86 @@
+/*
+ * 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.
+ */
+
+
+// Pull and unpack Lucene javadocs from published Maven artifacts for use in local link checking.
+
+configure(project(":solr:documentation")) {
+ ext {
+ luceneDocsDir = file("${project.buildDir}/lucene-javadocs")
+ }
+
+ configurations {
+ javadocs {
+ // Not sure why we need this, otherwise regular JARs get sucked in, not just
+ // javadoc-classifier JARs
+ transitive = false
+ }
+ }
+
+ dependencies {
+ // Note we can't use the abbreviated form (above) because we omit the version number
+ // for the palantir plugin and at the same time we wish to use the classifier.
+
+ // TODO:
+ // - For now this list is focused solely on the javadocs needed for ref-guide link validation.
+ // - If/when additional links are added from the ref-guide to additional lucene modules not listed here,
+ // they can be added.
+ // - If/when we need the lucene javadocs for "all" lucene depdencies in Solr (ie: to do link checking
+ // from all Solr javadocs?) then perhaps we can find a way to build this list programatically?
+ // - If these javadocs are (only every) consumed by the ref guide only, then these deps & associated tasks
+ // should just be moved to the ref-guide build.gradle
+ javadocs group: 'org.apache.lucene', name: 'lucene-core', classifier: 'javadoc'
+ javadocs group: 'org.apache.lucene', name: 'lucene-analysis-common', classifier: 'javadoc'
+ javadocs group: 'org.apache.lucene', name: 'lucene-analysis-stempel', classifier: 'javadoc'
+ javadocs group: 'org.apache.lucene', name: 'lucene-queryparser', classifier: 'javadoc'
+ javadocs group: 'org.apache.lucene', name: 'lucene-sandbox', classifier: 'javadoc'
+ javadocs group: 'org.apache.lucene', name: 'lucene-spatial-extras', classifier: 'javadoc'
+ }
+
+
+ task collectLuceneJavadocs() {
+ description "Collect and unpack javadoc artifacts from 'javadocs' configuration"
+
+ dependsOn configurations.javadocs
+ inputs.files configurations.javadocs
+ outputs.dir luceneDocsDir
+
+ doFirst {
+ def resolved = configurations.javadocs.resolvedConfiguration
+ resolved.resolvedArtifacts.each { artifact ->
+ def id = artifact.moduleVersion.id
+ // This mimics the directory stucture used on lucene.apache.org for the javadocs of all modules.
+ //
+ // HACK: the lucene.apache.org javadocs are organized to match the module directory structure in the repo,
+ // not the "flat" artifact names -- so there is no one size fits all way to determine the directory name.
+ // We have to "special case" that analysis-* modules are in an 'analysis/*' subdir, while the general rule is that
+ // '-' in artifact names are left as part of the dir name (ie: 'spatial-extras/')....
+ def path = id.name.replaceFirst('^lucene-', '').replaceFirst('^analysis-','analysis/')
+ project.sync {
+ from zipTree(artifact.file)
+ into file("${luceneDocsDir}/${path}/")
+ }
+ }
+ }
+ }
+
+ artifacts {
+ javadocs luceneDocsDir, {
+ builtBy collectLuceneJavadocs
+ }
+ }
+}
diff --git a/solr/solr-ref-guide/build.gradle b/solr/solr-ref-guide/build.gradle
index 7d56f8978a5..06b262857a0 100644
--- a/solr/solr-ref-guide/build.gradle
+++ b/solr/solr-ref-guide/build.gradle
@@ -133,9 +133,13 @@ ext {
// NOTE: extra '../' because we'll in a sub-dir of buildDir that will be built later...
props: [
htmlSolrJavadocs : 'link:../' + buildDir.toPath().relativize(project(':solr:documentation').docroot.toPath()).toString().replace(File.separator, '/'),
- // TODO: This isn't viable long term - see SOLR-15262 / SOLR-15264
- htmlLuceneJavadocs : "https://lucene.apache.org/core/${solrGuideVersionPath}_0/"
- ]
+ htmlLuceneJavadocs : 'link:../' + buildDir.toPath().relativize(project(':solr:documentation').luceneDocsDir.toPath()).toString().replace(File.separator, '/'),
+ ]
+
+ // TODO: (see full discussion in SOLR-15265)
+ // Ref guide build should really depend on those javadocs it links to - then there would be no awkwardness and, ideally,
+ // you could just sync the resources you need into the final structure (that's why I declared javadocs as an artifact).
+ // This does entail some duplication (syncing between folders) but if it's reused in different places then it's fine.
]
}