【问题标题】:Is it possible to specify logger for ant inside build.xml?是否可以在 build.xml 中为 ant 指定记录器?
【发布时间】:2011-04-19 19:20:02
【问题描述】:

是否可以在 build.xml 中指定 Ant listener/logger,而不是在命令行上?

【问题讨论】:

    标签: ant


    【解决方案1】:

    在构建文件中,可以使用 ant api 并通过 scriptdef 创建内部任务。
    即用 groovy 实现:

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

    还可以调整构建文件中的日志级别,请参阅:
    https://stackoverflow.com/a/5464009/130683
    https://stackoverflow.com/a/5479606/130683

    【讨论】:

      【解决方案2】:

      它不在构建文件中,但您可以设置 ANT_ARGS 环境变量来指定记录器

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

      【讨论】:

        【解决方案3】:

        【讨论】:

          【解决方案4】:
          <target name="real-build">
             <exec dir="${basedir}" executable="${ant.command}" failonerror="true">
              <arg line="-f build-all.xml target ${ant.logger}" />
             </exec>
          </target>
          

          【讨论】:

          • 这不在 build.xml 中,而是用一个新的 ant 实例打开一个新的 java 进程,类似于使用命令行选项 -logger .. btw。假设 ${ant.logger} 是 -logger ... 它应该是 arg line= ${ant.logger} -f ... => ant [options] [target [target2 [target3] ...]],见ant.apache.org/manual/running.html#options.
          猜你喜欢
          • 1970-01-01
          • 2011-06-26
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2022-11-01
          • 2012-06-18
          • 1970-01-01
          相关资源
          最近更新 更多