You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ho...@apache.org on 2020/09/18 21:37:08 UTC

[lucene-solr] branch master updated: SOLR-14824: remove cruft from the ref-guide gradle build and simpliy the publish process

This is an automated email from the ASF dual-hosted git repository.

hossman pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/master by this push:
     new 5e034d7  SOLR-14824: remove cruft from the ref-guide gradle build and simpliy the publish process
5e034d7 is described below

commit 5e034d7348833d855f5e4327efffdabb77f0346a
Author: Chris Hostetter <ho...@apache.org>
AuthorDate: Fri Sep 18 14:36:51 2020 -0700

    SOLR-14824: remove cruft from the ref-guide gradle build and simpliy the publish process
    
    some things being cleaned up here are simplifications of changes that were 1-to-1 ported from ant, others are left over from when we had a 'released' PDF and are no longer needed
---
 solr/solr-ref-guide/build.gradle               | 167 ++++++-------------------
 solr/solr-ref-guide/src/_config.yml.template   |  33 +++--
 solr/solr-ref-guide/src/_includes/footer.html  |   2 +-
 solr/solr-ref-guide/src/_includes/head.html    |   3 +-
 solr/solr-ref-guide/src/css/navs.css           |   2 +-
 solr/solr-ref-guide/src/meta-docs/publish.adoc |   8 +-
 6 files changed, 60 insertions(+), 155 deletions(-)

