Refresh an Eclipse project with Ant
Asked Answered
C

5

31

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

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.

There is a way to avoid the manual refresh step?

Credent answered 12/6, 2009 at 10:11 Comment(0)
R
34

Try this:

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

There are option details at the Eclipse help system.

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

Radburn answered 12/6, 2009 at 14:59 Comment(2)
As Roman has said, it's important to "Run in the same JRE as workspace" and not from a JRE or JDK that you setup.Selenite
codejava.net/ides/eclipse/how-to-change-jre-for-ant-in-eclipsePend
C
16

You may want to turn on "Refresh Automatically".

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

and it'll monitor filesystem changes for you.

Circinate answered 12/6, 2009 at 16:1 Comment(1)
The option is now called "Refresh using native hooks or polling", which is a bit less intuitive than "Refresh Automatically".Hopeh
L
6

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.

Leukocyte answered 12/6, 2009 at 16:12 Comment(0)
B
0

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?

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.

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

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

Brandish answered 17/6, 2009 at 9:53 Comment(0)
S
0

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

<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

Schlueter answered 30/10, 2017 at 7:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.