Eclipse的自定义构建规则 [英] Custom build rules for Eclipse

查看:149
本文介绍了Eclipse的自定义构建规则的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Java项目,它使用一些自动生成的源代码。这个源代码由一个命令行工具--- Bison生成,实际上是从一个特殊的源文件。



我想要一种方法来拥有Java当我按下Eclipse中的build按钮时,需要时自动重新生成源。这是可能的,如果是这样,那么怎么样?



通常我会把它整合到项目makefile中,但这当然是Java,它不使用makefile 。我看过蚂蚁,但是蚂蚁似乎对传统的命令行工具非常敌意。我知道像这样的东西,这是可能的内置的Eclipse构建器,因为Android开发工具包;那么它在做什么?

解决方案

右键单击项目,选择属性>建筑商>新...>程序



您可以选择在项目构建时运行的命令行工具。






为了完整性:这是一个仅限Eclipse的解决方案。我建议您使用构建系统而不是普通的Eclipse。 Maven和Ant都可以很好地与Eclipse(通过 m2eclipse ,Ant通过与上述相同的Builder机制,Ant)完美集成其他人也可以。



使用Maven,您可以使用 exec:exec 用法)。



使用Ant,您将使用 < Exec> 任务。


I have a Java project that uses some autogenerated source code. This source code is produced by a command-line tool --- Bison, actually --- from a special source file.

I would like a way to have the Java source automatically regenerated whenever necessary when I press the 'build' button in Eclipse. Is this possible, and if so, how?

Normally I'd integrate this into the project makefile, but of course this is Java, and it doesn't use makefiles. I've looked at ant, but ant seems rather hostile to traditional command-line tools. I know something like this is possible with the built-in Eclipse builder because the Android development kit does it; so what is it doing?

解决方案

Right-click the Project, select Properties > Builders > New ... > Program.

There you can select a command line tool that will be run whenever the project is built.


For completeness: this is an Eclipse-only solution. I would recommend you to use a build system instead of plain Eclipse. Both Maven and Ant integrate nicely with Eclipse (Maven through m2eclipse, Ant through the same Builder mechanism as above), possibly others as well.

With Maven, you would use exec:exec (usage).

With Ant you would use the <Exec> task.

这篇关于Eclipse的自定义构建规则的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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