Trouble creating Eclipse/Java projects from Git repo - java

I am brand new to Git and EGit. I have been asked to troubleshoot a project stored in a Git repo located at http://com.myorg.gitrepo/githome/myapp.git.
First I tried just doing this on the Git command-line. From a terminal, I executed:
git clone http://com.myorg.gitrepo/githome/myapp.git myapp
The command was successful and I can now see a project checked out under /home/myuser/myapp (I'm on Ubuntu 14.04).
Now I'm trying to load the checked out project into Eclipse as a Java project. Here are the steps I'm taking:
1. Right-click Package Explorer>> Import >> Git >> Projects from Git >> Next
2. Existing local repository >> Next
3. Select `myapp` project to import >> Next
4. No project found!?!?
As you can see, EGit is looking for some config that isn't there, or perhaps I'm just using it incorrectly.
My questions:
What am I doing wrong, and what can I do to fix this and get the project imported?
How could I improve this process in the future, by using EGit to do the initial clone (bypassing the need to use the raw Git command line)?

Are you sure the project you are importing contains the files eclipse uses for project management?
How does the .gitignore look like? Does it include .metadata/, .project/ for example?
If it does, it means that repo is configured to ignore the configuration files eclipse uses for managing the project, and you should use the wizard to create the project.
I think it is considered good practice to not include any editor specific files in the repos, as these cause a lot of conflicts, and the project shouldn't really depend on the editor like that anyways.

Related

Problems with IntelliJ at cloning repo from github

I am new to github. I tried to clone a repo and then pull the files on my computer. All the other team members did the same thing and it worked for them. When i open the project with Intellij all the .java files look like this:
files
It also says that my SDK isn't set.
I tried to set my SDK, and also i tried to set the java directory as 'sources root' because someone said that is a problem with the project structure.
These problems disappeared but then IntelliJ didn't recognize that my project is a maven project so i had to add manually the file pom.xml and refresh maven.
Then this problem disappeared but i had another:
"Cannot start compilation: the output path is not specified for module 'cmsiss'.
Specify the output path in Configure Project."
I tried to set it from project structure but now I have this error:output error
Please help.
Open maven project using pom.xml file. File->Open->pom.xml
Sources should be pointed to project root, not java directory.
Give these a try.
The usual steps that I follow to open the project:
git clone <github clone url>
Open the project in intelli J using
File<Open
and browse to open the root of the project.
This should work fine but if it does not, a few more things you can try:
Try making the project root as a maven module
You can open the Project Structure to make sure you have Java SDK set up properly. It should show the java version you are using there.
Worst case, that is if nothing else works and if the project is not too big, just create a new maven project and make sure it runs, then add all the project files.
I pulled the project again and started from zero. I specified the SDK and then I opened the Maven project window and added a maven project (selected the pom.xml file) and refreshed it. Maven did it's job and created the project structure and all the stuff I've tried to do manually and finally worked!

Difficulty creating a brand new Eclipse project under version control of existing Git repositories?

I am new to Git and having difficulty understanding how (best) to create an Eclipse (Luna) project under Git version control when the repository already exists.
My intuitive thought is that I should:
1.1) Create an empty remote (origin) repository, for example on GitHub.
1.2) Clone the remote repository to my local drive.
1.3) Make Eclipse aware of the connection to my Git repository.
1.4) Create an Eclipse project within the local repository working directory.
1.5) Add and commit the project files to the local repository.
1.6) Push the commit out to the remote (origin) repository.
I think I have a reasonable understanding of how Eclipse interacts with Git after the project already exists, and is already under version control. But I am starting from the ground up and am having a great deal of confusion getting to that state.
Steps 1.3 & 1.4 are what I can find no documentation for; and have not been able to hack my way through. I imported a local Git repository into Eclipse using the wizard. I can then create an Eclipse project in that directory. But for some reason I am not able to close, or later (e.g. after restarting Eclipse) open the project. The "Open Project" and "Close Project" options are greyed out on the menu. The project does not appear in the list of projects for that Eclipse workspace. I see the external project files that Eclipse has generated. From within Eclipse, when I try to open the project file, I'm told it is not a project. If I try again to create the same project, I'm told that it already exists. So I have a project in the git repository, but can't work with it. Eclipse doesn't recognize it's a project (for opening) while simultaneously acknowledging that it already exists (preventing redundant creation). I'm obviously doing this incorrectly. But have not been successful after many attempts to make this work.
I could follow an alternate order explained at http://wiki.eclipse.org/EGit/User_Guide:
2.1) Create an Eclipse project completely independent from Git.
2.2) Create a local Git repository around the Eclipse file.
2.3) Create the remote (origin) repository from the local repository.
However, I don't feel comfortable with this approach:
a) If I create things in this order, won't the remote Git repository see the local repository as origin (i.e. it's parent)?
b) I still haven't learned how to create an Eclipse file, from scratch, under version control of a preexisting repository. I have only learned to create a brand new repository from an existing Eclipse Project.
c) There is discussion in the EGit/User Guide (http://wiki.eclipse.org/EGit/User_Guide) about "Creating a Git Repository for multiple Projects". This illustrates how to create a brand new repository from several preexisting Eclipse projects. But it does not explain how to later create a brand new project into the existing repository containing multiple Eclipse projects.
How do I create a brand new Eclipse project, under version control of a preexisting repository?
I think I've figured out the best way to do this:
1) Create a new remote repository. Use GitHub or
git init --bare
2) Clone the remote repository to local disk.
cd pathForTheLocalRepository
git clone remoteRepositoryPath Project1
3) Within Eclipse, File->New->Java Project
3a) In the Create Java Project window, enter project name, uncheck "Use Default Location", and for "Location:" enter or browse to the local repository on disk.
4) Eclipse automatically recognizes that it is within a git repository.
5) Right click on the project in the Project Explorer window.
6) Team->Add To Index
7) Team->Commit
8) Team->Push to Upstream
9) The push creates a master branch when we were working with an empty remote repository.

