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

vladimirsitnikov pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/calcite.git


The following commit(s) were added to refs/heads/master by this push:
     new 5fd65a6  Make project buildable from folders that include special 
characters
5fd65a6 is described below

commit 5fd65a6b91bb123362c00d34a44b1bd6ae847a5b
Author: Vladimir Sitnikov <[email protected]>
AuthorDate: Wed Sep 30 22:08:10 2020 +0300

    Make project buildable from folders that include special characters
    
    String inside fmpp's tdd(...) expression needs quoting
---
 .../org/apache/calcite/buildtools/fmpp/FmppTask.kt      | 17 +++++++++++++----
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git 
a/buildSrc/subprojects/fmpp/src/main/kotlin/org/apache/calcite/buildtools/fmpp/FmppTask.kt
 
b/buildSrc/subprojects/fmpp/src/main/kotlin/org/apache/calcite/buildtools/fmpp/FmppTask.kt
index b968092..f591d7e 100644
--- 
a/buildSrc/subprojects/fmpp/src/main/kotlin/org/apache/calcite/buildtools/fmpp/FmppTask.kt
+++ 
b/buildSrc/subprojects/fmpp/src/main/kotlin/org/apache/calcite/buildtools/fmpp/FmppTask.kt
@@ -52,19 +52,28 @@ open class FmppTask @Inject constructor(
     val output = objectFactory.directoryProperty()
         .convention(project.layout.buildDirectory.dir("fmpp/$name"))
 
+    /**
+     * Path might contain spaces and TDD special characters, so it needs to be 
quoted.
+     * See http://fmpp.sourceforge.net/tdd.html
+     */
+    private fun String.tddString() =
+        "\"${toString().replace("\\", "\\\\").replace("\"", "\\\"")}\""
+
     @TaskAction
     fun run() {
         project.delete(output.asFileTree)
         ant.withGroovyBuilder {
-            "taskdef"("name" to "fmpp",
+            "taskdef"(
+                "name" to "fmpp",
                 "classname" to "fmpp.tools.AntTask",
-                "classpath" to fmppClasspath.get().asPath)
+                "classpath" to fmppClasspath.get().asPath
+            )
             "fmpp"(
                 "configuration" to config.get(),
                 "sourceRoot" to templates.get().asFile,
                 "outputRoot" to output.get().asFile,
-                "data" to "tdd(" + config.get() + "), " +
-                    "default: tdd(" + templates.get().asFile + 
"/../default_config.fmpp)"
+                "data" to "tdd(" + config.get().toString().tddString() + "), " 
+
+                    "default: tdd(" + 
"${templates.get().asFile}/../default_config.fmpp".tddString() + ")"
             )
         }
     }

Reply via email to