怎么说ant配置文件在那个文件夹中

时间:2014-08-25 08:07:14

标签: java ant slf4j logback

我有如下所示的项目结构,我正在尝试编写ant build文件。我的问题是如何说build.xml配置文件的logback在conf文件夹中?

项目层次结构

project
  | - - - src
  | - - - lib
  | - - - conf
           | - - - logback.xml
  | - - - ant
           | - - - build.xml
  | - - - rsc
           | - - - input.txt

我写过

<path   id="classpath">
        <fileset    dir="${lib.dir}"
                    includes="**/*.jar" />
</path>


<!--- init used to create a requirred directories -->               

<target name="compile"  depends="init">
    <javac  srcdir="${src.dir}" 
            destdir="${build.dir}/classes">
            <classpath refid="classpath" />
    </javac>
</target>

<target name="run" depends="compile">
    <!-- ? what should be written -->           

</target>

2 个答案:

答案 0 :(得分:1)

假设您的conf.dir属性指向${base.dir}/conf

<!-- Absolute path to logback conf file -->
<property name="logback.conf.file.abs.path" location="${conf.dir}/logback.xml"/>

运行 -target:

<target name="run" depends="compile">
    <java failonerror="yes" classname="your.main.class.name.Here">
        <arg line="-Dlogback.configurationFile=${logback.conf.file.abs.path}"/>
    </java>
</target>

答案 1 :(得分:0)

您可以在ant call

上使用启动参数设置文件
-Dlogback.configurationFile=conf/logback.xml

如果您使用antrunner,您可能会说

c:>antrunner -Dlogback.configurationFile=conf/logback.xml build.xml