Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Integrate Ant builder into Eclipse: Relative paths for refresh scope working set

Tags:

java

eclipse

ant

This question is similar to Integrate Ant builder into Eclipse: Error "Variable references empty selection", but asks for something different.

In my Eclipse JDT project, I have some ant tasks that I want to execute before compilation, so I added an ant builder to my Eclipse builder config. Now I want to configure the two options "refresh resources upon completion" and "working set of relevant resources" for this builder so that they contain a specific directory in my project.

Both allow me to specify a "working set" with this dialogue. The problem is that this will put paths in the Eclipse builder configuration file that are relevant to the workspace, and thus the paths will include project names.

The problem is that the whole project is managed in a subversion repository. The Eclipse configuration is part of the repository, and other users check this out with different file-system layouts and possibly different Eclipse project names. For example, I usually have several working copies of the same project in my Eclipse workspace, each of course with a different project name.

That's why I am looking for a way how to specify a working set in Eclipse relative to the project directory (not the workspace directory), or some other way to define the refresh scope of a builder such that it includes a single directory in my project.

I am using Eclipse 3.7 (Indigo).

If I configure the working set in the dialogue and look in the configuration file afterwards, the following string is the value of the ATTR_REFRESH_SCOPE option:

${working_set:
<?xml version="1.0" encoding="UTF-8"?>

<resources>

<item path="/MyProject" type="4"/>

</resources>}

Sanitized this looks like:

${working_set:
  <?xml version="1.0" encoding="UTF-8"?>
  <resources><item path="/MyProject/lib" type="2"/></resources>
}

So I want to get the "MyProject" part out of this. I tried the solution of the question mentioned above and replaced the path with ${build_project:/lib}. This gives no error message, but it seems to have no effect (Eclipse will not refresh the mentioned directory).

I also tried replacing the whole working set definition with ${build_project:/lib}, but this gives an error message Unable to restore resource memento.

I know that I could just tell Eclipse to refresh the whole project after the builder is run, but this is not what I want (its quite slow). Also for the "relevant resources" configuration option, this would mean that the builder needlessly runs after every change in the project.

like image 857
Philipp Wendler Avatar asked Nov 16 '11 09:11

Philipp Wendler


1 Answers

Unfortunately, Eclipse is not great with relative directories.

Relative Paths in Eclipse

However you can do the following:

  • Create a new workspace.
  • Import files from a known location that will be the same on all machines.
  • Configure everything inside of that known directory.
  • Provide workspace and setup instructions to other developers, so that they will use this same 'known directory'.

You could have something like

C:\YourKnownDir\
    \workspace\
    \src\
    \build\

and start eclipse with a batch file:

start %ECLIPSE_DIR%\eclipse.exe -data .\workspace

If you're going to be included .project files in SVN, there should really be a predetermined full path. EG:

C:\svn

Hope that helps, but I don't know any other way to tackle this issue.

like image 74
Dan Avatar answered Nov 20 '22 21:11

Dan