Eclipse automatically refresh resources and exclude build dir - eclipse

Eclipse Helios: 40+ project working set, using maven (mvn-eclipse plugin) to generate eclipse project files.
'Resource is out of sync with the file system: ...' Appears after doing, among other things, a text search.
After a bit of googling found Prefs > Workspace > Refresh Automatically which is widely reported to be malfunctional, and has the same symptom for me. The source files are source controlled, so therefore have lock attributes on them, was curious if this may come into play with this.
Second part is regarding my build directory; eclipse knows proj_root/target is the build directory, but I would like to exclude resource sync'ing in that folder.
I basically never want to see that dialog, and don't want to have to take action to remedy it (ie manually refreshing).

I had the same problem with m2eclipse.
Marking target folder as Derived resource worked for me (right-click -> Properties -> Resource -> Derived).

Related

Subclipse: How to add the default output folder to version control (*.class files)?

I am using eclipse 4.2 and Subclipse 1.8.20.
I am trying to add the contents of /WebContent/WEB-INF/classes to version control (this is also the default output folder of my project).
First let me state that this is possible with TortoiseSVN. I do understand why by default Subclipse ignores this directory, and I tried to change the Team settings, but I am not seeing a relevant entry for *.class files:
Is this at all possible with Subclipse?
More info:
Old an unanswered similar question: http://subclipse.tigris.org/ds/viewMessage.do?dsForumId=1047&dsMessageId=473163
Same topic but opposite question: How can I ignore build directory in Subclipse?
It is a horribly bad idea to version your build directory. Every time Eclipse does an auto-build it will cause all of the files to need to be committed again.
To answer your question, all Eclipse team providers automatically ignore any resource that is marked as "Derived" by Eclipse. The Derived flag is set on files that are created by the Eclipse builders. If you select one of these files that are ignored in Eclipse, right click and choose Properties. Navigate to the Eclipse Resource page. There will be a bunch of checkboxes. You should see that one of these is labelled Derived and will likely be checked.
Do not try to change the checkbox value. I am just pointing out where you can see and confirm this.

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

I'm trying to re-familiarize my self with the Eclipse environment and ant integration.
Question is: how to keep my sources dir + build.xml separate from the workspace?
What I have is
a small java project and its build.xml file with all the sources placed under a separate
project folder. I then started Eclipse and let it import my project via
New Project -> "Java Project from existing Ant Build File"
All went fine, until when I wanted to build the project from inside Eclipse using build.xml.
Ant starts complaining about not being able to find the source tree. After I examined
the workspace I found that Eclipse had copied the build.xml into the workspace, so it's
obvious that ant couldn't find any sources there. They are still under my project director
and I do want to keep them there, if possible.
so whats the best way so make this setup work? workspace on one side, my project on the other?
Thank!
edit: Is what I want even possible ?
Instead of using "Java Project from Existing Ant Buildfile", just create a simple "Java Project". In the wizard uncheck "use default location" and enter the path (or browse) to the top level directory of your existing project (i.e., where your build.xml is). True, eclipse will create .project and .classpath files in your project directory (if they do not already exist), but the project will remain outside the eclipse workspace.
Case in point, this setup has worked really well in a very particular situation on a standalone system where the source tree resides in a common location but each user has a workspace in a protected location. Using the method described above, each user of this system can create a project in their own eclipse workspace, execute ant targets and subsequently remove the project from their own workspace without affecting other users' workspaces.
What about using links?
Windows Symbolic Links
Linux man page for ln
I do this all the time in C++ projects (no Java, sorry, but I think the concept is portable).
I have my workspaces in ~/workspaces/{workspace_name}. I have a single shared project file in ~/{my_projects, and then the source trees (multiple versions) are in ~/proj1, ~/proj2, etc.
Within each ~/proj* directory, I put a symlink to ~/my_projects/.project and .cproject (required for C++, not used in Java). So each source tree is sharing the single project file. Then in each workspace (one for each source tree), I configure the workspace by importing the project link. For example, ~/workspaces/proj1 imports ~/proj1/.project, but ~/proj1/.project is actually a symlink to ~/my_projects/.project.
So this keeps the source separate from the workspaces. When building, there's no real configuration to do -- I just have Eclipse run make in the appropriate node of the tree -- we already have our own command-oriented build system (we're not using ant, but the same principle should apply).
I source-control the ~/my_projects folder in a private area of the SCM, so other team members don't see it or fiddle with it -- many of them don't use Eclipse at all.
There isn't really any need to try and avoid Ant and Eclipse using the same set of source files. In fact, its probably better that they do use the same set.
Bear in mind, you're not actually mixing anything. There is just one set of source files and then there are two different ways of building it; Ant and Eclipse. These builders are independent of each other, so there is no problem with being coupled to Eclipse. You can even happily commit all the eclipse files (.classpath, .project, .settings) to source control without affecting any developers who use a different IDE.
I do this all of the time (admittedly using maven, not ant), but the same principle applies.
If you have an existing project in Eclipse (with the .project in the source tree), then you can Import Project->Import Existing Project. When the dialog box comes up, you can choose to 'Copy projects into workspace'. Make sure this is unchecked, and them import.
You still store the .project in the original source tree, but thats all.
So now I have
code/xxx (which contains the .java files, which are in SVN)
code/xxx-workspace (which contains the eclipse workspace)

"Workspace is closed" exception when trying to get the workspace through ResourcesPlugin

