使用 Ant 刷新 Eclipse 项目

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/985976/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 13:47:26  来源:igfitidea点击:

Refresh an Eclipse project with Ant

eclipseantjar

提问by Antoine Claval

We have some Ant script fosr building the different jars we use, in several Eclipse projects. There is some interdependency

我们有一些 Ant 脚本用于构建我们在几个 Eclipse 项目中使用的不同 jar。有一定的依存关系

At the end of the build, we have to refresh some of the Eclipse projects in order to make the build path valid. Without this, it doesn't see one of the just-built jars and Eclipse throws a build path error.

在构建结束时,我们必须刷新一些 Eclipse 项目以使构建路径有效。没有这个,它就看不到刚刚构建的 jars 之一,Eclipse 会抛出构建路径错误。

There is a way to avoid the manual refresh step?

有没有办法避免手动刷新步骤?

回答by Roman P

Try this:

尝试这个:

<eclipse.refreshLocal resource="project_name/folder_name" depth="infinite" />

There are option detailsat the Eclipse help system.

Eclipse 帮助系统中有选项详细信息

Important: you have to choose "Run in the same JRE as workspace" at the Ant run configuration.

重要提示:您必须在 Ant 运行配置中选择“在与工作区相同的 JRE 中运行”。

回答by Scott Stanchfield

You may want to turn on "Refresh Automatically".

您可能想要打开“自动刷新”。

See Window->Preferences->General->Workspace->Refresh Automatically

见窗口->首选项->通用->工作区->自动刷新

and it'll monitor filesystem changes for you.

它会为你监控文件系统的变化。

回答by Shadwell

If you're running the ant script from within eclipse you can right-click on it and select "Run As >" then "Ant Build...". There's a 'Refresh' panel in the options to run the script which you can choose to refresh various things after the script completes.

如果您在 eclipse 中运行 ant 脚本,您可以右键单击它并选择“Run As >”,然后选择“Ant Build...”。运行脚本的选项中有一个“刷新”面板,您可以选择在脚本完成后刷新各种内容。

回答by Kevin Stembridge

This might not be answering your question exactly but I don't quite understand what is causing the problem.

这可能无法准确回答您的问题,但我不太明白是什么导致了问题。

As I understand it you have a project A that creates a jar file and that jar file is referenced by project B. When you re-build project A, you need to refresh so that project B can see the new jar file. Is that correct?

据我了解,您有一个项目 A,它创建了一个 jar 文件,该 jar 文件被项目 B 引用。当您重新构建项目 A 时,您需要刷新,以便项目 B 可以看到新的 jar 文件。那是对的吗?

I do something similar but I don't get any build path errors because the name of the project A jar file hasn't changed.

我做了类似的事情,但我没有收到任何构建路径错误,因为项目的名称 A jar 文件没有改变。

Another option is for Project B to reference Project A directly instead of referencing its jar file.

另一种选择是让项目 B 直接引用项目 A,而不是引用其 jar 文件。

I think I may have misunderstood the problem you are having but I hope this helps anyway.

我想我可能误解了您遇到的问题,但无论如何我希望这会有所帮助。

回答by Ahmad Nadeem

it can be done by following Ant tasks provided by the Eclipse platform.

它可以通过遵循 Eclipse 平台提供的 Ant 任务来完成。

<eclipse.refreshLocal resource="MyProject/MyFolder" depth="infinite"/>

Note:make sure to run Ant inside the same VM where Eclipse workspace is running, for details check following links

注意:确保在运行 Eclipse 工作区的同一 VM 中运行 Ant,有关详细信息,请查看以下链接