diff --git a/solr/solr-ref-guide/build.gradle b/solr/solr-ref-guide/build.gradle
index e3063c6..f6320e8 100644
--- a/solr/solr-ref-guide/build.gradle
+++ b/solr/solr-ref-guide/build.gradle
@@ -126,62 +126,40 @@ ext {
     buildContentDir = file("${buildDir}/content")
     mainPage = "index"
 
+    // the "MAJOR.MINOR" version of solr this guide is about (guides aren't specific to BUGFIX releases)
+    // So on 'branch_9_9' where 'version' may be 9.9.0, 9.9.1, 9.9.9, etc..;  solrDocsVersion = 9.9
     solrDocsVersion = "${version}".replaceAll(/^(\d+\.\d+)(|\..*)$/, "\$1")
-    solrDocsVersionPath = "${solrDocsVersion}".replaceAll(/^(\d+)\.(\d+)$/, "\$1_\$2_0")
-
-    solrGuideVersion = propertyOrDefault("solrGuideVersion", "${solrDocsVersion}-DRAFT")
-
-    solrRootPath = '../../../../solr/'
-    solrGuideDraftStatus = solrGuideVersion.matches(/^\d+\.\d+(|\.\d+)$/) ? "" : "DRAFT"
-    solrGuideVersionPath = solrGuideVersion.replaceAll(/^(\d+)\.(\d+)(-DRAFT)?.*/, "\$1_\$2\$3")
-
-    javadocLink = "https://docs.oracle.com/en/java/javase/11/docs/api/"
+    
+    // the "MAJOR_MINOR" version as a path for publishing the guide
+    // So on 'branch_9_9' where solrDocsVersion = 9.9; solrGuideVersionPath => 9_9
+    solrGuideVersionPath = "${solrDocsVersion}".replaceAll(/^(\d+)\.(\d+)$/, "\$1_\$2")
 
     if (project.hasProperty("local.javadocs")) {
         htmlSolrJavadocs = "link:../../docs/"
         htmlLuceneJavadocs = "link:../../../../lucene/build/docs/"
     } else {
-        htmlSolrJavadocs = "https://lucene.apache.org/solr/${solrDocsVersionPath}/"
-        htmlLuceneJavadocs = "https://lucene.apache.org/core/${solrDocsVersionPath}/"
+        // when linking to javadocs of code releases, which always use paths like "MAJOR_MINOR_BUGFIX"
+        // (even when 'BUGFIX' = 0), we link to the javadocs for the "MAJOR.MINOR.0" release
+        // So if solrGuideVersionPath = '9_9'; use '9_9_0' for javadoc links...
+        htmlSolrJavadocs = "https://lucene.apache.org/solr/${solrGuideVersionPath}_0/"
+        htmlLuceneJavadocs = "https://lucene.apache.org/core/${solrGuideVersionPath}_0/"
     }
 
-    bareBonesDir = file("${buildDir}/bare-bones-html")
-
-    // Some additional version properties are lazily computed
-    // in setupLazyProps (because they need to be computed after evaluation is complete).
-    props = [
-            "solr-root-path"         : solrRootPath,
-            "solr-guide-draft-status": solrGuideDraftStatus,
-            "solr-guide-version"     : solrGuideVersion,
-            "solr-guide-version-path": solrGuideVersionPath,
-            "solr-docs-version"      : solrDocsVersion,
-            "javadoc.link"           : javadocLink,
-            "java-javadocs"          : javadocLink,
-            "solr-javadocs"          : htmlSolrJavadocs,
-            "html-solr-javadocs"     : htmlSolrJavadocs,
-            "lucene-javadocs"        : htmlLuceneJavadocs,
-            "html-lucene-javadocs"   : htmlLuceneJavadocs,
-            "build-date"             : buildDate,
-            "DSTAMP"                 : buildDate,
-            "build-year"             : buildYear,
-            "current.year"           : buildYear
-    ]
-
-    asciiDocAttrs = [
-            'common': [
-                    'attribute-missing' : 'warn',
-                    'icons'             : 'font',
-                    'icon-set'          : 'fa',
-                    'figure-caption!'   : '',
-                    'idprefix'          : '',
-                    'idseparator'       : '-',
-                    'source-highlighter': 'coderay',
-                    'solr-root-path'    : solrRootPath,
-            ],
-            'html'  : [
-                    'imagesdir': buildContentDir.toString()
-            ]
-    ]
+    // ivy* props will be set in setupLazyProps
+    // (because they need to be computed after evaluation is complete).
+    templateProps = [
+      javadocLink: "https://docs.oracle.com/en/java/javase/11/docs/api/",
+                      
+      solrGuideDraftStatus: propertyOrDefault("solrGuideDraft", "true").toBoolean() ? "DRAFT" : "",
+      solrRootPath: project(':solr').projectDir.toString() + File.separator,
+      
+      solrDocsVersion: solrDocsVersion,
+      solrGuideVersionPath: solrGuideVersionPath,
+      htmlSolrJavadocs: htmlSolrJavadocs,
+      htmlLuceneJavadocs: htmlLuceneJavadocs,
+      buildDate: buildDate,
+      buildYear: buildYear,
+    ]   
 }
 
 task setupLazyProps {
@@ -189,25 +167,18 @@ task setupLazyProps {
         // These properties have to be resolved after the configuration phase is complete (palantir's constraint)
         // so we can't use them as input for caches.
         [
-                ["ivyversions./commons-codec/commons-codec", "commons-codec", "commons-codec"],
-                ["ivyversions.io.dropwizard.metrics.version", "io.dropwizard.metrics", "metrics-core"],
-                ["ivyversions.org.apache.logging.log4j.version", "org.apache.logging.log4j", "log4j-core"],
-                ["ivyversions./org.apache.opennlp/opennlp-tools", "org.apache.opennlp", "opennlp-tools"],
-                ["ivyversions.org.apache.tika.version", "org.apache.tika", "tika-core"],
-                ["ivyversions.org.apache.zookeeper.version", "org.apache.zookeeper", "zookeeper"],
-
-                ["ivy-zookeeper-version", "org.apache.zookeeper", "zookeeper"],
-                ["ivy-log4j-version", "org.apache.logging.log4j", "log4j-core"],
-                ["ivy-tika-version", "org.apache.tika", "tika-core"],
-                ["ivy-opennlp-version", "org.apache.opennlp", "opennlp-tools"],
-                ["ivy-commons-codec-version", "commons-codec", "commons-codec"],
-                ["ivy-dropwizard-version", "io.dropwizard.metrics", "metrics-core"]
-        ].each { antProp, depGroup, depId ->
-            props[antProp] = getVersion(depGroup, depId, configurations.depVer)
+                ["ivyCommonsCodec", "commons-codec", "commons-codec"],
+                ["ivyDropwizardMetrics", "io.dropwizard.metrics", "metrics-core"],
+                ["ivyLog4j", "org.apache.logging.log4j", "log4j-core"],
+                ["ivyOpennlpTools", "org.apache.opennlp", "opennlp-tools"],
+                ["ivyTika", "org.apache.tika", "tika-core"],
+                ["ivyZookeeper", "org.apache.zookeeper", "zookeeper"],
+        ].each { p, depGroup, depId ->
+            templateProps[p] = getVersion(depGroup, depId, configurations.depVer)
         }
 
         // Emit info about properties for clarity.
-        logger.warn("Building ref guide with:\n" + props.collect({ k, v -> "  ${k} -> ${v}" }).join('\n'))
+        logger.warn("Building ref guide with:\n" + templateProps.collect({ k, v -> "  ${k} -> ${v}" }).join('\n'))
     }
 }
 
