You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by to...@apache.org on 2020/07/20 13:00:30 UTC

[lucene-solr] branch jira/LUCENE-9312 updated: LUCENE-9312: set proper javadoc executable path (if Java runtime is specified).

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

tomoko pushed a commit to branch jira/LUCENE-9312
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git


The following commit(s) were added to refs/heads/jira/LUCENE-9312 by this push:
     new 964dad2  LUCENE-9312: set proper javadoc executable path (if Java runtime is specified).
964dad2 is described below

commit 964dad20de4fcafa44c50cc282b60b698b767489
Author: Tomoko Uchida <to...@gmail.com>
AuthorDate: Mon Jul 20 21:59:53 2020 +0900

    LUCENE-9312: set proper javadoc executable path (if Java runtime is specified).
---
 gradle/documentation/render-javadoc.gradle | 21 ++++++++++++++++-----
 gradle/testing/runtime-jvm-support.gradle  |  9 +++++++++
 2 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/gradle/documentation/render-javadoc.gradle b/gradle/documentation/render-javadoc.gradle
index 39f0ad8..e84370c 100644
--- a/gradle/documentation/render-javadoc.gradle
+++ b/gradle/documentation/render-javadoc.gradle
@@ -42,6 +42,11 @@ allprojects {
       srcDirSet = sourceSets.main.java;
 
       outputDir = project.javadoc.destinationDir;
+
+      // set javadoc command path when it passed via ext property
+      if (project.hasProperty("javadocCmdPath")) {
+        javadocCmdPath = project.javadocCmdPath
+      }
     }
 
     task renderSiteJavadoc(type: RenderJavadocTask) {
@@ -57,6 +62,10 @@ allprojects {
       // Place the documentation under Lucene or Solr's documentation directory.
       // docroot is defined in 'documentation.gradle'
       outputDir = project.docroot.toPath().resolve(project.relativeDocPath).toFile()
+
+      if (project.hasProperty("javadocCmdPath")) {
+        javadocCmdPath = project.javadocCmdPath
+      }
     }
   }
 }
@@ -150,6 +159,9 @@ class RenderJavadocTask extends DefaultTask {
 
   @Input
   def solrDocUrl = "${->project.solrDocUrl}"
+
+  @Input
+  def javadocCmdPath = org.gradle.internal.jvm.Jvm.current().getJavadocExecutable().toString()
   
   /** Utility method to recursively collect all tasks with same name like this one that we depend on */
   private Set findRenderTasksInDependencies() {
@@ -165,11 +177,7 @@ class RenderJavadocTask extends DefaultTask {
 
   @TaskAction
   public void render() {
-    // TODO: add 'String executable' property, much like Gradle's built-in javadoc.
-    // resolve lazily to the current JVM's javadoc executable (using the public new API).
-    // the runtime-jvm-support.gradle should then lazily modify this
-    // property if alt jvm is requested (the logic to set alt jvm should be there, not here).
-    def javadocCmd = org.gradle.internal.jvm.Jvm.current().getJavadocExecutable()
+    def javadocCmd = project.file(javadocCmdPath)
 
     def srcDirs = srcDirSet.srcDirs.findAll { dir -> dir.exists() }
     def optionsFile = project.file("${getTemporaryDir()}/javadoc-options.txt")
@@ -277,6 +285,9 @@ class RenderJavadocTask extends DefaultTask {
         ignoreExitValue true
       }
     }
+    outputFile.withWriterAppend { output ->
+      output.write("\n--------\nJavadoc command path: ${javadocCmd}\n")
+    }
 
     if (result.getExitValue() != 0) {
       // Pipe the output to console. Intentionally skips any encoding conversion 
diff --git a/gradle/testing/runtime-jvm-support.gradle b/gradle/testing/runtime-jvm-support.gradle
index 11d720f..0f9cc85 100644
--- a/gradle/testing/runtime-jvm-support.gradle
+++ b/gradle/testing/runtime-jvm-support.gradle
@@ -62,6 +62,15 @@ if (!currentJvm.javaExecutable.equals(altJvm.javaExecutable)) {
       options.forkOptions.javaHome = altJvm.installationDirectory.asFile
     }
 
+    plugins.withType(JavaPlugin) {
+      ext {
+        // there's no property 'altJvm.javadocExecutable'; retrieve 'javadoc' command file
+        javadocCmdPath = altJvm.installationDirectory.file("bin/javadoc").toString()
+      }
+      tasks.matching { it.name == "renderJavadoc" || it.name == "renderSiteJavadoc" }.all {
+        dependsOn ":altJvmWarning"
+      }
+    }
     // Look at Elasticsearch's code; there are caveats concerning build artifact caching
     // (we don't use it at the moment, but who knows).
     // TODO: Any javadoc calls?