Apache Solr open-source search software
LUCENE-9321: Fix offline link base url for snapshot build (#1695)
Tomoko Uchida5d46361024bc
diff --git a/gradle/documentation/documentation.gradle b/gradle/documentation/documentation.gradleindex fdc7107af93..eb5c46324d0 100644--- a/gradle/documentation/documentation.gradle+++ b/gradle/documentation/documentation.gradle@@ -18,10 +18,28 @@configure(rootProject) {def urlVersion = project.baseVersion.replace('.', '_')def refguideUrlVersion = project.baseVersion.replaceFirst(/^(\d+)\.(\d+).*$/, '$1_$2')-+ext {- luceneDocUrl = project.propertyOrDefault('lucene.javadoc.url', "https://lucene.apache.org/core/${urlVersion}")- solrDocUrl = project.propertyOrDefault('solr.javadoc.url', "https://lucene.apache.org/solr/${urlVersion}")+ luceneDocUrl = project.propertyOrDefault('lucene.javadoc.url', {+ if (project.version != project.baseVersion) {+ // non-release build+ project('lucene').file('build/documentation').toURI().toASCIIString()+ } else {+ // release build+ "https://lucene.apache.org/core/${urlVersion}"+ }+ }())++ solrDocUrl = project.propertyOrDefault('solr.javadoc.url', {+ if (project.version != project.baseVersion) {+ // non-release build+ project('solr').file('build/documentation').toURI().toASCIIString()+ } else {+ // release build+ "https://lucene.apache.org/solr/${urlVersion}"+ }+ }())+solrRefguideUrl = project.propertyOrDefault('solr.refguide.url', "https://lucene.apache.org/solr/guide/${refguideUrlVersion}")}diff --git a/gradle/documentation/render-javadoc.gradle b/gradle/documentation/render-javadoc.gradleindex 27d282bc44f..0a9ddb273f3 100644--- a/gradle/documentation/render-javadoc.gradle+++ b/gradle/documentation/render-javadoc.gradle@@ -213,23 +213,28 @@ class RenderJavadocTask extends DefaultTask {// - find all (enabled) tasks this tasks depends on (with same name), calling findRenderTasksInDependencies()// - sort the tasks preferring those whose project name equals 'core', then lexigraphical by path// - for each task get output dir to create relative or absolute link- findRenderTasksInDependencies()- .sort(false, Comparator.comparing{ (it.project.name != 'core') as Boolean }.thenComparing(Comparator.comparing{ it.path }))- .each{ otherTask ->- def otherProject = otherTask.project- // For relative links we compute the actual relative link between projects.- def crossLuceneSolr = (otherProject.docroot != project.docroot)- if (relativeProjectLinks && !crossLuceneSolr) {- def pathTo = otherTask.outputDir.toPath().toAbsolutePath()- def pathFrom = outputDir.toPath().toAbsolutePath()- def relative = pathFrom.relativize(pathTo).toString().replace(File.separator, '/')- opts << [ '-link', relative ]- } else {- // For absolute links, we determine the target URL by assembling the full URL.- def base = otherProject.path.startsWith(":lucene") ? luceneDocUrl : solrDocUrl- allOfflineLinks.put("${base}/${otherProject.relativeDocPath}/".toString(), otherTask.outputDir)+ // NOTE: explicitly exclude solr/test-framework, or attempting to link to lucene-test-framework because if we did javadoc would+ // attempt to link class refs in in org.apache.lucene, causing broken links. (either broken links to things like "Directory" if+ // lucene-test-framework was first, or broken links to things like LuceneTestCase if lucene-core was first)+ if (project.path != ':solr:test-framework') { //+ findRenderTasksInDependencies()+ .sort(false, Comparator.comparing { (it.project.name != 'core') as Boolean }.thenComparing(Comparator.comparing { it.path }))+ .each { otherTask ->+ def otherProject = otherTask.project+ // For relative links we compute the actual relative link between projects.+ def crossLuceneSolr = (otherProject.docroot != project.docroot)+ if (relativeProjectLinks && !crossLuceneSolr) {+ def pathTo = otherTask.outputDir.toPath().toAbsolutePath()+ def pathFrom = outputDir.toPath().toAbsolutePath()+ def relative = pathFrom.relativize(pathTo).toString().replace(File.separator, '/')+ opts << ['-link', relative]+ } else {+ // For absolute links, we determine the target URL by assembling the full URL.+ def base = otherProject.path.startsWith(":lucene") ? luceneDocUrl : solrDocUrl+ allOfflineLinks.put("${base}/${otherProject.relativeDocPath}/".toString(), otherTask.outputDir)+ }}- }+ }// Add offline links.allOfflineLinks.each { url, dir ->