Eclipse projects deleted from workspace after checkout to another directory - eclipse

I've a code repository in which is commited an eclipse workspace (everything in the workspace directory except pdom files).
This workspace references several projects that are commited in the same repository.
If I checkout this repository to another place and open it with eclipse, the workspace is empty (no project anymore)
I suspect that eclipse stores projects location with a full path while I expected a relative path.
Unfortunately, I was unable to find in which file of the workspace are stored the projects reference.
I'm using this system for continuous integration with Jenkis. Each branch is checked out in a different directory.
What should I do to make it work ?
Edit : Even if the workspace references projects by their full and not relative path, opening a workspace should at least contain some projects...

OK, I solved it by scripting the building of a new eclipse workspace with the headless feature of eclipse.
No workspace is stored in the repository anymore.

Related

Some or all projects can not be imported because they already exist in the workspace error in Eclipse" [duplicate]

I just added repository A to my Git perspective in Eclipse (which also instanced a local Git repository under some path) and can now see the working tree. Now how do I work on the files in the package explorer?
From what I've seen I have to use "import projects" - what does this do? My Eclipse workspace seems to be empty, while made changes will all display in the git repository.
Also, how do I work with multiple repositories and how do I switch between them? When I try to "import projects" from repository B I get the message that Some or all projects cannot be imported because they already exist in the workspace
The issue here is that Eclipse maintains its own file system representation that includes projects. This was required historically to support incremental compilers, even if the file system is not capable of sending notifications.
The Import projects option you have seen relates to importing projects from a git repository into the Eclipse file system; adding the repository to Eclipse allows Eclipse to know about the repository, and execute repository operations (e.g. fetch, commit, push).
About why doesn't the project import work, the Eclipse file system contains a set of top-level projects (each can be either in the workspace folder or somewhere on the disk, e.g. in a git repository); however, it is not possible to have two projects with the same name in the same workspace.
If you want to open the "same" project from two repositories (e.g. two development branches), you have to rename them not to have a common name. This name is stored in a .project file in the project root (or if none exists, it will be derived); you can use a refactor operation to change the project names. After that, you can import both projects into your Eclipse workspace.

How to initialize git for a new eclipse (neon) java project

