【问题标题】:Ant - String duplication in concat target in a macrodef - WhyAnt - 宏定义中 concat 目标中的字符串重复 - 为什么
【发布时间】:2019-04-01 16:31:54
【问题描述】:

我在 ant 宏定义中使用 concat 目标来生成 ddl 文件。一些属性字符串中的一部分字符串在生成的 ddl 中重复。

只有在从 concat 目标生成时才会观察到这种重复。

我尝试过 1) 使用破折号而不是下划线,2) 使用 ${property-name} 而不是 @{property-name},3) 使用 echo 目标而不是 concat 目标,4) 从 ant 1.9 切换。 3 到 1.10.5,以及 5) 进行在线搜索

在 ant 脚本中设置属性 <property name="SCHEMA_ID" value="REPLACE_SCHEMA_ID" />

在宏定义中设置的属性 <attribute name="schema-id" default="${SCHEMA_ID}" />

连接目标

<concat destfile="@{dest-dir}/@{spname}.ddl">
SET CURRENT SCHEMA = '@{schema-id}'
@@@@
SET CURRENT SQLID = '@{sql-id}'
@@@@
</concat>

ddl 文件中的输出行 SET CURRENT SCHEMA = 'REPLACE_REPLACE_SCHEMA_ID'

我希望 ddl 文件中的输出行是: SET CURRENT SCHEMA = 'REPLACE_SCHEMA_ID'

【问题讨论】:

    标签: apache ant concat macrodef


    【解决方案1】:

    据我所知,在使用 echo 或 concat 时(至少在宏定义中)存在一个错误,如果属性名称等于属性值的一部分,则值的一部分不匹配名字重复了。

    <property name="SCHEMA_ID" value="REPLACE_SCHEMA_ID" /> becomes REPLACE_REPLACE_SCHEMA_ID
    <property name="SCHEMA_ID" value="@SCHEMA_ID@" /> becomes @@SCHEMA_ID@@
    

    但是 &lt;property name="SCHEMA_ID" value="@schema_id@" /&gt; becomes @schema_id@

    奇怪的行为,我很容易被证明是错误的,但这就是我想出的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-21
      • 2015-09-14
      • 2012-09-20
      • 1970-01-01
      • 2019-01-08
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多