This is an automated email from the ASF dual-hosted git repository.
hossman pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/solr.git
The following commit(s) were added to refs/heads/main by this push:
new 6132d7c Use lucene javadoc link derived from lucene maven dep version
6132d7c is described below
commit 6132d7ce6e180dc03b66ab957569f972ea2d8586
Author: Chris Hostetter <[email protected]>
AuthorDate: Fri Mar 19 11:03:09 2021 -0700
Use lucene javadoc link derived from lucene maven dep version
Since (resolved) dep versions aren't available at gradle config time, this
involves a fair bit of refactoring to use lazy properties
Closes #34
Co-authored-by: Dawid Weiss <[email protected]>
---
gradle/documentation/documentation.gradle | 31 ++------
gradle/documentation/markdown.gradle | 2 +-
gradle/documentation/render-javadoc.gradle | 16 ++--
solr/solr-ref-guide/build.gradle | 117 ++++++++++++-----------------
4 files changed, 64 insertions(+), 102 deletions(-)
diff --git a/gradle/documentation/documentation.gradle
b/gradle/documentation/documentation.gradle
index 756234f..6d2b684 100644
--- a/gradle/documentation/documentation.gradle
+++ b/gradle/documentation/documentation.gradle
@@ -20,24 +20,18 @@ configure(rootProject) {
def refguideUrlVersion =
project.baseVersion.replaceFirst(/^(\d+)\.(\d+).*$/, '$1_$2')
ext {
- // TODO: The url should be constructed from actual dependency version...
but this isn't available
- // at evaluation time. it'd have to be a lazy property provider.
+ // NOTE: The actual dependency version isn't available at configuration
time, so we use a lazy property provider to
+ // supply it at execution time.
//
- // There are actually two questions -
- // 1) what to do about links to yet-unreleased Lucene versions and
- // 2) forgot what the second question was...
- //
- // For now, just hardcode the latest released version.
- // We could download Lucene javadoc artifacts for the actual dependency
and just
- // link it locally (and publish it on Solr site). This would ensure the
docs are always up-to-date,
- // even for Lucene snapshots.
- luceneDocVersion = "9_0_0-SNAPSHOT"
- luceneDocUrl = project.propertyOrDefault('lucene.javadoc.url',
"https://lucene.apache.org/core/${luceneDocVersion}")
+ // In the case of a 'SNAPSHOT' luceneDocVersion this URL won't actually
exist, but that shouldn't mater since
+ // we can't release Solr pointed at a Lucene SNAPSHOT, so we won't be
publishing in this state...
+ luceneDocUrl = project.propertyOrDefault('lucene.javadoc.url',
+ "https://lucene.apache.org/core/${-> getVersion("org.apache.lucene",
"lucene-core").replace('.', '_')}")
solrDocUrl = project.propertyOrDefault('solr.javadoc.url', {
if (project.version != project.baseVersion) {
- // non-release build
- new File(project('solr:documentation').buildDir,
'site').toURI().toASCIIString().minus(~'/$')
+ // non-release build does not cross-link between modules.
+ return null
} else {
// release build
"https://solr.apache.org/docs/${urlVersion}"
@@ -52,15 +46,6 @@ configure(rootProject) {
description = 'Generate all documentation'
dependsOn ':solr:documentation:assemble'
-
- doFirst {
- // Sanity check doc. version vs. actual version.
- def actualLuceneVersion = getVersion("org.apache.lucene",
"lucene-core").replace('.', '_')
- if (luceneDocVersion != actualLuceneVersion) {
- throw new GradleException("Compiling documentation with Lucene version
${luceneDocVersion} which is " +
- "different from actual dependency ${actualLuceneVersion}?")
- }
- }
}
assemble.dependsOn documentation
diff --git a/gradle/documentation/markdown.gradle
b/gradle/documentation/markdown.gradle
index 0f5bc3c..7112362 100644
--- a/gradle/documentation/markdown.gradle
+++ b/gradle/documentation/markdown.gradle
@@ -80,7 +80,7 @@ configure(project(':solr:documentation')) {
// list all properties used by the template here to allow uptodate checks
to be correct:
inputs.property('version', project.version)
- inputs.property('solrDocUrl', project.solrDocUrl)
+ inputs.property('solrDocUrl', project.solrDocUrl).optional(true)
}
}
diff --git a/gradle/documentation/render-javadoc.gradle
b/gradle/documentation/render-javadoc.gradle
index 5338cca..a0a35b2 100644
--- a/gradle/documentation/render-javadoc.gradle
+++ b/gradle/documentation/render-javadoc.gradle
@@ -46,7 +46,7 @@ allprojects {
}
task renderJavadoc(type: RenderJavadocTask) {
- description "Generates Javadoc API documentation for the main source
code. This directly invokes javadoc tool."
+ description "Generates Javadoc API documentation for each module. This
directly invokes javadoc tool."
group "documentation"
taskResources = resources
@@ -89,6 +89,8 @@ allprojects {
"https://junit.org/junit4/javadoc/4.12/": junitJavadocPackages
]
+ solrDocUrl = provider({ rootProject.solrDocUrl })
+
// Set up custom doclet.
dependsOn configurations.missingdoclet
docletpath = configurations.missingdoclet
@@ -211,10 +213,8 @@ class RenderJavadocTask extends DefaultTask {
def offlineLinks = [:]
@Input
- def luceneDocUrl = "${-> project.luceneDocUrl }"
-
- @Input
- def solrDocUrl = "${-> project.solrDocUrl }"
+ @Optional
+ Property<String> solrDocUrl = project.objects.property(String)
// default is to require full javadocs
@Input
@@ -228,7 +228,6 @@ class RenderJavadocTask extends DefaultTask {
@Input
List<String> javadocMissingIgnore = []
-
@Nullable
@Optional
@Input
@@ -321,7 +320,10 @@ class RenderJavadocTask extends DefaultTask {
opts << ['-link', relative]
} else {
// For absolute links, we determine the target URL by assembling
the full URL.
-
allOfflineLinks.put("${solrDocUrl}/${otherProject.relativeDocPath}/".toString(),
otherTask.outputDir)
+ def value = solrDocUrl.getOrElse(null)
+ if (value) {
+
allOfflineLinks.put("${value}/${otherProject.relativeDocPath}/".toString(),
otherTask.outputDir)
+ }
}
}
}
diff --git a/solr/solr-ref-guide/build.gradle b/solr/solr-ref-guide/build.gradle
index 06b2628..00b0e98 100644
--- a/solr/solr-ref-guide/build.gradle
+++ b/solr/solr-ref-guide/build.gradle
@@ -121,8 +121,7 @@ ext {
desc: 'HTML Site for publishing to the Solr website',
props: [
htmlSolrJavadocs:
"https://solr.apache.org/docs/${solrGuideVersionPath}_0/",
- // TODO: This isn't viable long term - see SOLR-15262 / SOLR-15264
- htmlLuceneJavadocs:
"https://lucene.apache.org/core/${solrGuideVersionPath}_0/"
+ htmlLuceneJavadocs: project(':solr:documentation').luceneDocUrl
]
]
linkCheckSiteDetails =
@@ -147,12 +146,34 @@ ext {
[ htmlSiteDetails, linkCheckSiteDetails ].each{ details ->
final def contentDir = file("${buildDir}/${details.path}-content")
final def htmlDir = file("${buildDir}/${details.path}")
- final def extraProps = details.props.clone()
- extraProps.htmlOutDir = "../${details.path}"
- task "prepare${details.name}Sources"(type: PrepareSources) {
- outDir contentDir
- props extraProps
+ tasks.create("prepare${details.name}Sources", PrepareSources) {
+ // configure task properties.
+ srcDir.set(project.sourceSets.refGuide.resources.srcDirs.first())
+ outDir.set(contentDir)
+
+ // Set these dependency versions as lazy gstrings so that they're
resolved after evaluation.
+ def dependencyProps = [
+ ["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"],
+ ].collectEntries { propKey, depGroup, depId -> [propKey, "${ ->
project.getVersion(depGroup, depId) }"] }
+
+ props.putAll([
+ htmlOutDir: "../${details.path}",
+ 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 : project.ext['solrDocsVersion'],
+ solrGuideVersionPath : project.ext['solrGuideVersionPath'],
+ buildDate : rootProject.ext['buildDate'],
+ buildYear : rootProject.ext['buildYear'],
+ * : details.props,
+ * : dependencyProps
+ ])
}
task "build${details.name}"(type: com.github.jrubygradle.JRubyExec) {
@@ -192,85 +213,36 @@ check.dependsOn checkLocalJavadocLinksSite, checkSite
assemble.dependsOn buildSite
abstract class PrepareSources extends DefaultTask {
-
- /** Original Source files we'll be syncing <b>FROM</b> */
+ // Original Source files we'll be syncing <b>FROM</b>
@InputDirectory
- public File getSrcDir() {
- return getProject().file("src")
- }
+ public DirectoryProperty srcDir = project.objects.directoryProperty()
- /**
- * Where we sync the source files <b>TO</b>
- */
- public void setOutDir(File outDir) {
- this.outDir = outDir;
- getOutputs().dir(outDir);
- }
- public File outDir;
+ // Destination folder.
+ @OutputDirectory
+ public DirectoryProperty outDir = project.objects.directoryProperty()
/**
- * Task specific props
+ * Task specific props (lazy provider)
*/
@Input
- public Map<String,String> getProps() {
- return props;
- }
- public void setProps(Map<String,String> props) {
- this.props = props;
- }
- private Map<String,String> props;
-
- /**
- * Basic properties that should be the same for all tasks of this type
- */
- @Input
- public Map<String,String> getStandardProps() {
- final Project p = getProject();
- return [
- javadocLink :
"https://docs.oracle.com/en/java/javase/11/docs/api/",
- solrGuideDraftStatus : p.propertyOrDefault('solrGuideDraft',
"true").toBoolean() ? "DRAFT" : "",
- solrRootPath : p.project(':solr').projectDir.toString() +
File.separator,
- solrDocsVersion : p.property('solrDocsVersion'),
- solrGuideVersionPath : p.property('solrGuideVersionPath'),
- buildDate : p.property('buildDate'),
- buildYear : p.property('buildYear'),
- ];
- }
+ public MapProperty<String, String> props =
project.objects.mapProperty(String, String)
public PrepareSources() {
// setup 'dependsOn classes, configurations.depVer' here
- // so that it's not neccessary for every task impl to declare
redundently
- final Project p = getProject();
+ // so that it's not necessary for every task impl to declare
redundantly
+ final Project p = getProject()
dependsOn(p.getConfigurations().getByName('depVer'))
dependsOn(p.getTasksByName('classes', false))
-
}
@TaskAction
public void doCopy() {
final Project p = getProject();
- final Configuration depVer = p.getConfigurations().getByName('depVer');
- // start with any task (instance) specific props.
- final def props = getProps().clone();
- // then add/override with anystandard props that should alwasy be used
- getStandardProps().each { k, v -> props[k] = v };
+ // Make a local copy we'll be modifying.
+ final def props = this.props.get()
- // 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.
But as this task
- // depends on the configuration, it's used correctly
- [
- ["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 { prop, depGroup, depId ->
- props[prop] = p.getVersion(depGroup, depId, depVer)
- }
-
- final File intoDir = this.outDir;
+ final File intoDir = this.outDir.asFile.get();
// Emit info about properties for clarity.
logger.lifecycle('Syncing source files to {} using props:\n{}',
@@ -279,19 +251,22 @@ abstract class PrepareSources extends DefaultTask {
// Escape all the properties, so they can be inserted into YAML
templates.
final def escapedProps = props.collectEntries{k, v -> [k,
v.replace("'","''")]}
+ def sourceDir = srcDir.get()
+
final WorkResult syncResult = p.sync({ copySpec ->
copySpec.setFilteringCharset('UTF-8');
- copySpec.from(getSrcDir(), { raw ->
+ copySpec.from(sourceDir, { raw ->
raw.exclude('**/*.template')
})
- copySpec.from(getSrcDir(), { templated ->
+ copySpec.from(sourceDir, { templated ->
templated.include('**/*.template')
templated.rename('(.+)\\.template', '$1')
templated.expand(escapedProps)
})
copySpec.into(intoDir);
- });
+ })
+
setDidWork(syncResult.getDidWork());
if (syncResult.getDidWork()) {
// if sync did work, that means we need to rebuild the nav data
files...