[英]Is it possible to generate the file 'build.xml' from the command line in Ant?
[英]Pass Command Line arguments to Apache Ant build file from DITAOT custom plugin
我正在尝试为 dita-ot 构建一个非常基本的自定义 html5 插件。 下面是我目前的设置。 这是我的 plugin.xml 文件。
插件.xml
<plugin id="html5-test" version="3.6.1">
<transtype name="html5-test" desc="testing html5 transformation with current setup." >
<param name="args.artlbl" desc="Specifies whether to generate a label for each image;" type="enum">
<val>yes</val>
<val default="true">no</val>
</param>
</transtype>
<feature extension="ant.import" file="build.xml" />
</plugin>
这里是 build.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:if="ant:if" xmlns:unless="ant:unless" name="dita2html5-test" default="get-parameters">
<target name="get-parameters">
<echoproperties/>
<!-- here I want to access CLI arguments for further use. --!>
<echo message="print value:${args.artlbl}"/>
</target>
控制台只显示文本,没有值。 我期待在那里看到“否”,因为它是默认值。 最终目标是在转换标签中获取 CLI arguments,然后将它们传递给 build.xml。 之后将其添加到属性中,然后在 ant xslt 任务中使用。
在plugin.xml
中配置参数默认值实际上并没有设置属性默认值。 DITA-OT 仅在为插件生成文档时使用这些信息。
您必须处理build.xml
中的默认值。 DITA-OT 内置插件使用以下约定:
<project>
<!--
This is the enty point DITA-OT will call when running html5-test.
In depends first call your own init target, then normal HTML5 target.
-->
<target name="dita2html5-test"
depends="html5-test.init,
dita2html5"/>
<target name="html5-test.init">
<!--
Since property values cannot be overwritten once set, this will only
set the value if there is no value set from the command line.
-->
<property name="args.artlbl" value="no"/>
</target>
</project>
所以最后我想通了。
dita -f html5 -i /test.dita -Done=abc
将“one”作为参数传递给 build.xml 文件。 在 build.xml 文件中,您将通过以下方式访问参数。 plugin.xml 文件无需更改。
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:if="ant:if" xmlns:unless="ant:unless" name="dita2html5-test" default="get-parameters">
<target name="get-parameters">
<echo>Embed another1:${one}</echo>
<echo message="print value:${args.artlbl}"/>
</target>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.