Is it possible to specify logger for ant inside bu

2020-02-12 05:31发布

问题:

Is it possible specify Ant listener/logger inside build.xml, not on a command line?

回答1:

Within the buildfile it's possible to make use of the ant api and create an internal task via scriptdef.
i.e. implemented with groovy:

http://josefbetancourt.wordpress.com/2011/08/18/buildlistener-groovy-scriptdef/ http://octodecillion.com/blog/buildlistener-groovy-scriptdef/

It's also possible to adjust the loglevel inside the buildfile, see :
https://stackoverflow.com/a/5464009/130683
https://stackoverflow.com/a/5479606/130683



回答2:

It's not in the build file, but you can set the ANT_ARGS env variable to specify the logger

http://wiki.apache.org/ant/TheElementsOfAntStyle



回答3:

Take a look at the Recorder task. http://ant.apache.org/manual/Tasks/recorder.html



回答4:

<target name="real-build">
   <exec dir="${basedir}" executable="${ant.command}" failonerror="true">
    <arg line="-f build-all.xml target ${ant.logger}" />
   </exec>
</target>


标签: ant