我的项目结构如下所示,我正在尝试编写 ant 构建文件。我的问题是我怎么能说 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>
最佳答案
假设您有一个指向 ${base.dir}/conf
的 conf.dir
属性:
<!-- Absolute path to logback conf file -->
<property name="logback.conf.file.abs.path" location="${conf.dir}/logback.xml"/>
运行-目标:
<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>
关于java - 如何说 ant 配置文件位于该文件夹中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25481561/