You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by th...@apache.org on 2020/09/14 16:38:27 UTC

[lucene-solr] 09/39: LUCENE-9474: make externalTool a function and add a build-stopping message on Windows for snowball generator.

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

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

commit 4f2ef00efa234f69e9265ceee06442bc7ff82a98
Author: Dawid Weiss <da...@carrotsearch.com>
AuthorDate: Sun Aug 30 17:10:18 2020 +0200

    LUCENE-9474: make externalTool a function and add a build-stopping message on Windows for snowball generator.
---
 build.gradle                                | 12 ++++++------
 gradle/documentation/changes-to-html.gradle |  2 +-
 gradle/generation/jflex.gradle              |  2 +-
 gradle/generation/snowball.gradle           |  8 +++++++-
 gradle/generation/util.gradle               |  4 ++--
 gradle/validation/check-broken-links.gradle |  5 +----
 gradle/validation/missing-docs-check.gradle |  2 +-
 7 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/build.gradle b/build.gradle
index 4c8209a..9801e06 100644
--- a/build.gradle
+++ b/build.gradle
@@ -90,12 +90,12 @@ ext {
       "flexmark": "0.61.24",
   ]
   
-  // read some external tool locations from system props
-  externalToolExecutables = [
-      "python3": propertyOrDefault('python3.exe', 'python3'),
-      "python2": propertyOrDefault('python2.exe', 'python2'),
-      "perl": propertyOrDefault('perl.exe', 'perl'),
-  ]
+  // Allow definiting external tool locations using system props.
+  externalTool = { name ->
+    def resolved = propertyOrDefault("${name}.exe", name as String)
+    logger.info("External tool '${name}' resolved to: ${resolved}")
+    return resolved
+  }
 }
 
 // Include smaller chunks configuring dedicated build areas.
diff --git a/gradle/documentation/changes-to-html.gradle b/gradle/documentation/changes-to-html.gradle
index 5f56532..b49ae93 100644
--- a/gradle/documentation/changes-to-html.gradle
+++ b/gradle/documentation/changes-to-html.gradle
@@ -54,7 +54,7 @@ class ChangesToHtmlTask extends DefaultTask {
   def toHtml(File versionsFile) {
     def output = new ByteArrayOutputStream()
     def result = project.exec {
-      executable project.externalToolExecutables["perl"]
+      executable project.externalTool("perl")
       standardInput changesFile.newInputStream()
       standardOutput project.file("${targetDir.get().getAsFile()}/Changes.html").newOutputStream()
       errorOutput = output
diff --git a/gradle/generation/jflex.gradle b/gradle/generation/jflex.gradle
index 1f5feb2..e7c65df 100644
--- a/gradle/generation/jflex.gradle
+++ b/gradle/generation/jflex.gradle
@@ -149,7 +149,7 @@ configure(project(":lucene:analysis:common")) {
       def target = file('src/java/org/apache/lucene/analysis/charfilter/HTMLCharacterEntities.jflex')
       target.withOutputStream { output ->
         project.exec {
-          executable = project.externalToolExecutables["python2"]
+          executable = project.externalTool("python2")
           workingDir = target.parentFile
           standardOutput = output
           args += [
diff --git a/gradle/generation/snowball.gradle b/gradle/generation/snowball.gradle
index b2b6882..b7b37c4 100644
--- a/gradle/generation/snowball.gradle
+++ b/gradle/generation/snowball.gradle
@@ -15,6 +15,8 @@
  * limitations under the License.
  */
 
+import org.apache.tools.ant.taskdefs.condition.Os
+
 apply plugin: "de.undercouch.download"
 
 configure(rootProject) {
@@ -99,8 +101,12 @@ configure(project(":lucene:analysis:common")) {
     dependsOn downloadSnowballData
 
     doLast {
+      if (Os.isFamily(Os.FAMILY_WINDOWS)) {
+        throw GradleException("Snowball generation does not work on Windows, use a platform where bash is available.")
+      }
+
       project.exec {
-        executable "bash" // TODO: does not work with windows, use project.externalToolExecutables[] instead
+        executable "bash"
         args = [snowballScript, snowballStemmerDir, snowballWebsiteDir, snowballDataDir, projectDir]
       }
     }
diff --git a/gradle/generation/util.gradle b/gradle/generation/util.gradle
index d1a3c24..36ad86b 100644
--- a/gradle/generation/util.gradle
+++ b/gradle/generation/util.gradle
@@ -57,7 +57,7 @@ configure(project(":lucene:core")) {
         logger.lifecycle("Executing: ${prog} in ${targetDir}")
         project.exec {
           workingDir targetDir
-          executable project.externalToolExecutables["python3"]
+          executable project.externalTool("python3")
           args = ['-B', "${prog}"]
         }
       }
@@ -82,7 +82,7 @@ configure(project(":lucene:core")) {
         ['True', 'False'].each { transpose ->
           project.exec {
             workingDir targetDir
-            executable project.externalToolExecutables["python3"]
+            executable project.externalTool("python3")
             args = ['-B', 'createLevAutomata.py', num, transpose, "${momanDir}/finenight/python"]
           }
         }
diff --git a/gradle/validation/check-broken-links.gradle b/gradle/validation/check-broken-links.gradle
index 2810475..ed83a86 100644
--- a/gradle/validation/check-broken-links.gradle
+++ b/gradle/validation/check-broken-links.gradle
@@ -16,7 +16,6 @@
  */
 
 configure(rootProject) {
-
   task checkBrokenLinks {
     group 'Verification'
     description 'Check broken links in the entire documentation'
@@ -24,10 +23,8 @@ configure(rootProject) {
     dependsOn ':lucene:checkBrokenLinks'
     dependsOn ':solr:checkBrokenLinks'
   }
-
 }
 configure(subprojects.findAll { it.path in [':lucene', ':solr'] }) {
-
   task checkBrokenLinks(type: CheckBrokenLinksTask, 'dependsOn': 'documentation')
 
   // TODO: uncomment this line after fixing all broken links.
@@ -52,7 +49,7 @@ class CheckBrokenLinksTask extends DefaultTask {
     def result
     outputFile.withOutputStream { output ->
       result = project.exec {
-        executable project.externalToolExecutables["python3"]
+        executable project.externalTool("python3")
         ignoreExitValue = true
         standardOutput = output
         errorOutput = output
diff --git a/gradle/validation/missing-docs-check.gradle b/gradle/validation/missing-docs-check.gradle
index e9cb6ae..781208a 100644
--- a/gradle/validation/missing-docs-check.gradle
+++ b/gradle/validation/missing-docs-check.gradle
@@ -89,7 +89,7 @@ class CheckMissingDocsTask extends DefaultTask {
   def checkMissingJavadocs(File dir, String level) {
     def output = new ByteArrayOutputStream()
     def result = project.exec {
-      executable project.externalToolExecutables["python3"]
+      executable project.externalTool("python3")
       ignoreExitValue = true
       standardOutput = output
       errorOutput = output