【问题标题】: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】:

    &lt;taskdef&gt; 任务之前读取属性文件。

    如果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>
    

    【讨论】:

      猜你喜欢
      • 2016-09-08
      • 1970-01-01
      • 2017-07-20
      • 2011-10-22
      • 1970-01-01
      • 2013-01-13
      • 2017-12-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多