从_within_的build.xml完全指定Eclipse编译器 [英] Specifying the Eclipse compiler completely from _within_ build.xml

查看:163
本文介绍了从_within_的build.xml完全指定Eclipse编译器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于我们要使用Eclipse Java编译器(ECJ-3.5.jar从eclipse.org下载)上,而不是JDK的Java 6的运行时版本打造我们的产品,实验我的理解是,这是一个加入这个jar蚂蚁类路径,并设置build.compiler财产的事指向适配器。

As an experiment we want to build our products using the Eclipse java compiler (ecj-3.5.jar downloaded from eclipse.org) on the runtime version of Java 6 instead of the JDK, and as I understand it, it is a matter of adding this jar to the ant classpath, and setting the build.compiler property to point to the adapter.

通过包括

<property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter" />

在我的build.xml和调用Ant了JRE,我得到的预期误差适配器无法找到,并在Eclipse面板添加ECJ-3.5.jar到classpath我可以编译我的code如预期。我相信同样的功能,可与有现代化的蚂蚁命令行-lib foo.jar中。

in my build.xml and invoking ant with a JRE, I get the expected error that the adapter cannot be found, and by adding ecj-3.5.jar to the classpath in the Eclipse panel I can compile my code as expected. I believe the same functionality to be available with "-lib foo.jar" from the command line with modern ants.

现在,我想从的 的范围内指定,我想对我的满足与上述相同的classpath ECJ-3.5.jar build.xml文件。我们可以已经与Ant任务做到这一点,所以我相信这是可能的。

Now, I want to specify from within build.xml that I want ecj-3.5.jar on my classpath satisfying the same as above. We can already do this with ant tasks, so I believe it is possible.

所以,问题是:我如何可以添加到使用javac的从build.xml文件中定位编译器的只有的类路径

So the question is: How can I add to the classpath used by javac to locate the compiler only from within build.xml?

看来,即将到来的ant4eclipse 1.0包括Eclipse编译器(这是我想用这个为)通过升级到(0.5),所以应该解决我们的问题。

It appears that the upcoming ant4eclipse 1.0 includes the Eclipse compiler (which is what I wanted to use this for), so by upgrading to that (from 0.5) should solve the problem we have.

2010-09-24:Ant4Eclipse仍处于M4而不当释放将发生指示

2010-09-24: Ant4Eclipse is still at M4 without indication of when the release will happen.

2011-12-01:我们现在已经从蚂蚁迁移到Maven的。这个build.xml脚本击中需要复杂墙和一个新鲜的做法。任何人都需要选择做什么 - 不走ant4eclipse路径除了琐碎的项目

2011-12-01: We have now migrated from ant to maven. The build.xml scripts hit the complexity wall and a fresh approach was needed. Anyone needing to choose what to do - do not go the ant4eclipse path except for trivial projects.

2012-11-30:一年后,Maven的经验仍然是大多良好。有很多怪癖和变化的心态,但最有意义的方面。 Maven的可以很容易地指定个别项目的编译器级别。我们正在研究使用欧洲法院,而不是javac的(有几个原因),但对于大多数用途javac的工作得很好。

2012-11-30: A year later, the maven experience is still mostly good. There is a lot of quirks and changes in mindset but most make sense in the context. Maven can specify the compiler level on individual projects easily. We are looking into using ecj instead of javac (for several reasons) but for most purposes javac works nicely.

推荐答案

一种方法是使用javac时指定一个componentdef的引用。

One way is to specify a reference to a componentdef when using javac.

<componentdef name="ecj" 
              classname="org.eclipse.jdt.core.JDTCompilerAdapter" 
              classpath="ecj-3.7.1.jar" />

<javac ....>
  <ecj/>
</javac>

另一个选项是设置build.compiler你有,或用于javac编译器属性,然后指定一个javac的compilerclasspath。这就好比结构的正常路径来保存classpath中加载你的编译器适配器。

Another option is to set build.compiler as you have or the compiler attribute for javac and then specify a compilerclasspath for javac. This is a normal path like structure to hold the classpath for loading your compiler adapter.

<javac compiler="org.eclipse.jdt.core.JDTCompilerAdapter" ....>
  <compilerclasspath>
     ...
  </compilerclasspath>
</javac>

有关详细信息,请参阅 javac任务在Ant手册文档。注意,这两个解决方案都只是从1.8蚂蚁开始工作。

See the javac task documentation in the Ant manual for more details. Note that both these both solutions only work from Ant 1.8 onwards.

这篇关于从_within_的build.xml完全指定Eclipse编译器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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