【问题标题】:read properties file inside ant taskdef读取ant taskdef中的属性文件
【发布时间】:2015-11-25 15:10:17
【问题描述】:
我正在定义一个 build.xml 文件,我需要从属性文件中读取一些路径。在我定义的目标上读取它是可以的。当我尝试读取 taskdef 中的值时,问题就来了。我怎样才能做到这一点?
我有这样的事情:
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath>
<fileset dir="${paths.jaxb.lib}" includes="*.jar" />
</classpath>
</taskdef>
我的“paths.jaxb.lib”是 jaxb lib 文件夹的路径。如何从我的 paths.properties 文件中获取此值?
【问题讨论】:
标签:
ant
properties
properties-file
taskdef
【解决方案1】:
在<taskdef> 任务之前读取属性文件。
如果paths.properties 是……
paths.jaxb.lib=path/to/my/jaxb/lib
...然后在build.xml...
<!-- Loading the Java properties file sets the paths.jaxb.lib Ant property. -->
<property file="paths.properties"/>
<taskdef name="xjc" classname="com.sun.tools.xjc.XJCTask">
<classpath>
<fileset dir="${paths.jaxb.lib}" includes="*.jar" />
</classpath>
</taskdef>