How to configure a project imported from GIT to be a Java project in Eclipse?

I've imported a project from Git in Eclipse using this method:
File > Import > Git > Projects from Git > Next > Clone URL .
At this point I inserted the URI like this https://github.com/mygituser/My-Project .
Then my user and password, and the project was imported.
The problem is that Eclipse didn't recognize it as a Java project, and I really don't know why.
As consequence, I can't see errors or warnings on my project and neither use autocomplete, I'm getting this message "This compilation unit is not on the build path of a Java project".
Also, right click on My-Project > Build path shows the message "No actions avaliable".
If you need more information to help me, could you ask me on comments, please?
I appreciate your attention!
Most people don't include build files in repositories, only source. What you need to do is create a new Eclipse project the create a Git repo on top of that:
Create a new Eclipse project, and go to it with your terminal.
git init to initialize a repo.
git remote add origin https://github.com/mygituser/My-Project to add the remote.
git pull -u origin master to pull the changes.
Also, make sure that when you commit, you don't add build files that the author kept out. You can do this via a .gitignore file. Simply take this file and add it to your project directory.
This method applies to most Git repositories, as build and compiled files are usually left out.
Note that this method requires that you install Git for command line (or Git Bash). You can get Git at their website.
Since you already have the source code downloaded from the git repository, you should be able to create an Eclipse project from the existing source code.

Trying to move GIT Project from IntelliJ IDEA to Eclipse with EGit?

My firm is making me move back to Eclipse and I am trying to move GIT Project from IntelliJ IDEA to Eclipse with EGit?. The issue I am having is that I access my project from the command line with the following command:
git clone git#git:common.git
That's how I clone it and then I just work in IntelliJ without a issue, In Eclipse with EGit I am getting the following screen and every setting I am trying down work
Can someone please tell me based on the command line what options I should be using.. thanks
I've always had problems cloning via EGit. Here's what works for me:
Clone via the command-line as usual.
Create or import your project into an Eclipse workspace.
Right-click the project in the Navigator or Package Explorer.
Team > Share Project > Git > Next.
Since there will already be .git repo there, select 'Use or create repo in parent...".
Finish. Give it a few seconds and you should see your project files decorated with Git repo information.

Android Eclipse test projects cannot be used with a project being built in an Android build tree

An Android Java project placed in a git repository and built in an Android tree in /packages/apps needs to have the project files located at the root of the git repository.
This is problematic for creating a complementary Test project, which should ideally be included in the same git repository so commits are atomic for both code and tests. Eclipse gets very unhappy if you include the Test project as a subdirectory.
Is there an appropriate approach for dealing with this other than creating a second repository?
I dont know git but this seems to be a code organization problem rather than git issue. I think I would create a workspace and then have the application and test project as sub projects within that workspace, like this
/packages/apps/<product-name> - This is the workspace
/packages/apps/<product-name>/app-name - This is the application
/packages/apps/<product-name>/app-name-test - This is the test project for the application
I don't use git inside eclipse. I have my repo cloned at ~/work/repo and have 2 subfolders one for the actual project and one for the test project. Then inside my workspace i have 2 symlinks that point to the folders inside the repo folder. Eclipse thinks they are both normal projects and doesn't care about the repo management. I just go to command line and "cd ~/work/repo; git add .; git commit; " and i can commit both test and code at the same time.
Hope that helps

Categories

Resources