Eclipse: how to keep the project and ant build.xml source files separate from the eclipse workspace?

I am trying to overestimate myself with the Eclipse framework and ant integration.

Question: how to save the source dir + build.xml files separately from the workspace?

I have a small java project and a build.xml file with all sources placed under a separate project folder. Then I started Eclipse and allowed to import my project through a New project -> "Java project from an existing ant build file

Everything went fine until I wanted to build a project from Eclipse using build.xml. Ant begins to complain about the inability to find the source tree. After I looked around in the workspace, I found that Eclipse had copied the build.xml file into the workspace, so it is obvious that ant could not find any sources. They are still under my project director and I want to keep them there if possible.

so what's the best way to make this setting work? workspace on the one hand, my project on the other?

Thanks!

edit: I want this to be possible?

+8
eclipse ant integration workspace
source share
5 answers

Instead of using the Java Project from an Existing Ant Buildfile, simply create a simple Java Project. In the wizard, uncheck the "use the default location" box and enter the path (or browse) into the top-level directory of the existing project (i.e. where is your build.xml file). True, eclipse will create the project files .project and .classpath in the directory of your project (if they do not already exist), but the project will remain outside the eclipse workspace.

The fact is that this setting worked very well in a special situation in an autonomous system, where the source tree is in a common place, but each user has a workspace in a protected place. Using the method described above, each user of this system can create a project in his own eclipse workspace, execute Ant targets and subsequently remove the project from his own workspace without affecting the workspaces of other users.

+10
source share
+2
source share

I do this all the time in C ++ projects (no Java, sorry, but I think this concept is portable).

I have my workspaces in ~ / workspaces / {workspace_name}. I have one common project file in ~ / {my_projects, and then the source trees (multiple versions) are in ~ / proj1, ~ / proj2, etc.

In each ~ / proj * directory, I put a symbolic link in ~ / my_projects / .project and .cproject (required for C ++ not used in Java). Therefore, each source tree uses a common project file. Then, in each workspace (one for each source tree), I set up the workspace by importing the project link. For example, ~ / workspaces / proj1 imports ~ / proj1 / .project, but ~ / proj1 / .project is actually a symbolic link to ~ / my_projects / .project.

Thus, this source stands out separately from workspaces. When creating, there is no real configuration - I just run make Eclipse in the corresponding node of the tree - we already have our own command-oriented system (we do not use ant, but the same principle should apply).

I have a source-control folder ~ / my_projects in a private SCM area, so other team members do not see this or play with it - many of them do not use Eclipse at all.

+1
source share

There is really no need to try to avoid Ant and Eclipse using the same set of source files. In fact, it is probably better that they use the same set.

Remember, you are not mixing anything. There is only one set of source files, and then there are two different ways to create it; Ant and Eclipse. These builders are independent of each other, so there is no problem connecting to Eclipse. You can even happily transfer all eclipse files (.classpath, .project, .settings) to the original control without affecting developers who use a different IDE.

0
source share

I do this all the time (admittedly using maven, not ant), but the same principle applies.

If you have an existing project in Eclipse (with .project in the source tree), you can import Project-> Import Existing Project. When the dialog box appears, you can select "Copy projects to workspace." Make sure this is not checked and they import.

You still save the .project in the original source tree, but all that.

So now I have

  • code / xxx (which contains .java files that are in SVN)
  • code / xxx-workspace (containing the eclipse workspace)
0
source share

All Articles