我有一些RAML文件放在一个文件夹中,我正在设置一个ANT脚本,使用raml2html站点上的raml.org包将它们“构建”到raml.org文档中。
我刚接触过蚂蚁,所以我可能没有最有效地利用它,但这是次要的问题。我使用两个目标来实现这个目标,它们看起来如下(我省略了干净和init):
<!-- Look for the RAML, send them one at a time to post-build -->
<target name="build" depends="clean, init">
<echo message="searching for raml source in ${src}"/>
<foreach param="file" target="post-build">
<fileset dir="${src}">
<include name="**/*.raml"/>
</fileset>
</foreach>
</target>
<!-- Run raml2html on each of them, saving output in build/ -->
<target name="post-build" depends="">
<echo>file: ${file}</echo>
<substring text="${file}" parent-dir="${src}/" property="filename" />
<echo>filename: ${filename}</echo>
<echo>build-to: ${build}/${filename}</echo>
<exec executable="raml2html" failonerror="true">
<arg value="-i ${file}" />
<arg value="-o ${build}/${filename}" />
</exec>
</target> 当我运行ANT脚本:$ant build时,这两个目标返回以下内容:
build:
[echo] searching for raml source in /home/ryan/workspace/RAMLValidator/src
[foreach] The nested fileset element is deprectated, use a nested path instead
post-build:
[echo] file: /home/ryan/workspace/RAMLValidator/src/sample.raml
[echo] filename: sample.html
[echo] build-to: /home/ryan/workspace/RAMLValidator/build/sample.html
[exec] 2.0.2似乎我提供给<exec>的参数在途中被转换成了raml2html的-V选项,因为当我从终端运行$raml2html -V时,它的版本是2.0.2。当我从终端:$raml2html -i src/sample.raml -o build/sample.html显式运行相同的命令时,它生成的HTML与预期的完全相同.我怎么搞砸的?
发布于 2015-08-04 19:38:03
问题是,ANT将选项标志和标志的参数作为单独的实体处理,每个实体都需要自己的<arg />标记才能正常工作。
修改“构建后”目标中的exec任务,就像修正了问题一样:
<exec executable="raml2html" failonerror="true">
<arg value="-o" />
<arg value="${build}/${filename}"/>
<arg value="${file}" />
</exec>希望这能帮我节省一小部分时间!
https://stackoverflow.com/questions/31815610
复制相似问题