覆盖编译器属性在Ant javac任务 [英] Override the compiler attribute in an Ant javac task

查看:113
本文介绍了覆盖编译器属性在Ant javac任务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图重写蚂蚁编译器通过命令行,使所有的javac任务使用我指定的编译器属性。
我碰到的问题是,设置自己的价值为编译器的任何目标将覆盖我设置在条命令行之一。所以,即使我输入以下命令。

I'm trying to override Ant compiler attributes via the command line so that all 'javac' tasks use my specified compiler. The problem I've run into is that any target that sets its own value for compiler overrides the one that I set at the commmand line. So, even though I'm entering the following command.

ant -Dbuild.compiler=mycompiler  

这有以下任何​​目标是要运用现代的编译器,而不是mycompiler因为编译器=现代属性

Any target that has the following is going to use the modern compiler instead of mycompiler because of that compiler="modern" attribute

<javac srcdir="."  
       destdir="${classes.dir}/core"  
       compiler="modern"  
       encoding="UTF-8">  
    <include name="org/**" />  
    <include name="com/**" />  
    <compilerarg line="${config.build.compilerarg}" />  
</javac>    

有没有办法通过命令行来覆盖此,还是我坚持编辑生成文件?

Is there any way to override this from the command line, or am I stuck editing the build file?

推荐答案

蚂蚁 的javac 任务文档说:

The Ant javac task documentation says:

有可能使用不同的编译器。这可以通过设置全局build.compiler财产,这将影响整个构建所有任务中指定,或通过设置编译器的属性,特定于当前任务。对于无论是build.compiler属性或属性编译有效值为:

It is possible to use different compilers. This can be specified by either setting the global build.compiler property, which will affect all tasks throughout the build, or by setting the compiler attribute, specific to the current task. Valid values for either the build.compiler property or the compiler attribute are:

这听起来仿佛可以指定全局build.compiler财产设置一个特定的编译器的属性。

It sounds as if you can either specify the global build.compiler property or set a specific compiler attribute.

所以,它看起来像您需要修改您的构建文件,并且:

So, it looks like you will need to modify your build file and either:


  1. 删除该呼叫的javac编译器的属性,并允许
    全球build.compiler设置
    向下级联

  1. remove the compiler attribute from the javac calls and allow the global build.compiler setting to cascade down

改变编译器的价值
从硬codeD属性字符串
    编译器=现代是财产
    编译器=$ {} javac.compiler

change the values of the compiler attribute from a hard-coded string compiler="modern" to be property compiler="${javac.compiler}"

这篇关于覆盖编译器属性在Ant javac任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