I get this error when trying to get the workspace through ResourcesPlugin:
java.lang.IllegalStateException: Workspace is closed.
at org.eclipse.core.resources.ResourcesPlugin.getWorkspace(ResourcesPlugin.java:339)
The code generating this is:
IWorkspace ws = ResourcesPlugin.getWorkspace();
Can you please help with this problem?
Does your Manifest.MF contain the org.eclipse.core.resources in the Require-bundle section ?
And do you launch your test as a plugin ? (not as a 'Java Application')
See also this thread.
As mentioned in the "Resources and the file system" help page,
You can access the workspace from the resources plug-in class (defined in org.eclipse.core.resources).
When the resources plug-in is not running, the workspace exists solely in the file system and is viewed or manipulated by the user via standard file-based tools. Let's look at what a workspace looks like on disk as we explain the resources plug-in API.
From this book:
The workspace directory, regardless of the name defined with the -data invocation option, has two roles:
it acts as the parent for the .metadata directory
and as the default location for projects
the workspace can contains projects only when:
the org.eclipse.core.resources plugin is included in the configuration and
and appropriately started from the workbench
this is automatic from an IDE configuration based on the org.eclipse.ui.ide.workbench application.
See also this thread and remember that:
the workspace is a different workspace from the runtime-workspace that's used for testing plugins. When you do Run on an Eclipse PDE environment, it creates a new workspace which is completely empty.
The testing workspace root can be specified through the "-data" launching option.
If you want to access a file, your best bet is to include it in the plugin itself, and then use getClass().getResourceAsStream("/myfile.txt") to get an InputStream that you can read the contents for.
Try calling Plugin.getStateLocation() in the plugin, it should cause the workspace to be created for you. Without this, you can't save any preferences either. http://dev.eclipse.org/newslists/news.eclipse.platform/msg45020.html
http://help.eclipse.org/help32/index.jsp?topic=/org.eclipse.platform.doc.isv/reference/api/org/eclipse/core/runtime/Plugin.html#getStateLocation%28%29
Err, sorry -- I just completed necroed this question by accident :)

Eclipse - Ignore Entire Directories

I use Aptana Studio (based on Eclipse). I'm trying to get Eclipse to completely ignore an entire directory inside a project. I mean COMPLETELY. I don't want it to display in the project folder. I don't want Eclipse to even be aware it exists.
Unfortunately, all my efforts to add it as a filter don't work. See http://forums.aptana.com/viewtopic.php?f=14&t=8340#p33714 . I think the filter only prevents the folder from being displayed in the project display. It doesn't keep Eclipse from actually looking at all the files in that folder for code assist, etc.
My problem is that directory has thousands of text files. So, each time Eclipse opens or refreshes this project, it analyzes all those files.
How can I prevent this?
Not sure about this aptana thing, but there is a convenient way to do it in native eclipse:
Right-click a project folder in Project Explorer tree and go to "Properties".
Resource -> Resource Filters.
Add as much exclusion filters for files/folders as you like.
If your project tree is not refreshed immediately, press F5 to enforce it.
Consider also the 'Derived' checkbox: right-click an entry in the package explorer, choose properties, check Derived. This may solve part of your problem.
See http://robmayhew.com/eclipse-ignore-folder/
If you have a linked resource (pointing off to some other file/folder on disk) with the same name in the same location in the resource tree, then the real folder on disk will be hidden from the resource model.
Unfortunately you can't create the linked resource if the real directory is already there in the project structure. You can try something like this:
On disk, rename/move the directory in question
Refresh the project, the directory is gone
Create a linked resource ( New -> File/Folder >> Advanced -> Link to file in the file system ). Name it the same as the original directory.
On disk, restore the original name of the directory
Refresh project.
Try right-clicking "Properties" and unchecking all permissions.

Why is eclipse trying to compile files not in my build path?

I have a rather large project which contains a number of third-party dependencies which are linked via svn:externals. These include tomcat and blazeDS, which are packaged by our installer via ant. The problem is that these projects contain dozens of sample JSP pages, and eclipse chokes on them when trying to build the project, producing hundreds of errors.
Our project setup is something like this:
src/
main/
test/
third-party/
blazeDS/
tomcat/
etc.
Now, in eclipse, my project's build path is set to only include subfolders in src/main and src/test. Yet, for some reason, it still tries to build everything beneath third-party. I have clicked on third-party and selected "remove from build path", but this had no effect. I even tried adding the third-party folder to the build path, and then excluding "", "/*", and "**/*.jsp", but again, to no effect.
What is going on here?
Edit: Thanks for the suggestions, though unfortunately, they don't seem to fix the issue. I don't have the CheckStyle plugin installed (I'm using Eclipse 3.4.1 with the only custom plugins being subclipse and flex builder), and I tried disabling all extra builders except for Java, but the errors are still being thrown.
I usually have this kind of issue with CheckStyle plugin, where you need to specify in its properties (right-click on project -> Properties -> CheckStyle):
"Exclude from check Files non located in a source directory"
Otherwise it does analyze (and reports warning/errors on) files which are not candidate to be compiled in the first place.
Couple of other suggestions:
try restarting your eclipse with the -clean option (eclipse software version of 'did you reboot it ?' ;) ). Beware it can reset your workspace perspectives, so you may want to try that with a copy of your workspace instead.
try deleting your project (your workspace reference of your project, not its actual content), and reimporting it (beware of your custom launchers, they may get removed in the process).
check if you do not have any linked directory within src or test, which would point to thirdparty(/**): that would explain the unwanted compilation.
It could be that your eclipse project is configured to have extra Builders. You can check that in the project's properties (right-click on project -> Properties -> Builders).
In my case it was because there was a reference to the file (which I had excluded from the build path) in another file which was in the build path. I wanted to exclude SegModel.hpp from the build path, but in another file, I had specified template short K::KEstimate<SegModel>(SegModel& m, short stepCode);