I installed a fresh copy of eclipse Neon, and created a new gradle java project in a new and shiny workspace. What is the best practice for adding git to the party?
I read that initializing git in the project directory is really a bad idea.
What is a particularly good idea then?!
Thanks!
The good idea is to git init a parent folder of the project different from the main workspace folder.
This is exactly what happens if you let Egit git init your project (Right click on project -> Team -> Share Project -> Git ->...) and select an external folder as repository, say c:\users\john\my-git-repository.
You will then have two folders:
c:\users\john\my-git-repository containing the \.git folder and \<my-project> folder
c:\users\john\<eclipse-workspace> the eclipse workspace folder, which will NOT contain your project folder (remember that eclipse workspace is just a logical container for projects, they don't need to be physically there).
Another option is to create a folder inside the workspace, create the project as a subfolder of that folder and then git init that folder. This way:
c:\users\john\<eclipse-workspace>\shared-projects\<my-project>
You will create the repository in the \shared-projects folder (either by command line with git init or from whithin Eclipse with the wizard), which will contain the \.git folder, \<my-project> folder and any other project you want to share.
Remember why Eclipse suggests to keep repositories outside the workspace (https://wiki.eclipse.org/EGit/User_Guide#Creating_Repositories):
It is a good idea to keep your Repository outside of your Eclipse Workspace.
There are several reasons for this:
The new Repository will consider the complete folder structure of the Eclipse workspace as (potential) content. This can result in performance issues, for example when calculating the changes before committing (which will scan the complete .metadata folder, for example)
If your git repo is in the \shared-projects folder the repository will NOT consider the complete folder structure of the Eclipse workspace as (potential) content and will NOT scan the .metadata folder since it's outside the repo. The only contents of the repo will be your shared projects!

spliting git repository from eclipse project - egit

I'm more or less a git newbie, trying to get a good Setup to work in Eclipse with egit. I'm running Kepler with latest updates.
Originally I Setup the structure inside the Workspace Directory.
+Workspace/.git
+Workspace/TheProject
Using this Setup (admittedly with Juno) commits were taking forever. For this and other reasons I'd like to move git outside the Workspace Directory, outside eclipse in a parallel Directory.
+OtherDirectory/.git
+Workspace/TheProject
But I'm not getting very far. There seems to be no easy way to split the EXISTING git to another Location without having the Project move there too(!?)
I've tried e.g. Cloning the existing git (in the git repository perspective) and having it Import the Project in the same move.
I've tried just Cloning the existing git, without selection of "Import Project" at the same time.
Then I right clicked the cloned repository and went through the Import Existing Project dialog. I don't get a Chance to say where the Project should be loaded to.
In both cases the Project Ends up in the same Directory as the .git Directory (now outside the Workspace)
+OtherDirectory/.git
+OtherDirectory/TheProject
and not as I wish - to have the Project in the Workspace Directory.
This must be possible (?), but how?
Simply copy the .classpath and .project from Workspace/TheProject or OtherDirectory/TheProject, to otherDirectory (where the .git folder is).
Then import your project into the workspace, as in "Eclipse - Import an existing project?"
Everything will remain in OtherDirectory/ (outside your Eclipse workspace folder), but will be visible in your Eclipse workspace.

Git workflow: PDT + Egit on Eclipse workspace and Git bare repository

I'm developing a Symfony applicatoin and I'm trying to set up a Git workflow on Eclipse. The workspace (where the project files lies) are located on /home/sfprojects/testing/ and the Git repository is located on /var/git/testing.
Reading over and over all the Git resources I've could found (including "Pro Git" by Scott Chacón, and the EGit user guide (http://wiki.eclipse.org/EGit/User_Guide, among others), it's easy to understand why the Git repository and the Eclipse workspace should not share the same directory, now my big confusion is that I can not see a method to keep both things separated from each other.
Once I've created the Git repository through the wizard, all the project files are moved automatically from the Eclipse workspace to the working directory on /var/git/testing/testing/. For my big surprise, the new created Git repository became into the new project workplace on Eclipse with .git directory in the parent directory. It is not a obvious contradiction?. If I let the mouse pointer over the option "Use or create repository in parent folder of project" a very clear help tag with the following text:
When checked, this wizard will try to find or create a repository in the parent folder hierarchy of the selected projects.
Typically, newly created projects are located in the Eclipse workspace, thus repositories created this way would also end up in the Eclipse workspace.
This is not recommended for several reasons explained in the EGit user guide.
So, after some research, my logical conclusion is to create a Git bare repository and then link it to the project located in the workspace... wrong! bare repositories are not available to a Eclipse project.
I need a serious explanation on this.
Seems that I went wrong about what I thought was a contradiction in the EGit User Guide and the EGit behaviour about moving the project directory to the Git repository.
When the project files are moved as a working directory of the Git repository (with a Git metadata folder at the same level), they're still under the Eclipse control, as Eclipse workspace. But as EGit User Guide says (http://wiki.eclipse.org/EGit/User_Guide#Eclipse_Workspace_and_Repository_working_directory), the .git metadata folder should NOT be into the workspace... well that's when I was wrong, cause it is a Eclipse project/Git working folder... but it IS NOT an Eclipse workspace by any means, so the Git metadata folder is not editable, as any other source project file, just for Git (and the EGit Eclipse plugin, of course).

Egit Eclipse best practises (play framework 2,.0) project

Im very new to git ingeneral, egit and github.
The problem:
Lets say I have a project for eclipse in c:/username/workspace name "Test". So I versioned it and pushed it up to github.
Now I can see all my Files in github under the directory "Test" in github. In example /src. The "Test" directory is not versioned. only the name of the repository is "Test".
My next step was to delete my local files and fetch my project again(For testing). After that I had to import my project again (but I had to use the new project wizard) over the egit view. Unluckily also the wrong scala version was detected. (Was a play framework project). So I had a big exclamation mark on the project view.
My questions:
What is the best practice to oush a project to github so everyone can participate? Everything under the project folder? Obviously some information got lost through the process.
How can I prevent to generate a new project every time someone clones the repository?
What about best practices for using git inside the workspace. Eclipse warned not to put the project inside the workspace.
Im coming from a subversion background :/. Maybe a general missunderstanding.
Thanks in advance
Switching from SVN to Git in an Eclipse environment can take some getting use to. (I'm still getting accustomed to it myself.) Keep in mind the difference between the role of the .git folder and the .svn folders for Git and SVN respectively. There is a .svn folder at every folder level in the working copy. There is no .svn folder in the traditional Eclipse workspace root. The "source controlled things" are subdirectories of the workspace, not the workspace itself. This is generally good because the workspace contains desktop specific settings that one generally doesn't want shared (much of it in the .metadata directory).
With Git, there is only one .git folder that contains everything. The first impulse is to do a
git init
at the workspace level. This would make the subfolders (the Eclipse projects) eligible for source control. But wait, so is .metadata. Of course you can ignore it. But you may have to ignore lots of other folders (projects) that you do not want source controlled. Of course, the .gitignore should be included. But others will have different files to ignore.
It turns out that its easier to use Git with Eclipse if you place the .git folder and its sibling source controlled folders (Eclipse projects) someplace else besides the workspace root. Your view in Eclipse doesn't change. You still see all your projects, both the Git-controlled and the SVN controlled and ones not shared at all. But underneath in the filesystem, the Git-controlled folders will be somewhere else. This is what EGit prefers.
On my desktop, I have a workspaces directory for most of my Eclipse workspaces. Now that I use EGit, I also have an egit directory where I keep the local EGit repositories. The Eclipse workspaces that share using EGit reference a subdirectory of egit. It's from these local Git repositories that one pushes and pulls from GitHub.
Sorry for the length. I got a bit carried away.