@@ -215,9 +186,7 @@ task prepareSources(type: Sync) {
     dependsOn setupLazyProps
 
     // If replaceable properties change, we have to rerun the task.
-    inputs.properties props
-
-    def dummyAntProject = new org.apache.tools.ant.Project()
+    inputs.properties templateProps
 
     from(file("src"), {
        exclude '**/*.template'
@@ -227,15 +196,9 @@ task prepareSources(type: Sync) {
         include '**/*.template'
         rename '(.+)\\.template', '$1'
         filteringCharset = 'UTF-8'
-        filter(org.apache.tools.ant.filters.ExpandProperties, project: dummyAntProject)
+        expand(templateProps)
     })
 
-    doFirst {
-        props.each { k, v ->
-          dummyAntProject.setProperty(k, v)
-        }
-    }
-
     into buildContentDir
 }
 
@@ -262,60 +225,6 @@ task buildNavDataFiles(type: JavaExec) {
     }
 }
 
-task bareBonesAsciiDoctor {
-    dependsOn buildNavDataFiles
-
-    doLast {
-        // Regenerate fully.
-        project.delete(bareBonesDir)
-        bareBonesDir.mkdirs()
-
-        // Convert each file separately so that folders are preserved.
-        Path source = buildContentDir.toPath().toAbsolutePath().normalize()
-        Path target = bareBonesDir.toPath().toAbsolutePath().normalize()
-
-        Asciidoctor adoc = Asciidoctor.Factory.create()
-        fileTree(source, {
-            include "**/*.adoc"
-            exclude "**/_*"
-        }).each { file ->
-            Path relative = source.relativize(file.toPath())
-            Path targetDir = target.resolve(relative).getParent()
-
-            def opts = OptionsBuilder.options()
-                    .backend('html5')
-                    .docType("book")
-                    .headerFooter(false)
-                    .safe(SafeMode.UNSAFE)
-                    .baseDir(source.toFile())
-                    .toDir(targetDir.toFile())
-                    .destinationDir(targetDir.toFile())
-                    .mkDirs(true)
-                    .attributes(asciiDocAttrs.common + asciiDocAttrs.html + props)
-
-            adoc.convertFile(file, opts)
-        }
-    }
-}
-
-task bareBonesHtmlValidation(type: JavaExec) {
-    dependsOn bareBonesAsciiDoctor
-    description("Builds (w/o Jekyll) a very simple html version of the guide and runs link/anchor validation on it")
-
-    classpath = sourceSets.main.runtimeClasspath
-    main = 'CheckLinksAndAnchors'
-    workingDir = buildContentDir
-
-    args([
-            "${bareBonesDir}",
-            "-bare-bones"
-    ])
-
-    if (project.hasProperty("local.javadocs")) {
-        args += "-check-all-relative-links"
-    }
-}
-
 task buildSiteJekyll(type: com.github.jrubygradle.JRubyExec) {
     dependsOn buildNavDataFiles
 
@@ -347,7 +256,7 @@ task buildSite(type: JavaExec) {
 }
 
 // Hook up custom tasks with standard tasks.
-check.dependsOn bareBonesHtmlValidation
+check.dependsOn buildSite
 
 // Do not hook site building to assemble, at least for now.
 // assemble.dependsOn buildSite
diff --git a/solr/solr-ref-guide/src/_config.yml.template b/solr/solr-ref-guide/src/_config.yml.template
index fb840c0..2791b83 100755
--- a/solr/solr-ref-guide/src/_config.yml.template
+++ b/solr/solr-ref-guide/src/_config.yml.template
@@ -1,7 +1,7 @@
 #
 #
 #
-# NOTE: Ant converts _config.yml.template into create _config.yml and performs ant property substitution.
+# NOTE: gradle converts _config.yml.template into create _config.yml and performs script engine substitutions
 #
 #
 #
@@ -68,22 +68,21 @@ asciidoc: {}
 # NOTE: If you add any attributes here for use in adoc files, you almost certainly need to also add
 # them to the <asciidoctor:convert/> ant task for precommit validation as well.
 solr-attributes: &solr-attributes-ref
-  solr-root-path: "../../../"
-  solr-guide-draft-status: "${solr-guide-draft-status}"
-  solr-guide-version: "${solr-guide-version}"
-  solr-guide-version-path: "${solr-guide-version-path}"
-  solr-docs-version: "${solr-docs-version}"
-  java-javadocs: "${javadoc.link}"
-  solr-javadocs: "${html-solr-javadocs}"
-  lucene-javadocs: "${html-lucene-javadocs}"
-  build-date: "${DSTAMP}"
-  build-year: "${current.year}"
-  ivy-commons-codec-version: "${ivyversions./commons-codec/commons-codec}"
-  ivy-dropwizard-version: "${ivyversions.io.dropwizard.metrics.version}"
-  ivy-log4j-version: "${ivyversions.org.apache.logging.log4j.version}"
-  ivy-opennlp-version: "${ivyversions./org.apache.opennlp/opennlp-tools}"
-  ivy-tika-version: "${ivyversions.org.apache.tika.version}"
-  ivy-zookeeper-version: "${ivyversions.org.apache.zookeeper.version}"
+  solr-root-path: "${solrRootPath}"
+  solr-guide-draft-status: "${solrGuideDraftStatus}"
+  solr-guide-version-path: "${solrGuideVersionPath}"
+  solr-docs-version: "${solrDocsVersion}"
+  java-javadocs: "${javadocLink}"
+  solr-javadocs: "${htmlSolrJavadocs}"
+  lucene-javadocs: "${htmlLuceneJavadocs}"
+  build-date: "${buildDate}"
+  build-year: "${buildYear}"
+  ivy-commons-codec-version: "${ivyCommonsCodec}"
+  ivy-dropwizard-version: "${ivyDropwizardMetrics}"
+  ivy-log4j-version: "${ivyLog4j}"
+  ivy-opennlp-version: "${ivyOpennlpTools}"
+  ivy-tika-version: "${ivyTika}"
+  ivy-zookeeper-version: "${ivyZookeeper}"
 
 asciidoctor:
   safe: 0
diff --git a/solr/solr-ref-guide/src/_includes/footer.html b/solr/solr-ref-guide/src/_includes/footer.html
index 910ad48..d11fd4a 100755
--- a/solr/solr-ref-guide/src/_includes/footer.html
+++ b/solr/solr-ref-guide/src/_includes/footer.html
@@ -2,7 +2,7 @@
             <div class="row">
                 <div class="col-lg-12 footer">
                &copy;{{ site.solr-attributes.build-year }} {{site.company_name}}. All rights reserved. <br />
-{% if page.last_updated %}<p>Page last updated:</span> {{page.last_updated}}<br/>{% endif %} Site Version: {{ site.solr-attributes.solr-guide-version }} <br />Site last generated: {{ site.solr-attributes.build-date }} <br />
+{% if page.last_updated %}<p>Page last updated:</span> {{page.last_updated}}<br/>{% endif %} Solr Version: {{ site.solr-attributes.solr-docs-version }} <br />Site last generated: {{ site.solr-attributes.build-date }} <br />
 <p><img src="{{ "images/solr-sunOnly-small.png" }}" alt="Apache Solr"/></p>
                 </div>
             </div>
diff --git a/solr/solr-ref-guide/src/_includes/head.html b/solr/solr-ref-guide/src/_includes/head.html
index da760d2..077bd6a 100755
--- a/solr/solr-ref-guide/src/_includes/head.html
+++ b/solr/solr-ref-guide/src/_includes/head.html
@@ -3,8 +3,7 @@
 <meta name="viewport" content="width=device-width, initial-scale=1">
 <meta name="description" content="{% if page.description %}{{ page.description | strip_html | strip_newlines | truncate: 160 }}{% endif %}">
 <meta name="keywords" content="{{page.tags}}{% if page.tags %}, {% endif %} {{page.keywords}}">
-{% comment %}NOTE: explicitly using the GUIDE version here (not solr) {% endcomment %}
-<title>{% if page_id != "index" %}{{ page.title }} | {% endif %}{{ site.site_title }} {{ site.solr-attributes.solr-guide-version}}</title>
+<title>{% if page_id != "index" %}{{ page.title }} | {% endif %}{{ site.site_title }} {{ site.solr-attributes.solr-docs-version}}</title>
 
 <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
 <link rel="stylesheet" type="text/css" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css">
diff --git a/solr/solr-ref-guide/src/css/navs.css b/solr/solr-ref-guide/src/css/navs.css
index 67273a7..1c50dfe 100644
--- a/solr/solr-ref-guide/src/css/navs.css
+++ b/solr/solr-ref-guide/src/css/navs.css
@@ -184,7 +184,7 @@ ul.nav li ul {
 
 /* end navgoco sidebar */
 
-/* When '-Dsolr-guide-version' is not set during the build, the Guide is
+/* When 'solr-guide-draft-status: DRAFT' is in _config.yml, the Guide is
    considered a Draft and includes a notice in the sidebar to that effect */
 
 .sidebar-header p.draft-notice {
diff --git a/solr/solr-ref-guide/src/meta-docs/publish.adoc b/solr/solr-ref-guide/src/meta-docs/publish.adoc
index bbe551a..70a8283 100644
--- a/solr/solr-ref-guide/src/meta-docs/publish.adoc
+++ b/solr/solr-ref-guide/src/meta-docs/publish.adoc
@@ -43,7 +43,7 @@ The build process generates the page hierarchy and builds the HTML pages with cu
 To build the HTML, from the top level of the project, run:
 
 [source,bash]
-$ gradlew clean solr:solr-ref-guide:buildSite
+$ ./gradlew clean solr:solr-ref-guide:buildSite
 
 This will produce pages with a DRAFT watermark across them. While these are fine for initial DRAFT publication, see the section <<Publish the Final Guide>> for steps to produce final production-ready HTML pages.
 
@@ -72,11 +72,9 @@ Since the Guide has already been uploaded to SVN, you need to overwrite the exis
 Build the Guide locally with a parameter for the Guide version. This requires the same <<Pre-Requisites,pre-requisites>> from above.
 
 [source,bash]
-$gradlew clean solr:solr-ref-guide:buildSite -PsolrGuideVersion=X.Y
+$ ./gradlew solr:solr-ref-guide:buildSite -PsolrGuideDraft=false
 
-where `X.Y` is the version you want to publish (i.e., `7.7`).
-
-IMPORTANT: The `-PsolrGuideVersion` system property is optional if you build drafts locally or as pre-publication DRAFTs (i.e., not for publication). By default the build system uses the `build.gradle` file in the current branch to identify the version and assumes this is a `DRAFT` build which will have a DRAFT watermark and other labels on the pages. Including the `-PsolrGuideVersion` system property ensures the DRAFT watermark and labels are removed from the HTML files.
+IMPORTANT: The `-PsolrGuideDraft` system property is optional if you build drafts locally or as pre-publication DRAFTs (i.e., not for publication). By default the build system assumes this is a `DRAFT` build which will have a DRAFT watermark and other labels on the pages. Including the `-PsolrGuideDraft=false` property ensures the DRAFT watermark and labels are removed from the HTML files.
 
 *Pull Production Repo and Upload New Files*