How to open Eclipse project as read-only? - eclipse

Does anyone know is there a way to open a project in Eclipse in read-only mode? If there is a lot of similar projects open it is easy to make changes to a wrong one.

Putting project in read-only mode is really useful, when you make another instance from the previous project. So you copy all files from old project, then make changes in the new instance. It's really simple to edit files from old project by mistake (they have the same names)!
Serg if you use linux, I suggest to put all files in read only mode with chmod in terminal:
sudo chmod 444 -R /path/to/your/project
After this operation Eclipse will tell you that file you are trying to edit is in read-only mode. I think that's enough to make the previous project safe :)

One sub-optimal solution is to make the project directory read-only in the file system in the underlying OS. I'm not sure how eclipse will react though.

This feature is called "binary projects" and is provided by the eclipse plug-in developement environment (PDE). Note that this only works for eclipse plug-in project, see
Contributing to Eclipse - Principles, patterns and plug-ins
or
http://www.vogella.de/articles/EclipseCodeAccess/article.html#importplugins_binary

You can also use the close project/open project feature : close all projects and only open the one you need to work on ?

Related

Eclipse: The project was not built since the source file ... could not be read

When compiling my Java project, I get this error in Other errors:
Description Resource Path Location Type
The project was not built since the source file /PROJECT/src/main/org/../ABC.java could not be read PROJECT Unknown Java Problem
Indeed, the file is listed in Package Explorer but shows only "Error retrieving content description. On the file system, the silent dir exists but not the file; git status is missing nothing. How do I resolve that compile error?
Simply restart eclipse, refresh all projects and do a clean build. That should fix it. Don't forget the eclipse restart, else no matter how many times you do a clean build or refresh, it will not fix the problem
Looks like someone has deleted that file but eclipse still think that file is part of the project. Might have happened when someone deleted a file from the source control in an improper way.
If you dont have pending changes then you can get fresh copy of the project and import it into your workspace.
If you have pending changes then take a copy of changes and repeat above step. ( A restart of eclipse may be necessary)
It can be related to missing location
Select File => properties => Resource => Edit file location.
I know the answer is accepted but in my case that solution didn't work for me, I had restored files from a backup to my local project in linux and the files I restored were owned by root with only the owner being able to read/write the files. SO, I sudo chowned the files "sudo chown _R myUser:myUser *" at the base of my project, refreshed in Eclipse (f5) and the annoying repeated failure of my build was a thing of the past.
If you are writing Maven projects, try right click on the project and select [Maven] -> [Update Project...]
It works for me.
For me there was a different solution than mentioned here.
I was doing a no-no, I imported a project that had a .project file, and there was some errors in the way my version of eclipse was reading some of the files. The package names and files had a little ! symbol with a yellow background.
The solution was to delete the packages. Obviously make a backup. But in doing this most times the files nor the packages were deleted. Instead eclipse refreshed and the desired files were there. Sometimes I had to hit refresh (F5), and sometimes I had to restore files.
I found it best to delete the packages as that is where eclipse was having reading the data.
If the missing file is still mentioned in the Linked Resources, no refresh and restart of Eclipse will ever solve the problem. You have to delete the file in the Project Properties Linked Resources list.
For anyone using VS Code with the RedHat Java plugins (which use Eclipse tooling under the hood), I got this error as well. I fixed with the following:
# Quit VS Code
rm -rf ~/Library/Application\ Support/Code/User/workspaceStorage/*
# Reopen VS Code
As all others said, it is most probably an issue with the internal caches of Eclipse.
I usually restart the IDE with the additional -clean option to wipe out the OSGi-related caches, then clean and rebuild all the projects.
If the problem persists, I realized that cleaning up the single affecting project works better that cleaning up the whole workspace. (Ominous... XD)
This usually happens to me when merging changes that imply renaming or deletion of source files, prior to launching Eclipse.

Eclipse and copying workspaces

What do I have to do to copy a complete workspace from one computer to another and be simply able to continue working on it on the other computer?
In general, a filesystem copy should be sufficient. If you run into problems with your projects, try removing the project from the workspace (without deleting the files) and then re-add the project, which will rebuild the metadata.
Make sure you shut down eclipse before you copy the workspace, and that the target computer has the same (or higher) eclipse version, including the same plugins.
Check that your workspace actually contains all the projects - when creating a project, it's possible to have its files situated outside the workspace.
If your projects use any external libraries installed on the system, install these on the other system in the same place (or adjust the paths).
Then, there should be no problem.
You shouldn't have any issues with a straight filesystem copy as long as your eclipse versions match up.
If they don't, the project metadata may not load correctly
You need to copy the whole folder which you select as your workspace at startup (or you once selected). All settings are included in there (even the opened files).
I use rsync for this. Works great.

Forcing Eclipse to generate standard Unix makefiles

I have an Eclipse project I've been working on for some time now, and I'd like to open source it. But to do that I'd like to have a clean Makefile like the majority of other open source programs. I understand I could make my own, but it would be better if Eclipse could manage it for me. Getting Eclipse to generate a CMake file would be even better, but I can settle for a plain makefile if that is easiest. So, how can I get Eclipse to do this? There are a few posts on the internet that suggest selecting "Managed make" when creating a project, but they were from a few years ago and are outdated. When I try to create a C project, there is the option to create a "Makefile project", but it creates the makefile in a folder called "Linux GCC" and makes everything cluttered. Any suggestions?
I've been a *nix guy for 25+ years and am a big fan of make. However, making your Eclipse project dependent upon make is going to exclude the Mac and Windows community. Why don't you just export the Eclipse project and open source it as an Eclipse project? Then users can can have it ready to extend if they choose. You didn't specify the language your project is written in, if it's Java (pretty common for Eclipse) why not create an ant build file for the project?
Just a thought.
I ended up just creating a CMake project by hand. CMake files are really not that hard to make, and it's a lot easier than trying to get Eclipse to do it for you. Plus, they're cross-platform.
Would a CMakeBuilder eclipse plugin, associated with this tutorial be a good fit for what you are trying to do?
The end result would be something like:
(source: vtk.org)
If you've been building your project using the Debug configuration the makefile Eclipse generates is stored in the Debug folder of your project (or the Release folder if you've built it using the release configuration).

svn command line from eclipse

Hello is there a way to use svn command line from eclipse?
Within eclipse in my project browser i can righclick and then click team and than i have something like svn. Not sure which plugin it is. But it doesn't have button's to for example ignore files for uploading. That's why I want to to it command line. And my question is how to do it.
Ok so how can I use it from command line in windows xp?
The plugin you are probably using is Subclipse. It should have an "Add to svn:ignore" option. If not, try updating to the latest versions of Eclipse and Subclipse. In general subclipse should be enough and there is no need for the command line.
For Windows XP I recommend Tortoise SVN. It integrates with the Windows Explorer and offers you a graphical environment for all your needs. I would say that is much more stable than subclipse and very easy to use.
If you do want to use the command line tools, download and install svn-win32 from here. The command line tools could be helpful in merge and copy operations.
I should also point out that none of these methods interfere with each other. You can work with Tortoise SVN or the command line and subclipse won't be affected. All svn clients work by writing and reading from hidden directories called .svn. There is one such directory in every folder under source control. As long as the svn client software is of the same version, an svn client can write to these hidden folders and another one will be able to read from it. A problem could arise if one of the clients is updated to a version that uses a different protocol for writing to the .svn folders. In that case, older clients won't be able to read the information stored there. Upgrading them to the latest version will solve the problem.
Not sure what you're trying to do; sometimes it's better to describe the goal rather than the means you plan to do it.
Have you tried Subeclipse? It lets you use SVN inside Eclipse; it's great.
I'm not sure if you can use it from Eclipse, but nothing stops you from just using it. From cmd / xterm / whatever. It's not going to interfere with Eclipse in anyway, nor will it interfere with Subclipse (which I'm assuming is what you're using).
I'm using subclipse, and in generaly it works pretty well.
However, and I guess this is your problem, the Team Synchronization by default wants to add all files in my projects, not just the ones I add to version control. This is lame and frustrating, and apparently there's no way to turn it off. Screenshots for older versions, however, hints at the possibility of turning the "feature" off. Frustrating!
I'm not personally a fan of Subclipse - it slows the IDE a bit too much for my taste. Here is an alternative approach using External Tools and TortoiseSVN
Create a new External Tool
Call it SVN Commit
Set the Location to \bin\TortoiseProc.exe (mine is C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe)
Set the arguments to /command:commit /path:"${selected_resource_loc}"
Open the file / directory you want committed and run the external tool.
Interchange the commit in step four for additional commands. You can also add the specific tools to favorites and have them in a dropdown on the toolbar.
Additional Arguments Here
Not intended to be too presumptuous here, but I think you should look at whether Subversive or Subclipse actually solves problem in a different way than you intended. For instance, it is very much possible to ignore files and directories from being checked in, via Subclipse.
On the other hand, if you really want to hack away via the command prompt from Eclipse, you must install the Target Management project (supported for Eclipse Europa and Ganymede). Once you have that installed, you can launch a remote shell to your local machine and then type away on the command line :).
PS: I haven't used this approach ever; Subversive satisfied all my requirements of a SVN plugin in Eclipse.

How do I configure Eclipse to work on Qt-based applications in a subversion tree?

Most of the work being done at my company is Qt-based C++, and it's all checked into a Subversion repository. Until now, all work on the codebase has been done purely with nano, or perhaps Kate. Being new here, I would like to take advantage of setting up Eclipse -properly- to edit my local copy of the tree. I have the CDT "version" of Eclipse, and the Qt integration, and the Subclipse module. At this point, though, I don't know what to do. Do I "import" the projects into an Eclipse-controlled workspace? Do I edit them in place? Nothing I've tried to do gets Eclipse to recognize that the "project" is a Qt application, so that I can get the integration working.
I would create a new QT project in eclipse, then switch perspectives to subclipse and simply do a SVN checkout into the new eclipse project. You should be good to go.
OK, I've been playing around with this idea, and it has some merit. I can switch to the "SVN Project Exploring" perspective (which I hadn't noticed before), and do a checkout from the head of the sub-project I want. I get a nice SVN-linked copy of the tree in my Eclipse workspace for editing. Eclipse even "understands" the classes, and can do completion on methods and such. However, I still can't get Eclipse to understand that the project is a "QT Gui" project, such that I could view the properties, and control the linking of the various Qt libraries and the like. By extension, it also doesn't understand how to build my project, like it would be able to do if I had created an empty Qt Gui project from scratch. How do I get this part working?
I have exactly the same situation at work (with CVS instead of subversion and the rest of the team using KDevelop but that's no big deal). Just start a new Qt Gui project using the Qt - Eclipse integration features and then remove all the auto generated files. Now using the "Team" features of eclipse and choose to share your project, enter the path to the repository and you 're good to go.
Checkout the project. It will ask you some options like if you want to start with a blank project, or want to use the tree to make a new project. Choose the latter and you should be ok :). It seems to work for me with Ganymed and subversive(not sure about subclipse and i don't remember.) :)
The only way I could get this to work was to check out the project with eclipse and then copy over the .project and .cdtproject files from another Qt-project. Then do a refresh on the project. This is a horrible hack but it gets you started.
You might need to define another builder for 'make'.
Second nikolavp - Checkout, and mark the option to use the new project wizard, then select Qt project. I've done this (with ganymede) and it successfully finds everything and builds correctly.
My solution:
go to the svn-view and add the repository location for your project
check out the project some temporary location with svn or any client you like
choose 'File->Import...' and say 'Qt->Qt project'
browse to the location of the *.pro file, select and hit the OK-Button
you are in the game with an appropriate Qt-project and Subversion Access for that project
I would say the same as the last one,
but instead of the two first steps I would set up the Qt-Eclipse integration:
Qt-Eclipse integration before looking for the *.pro file.