eclipse:保存后自动构建
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3360596/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
eclipse: auto build after save
提问by David B
I have an ant script that creates runnable jar and I want it to run each time I make changes in my code and save them. I guess I need some "auto build after save" option in Eclipse. Is there such a thing?
我有一个创建可运行 jar 的 ant 脚本,我希望它每次在我的代码中进行更改并保存它们时都运行。我想我在 Eclipse 中需要一些“保存后自动构建”选项。有这样的事情吗?
回答by VonC
You could declare your script as a builder, and make it run "during auto build
".
您可以将脚本声明为构建器,并使其运行“ during auto build
”。
See the properties of your project: you can add an external program (above) or an an script (below).
查看项目的属性:您可以添加外部程序(上图)或脚本(下图)。
If you can export your script as an ant script, like the OP David Bdid in his answer, it becomes quite easy:
如果您可以将脚本导出为 ant 脚本,就像OP David B在他的回答中所做的那样,这将变得非常简单:
- Export as an ant script: right-click the
project -> export -> runaable jar file
, tick "save as ANT script
" and finish. - Add the ant script as a builder: right-click the
project -> properties -> Builders -> new (Ant)
.
Paste the path for the ant file, go to "targets
" tab and click the "set targets
" button next to "auto build
".
Finally, click OK, OK, OK.
- 导出为 ant 脚本:右键单击
project -> export -> runaable jar file
,勾选“save as ANT script
”和finish。 - 添加 ant 脚本作为构建器:右键单击
project -> properties -> Builders -> new (Ant)
.
粘贴 ant 文件的路径,转到“targets
”选项卡,然后单击“set targets
”旁边的“ ”按钮auto build
。
最后,单击OK、OK、OK。
回答by David B
Actually, the best solution I found was: right-click the project -> export -> runaable jar file, tick "save as ANT script" and finish. Now right-click the project -> properties -> Builders -> new -> paste the path for the ANT file, go to "targets" tab and click the "set targets" button next to "auto build", OK, OK, OK.
实际上,我找到的最佳解决方案是:右键单击项目 -> 导出 -> 可运行的 jar 文件,勾选“另存为 ANT 脚本”并完成。现在右键单击项目 -> 属性 -> Builders -> 新建 -> 粘贴 ANT 文件的路径,转到“目标”选项卡,然后单击“自动构建”旁边的“设置目标”按钮,确定,确定,好的。
回答by zengr
Use an ANT file which will be triggered everytime you save a file: Using Ant to Auto-Build in Eclipse
使用每次保存文件时都会触发的 ANT 文件:Using Ant to Auto-Build in Eclipse