This how-to is served as my memo to import a Bitbucket project into Eclipse. First things first, make sure you have an up-and-running Eclipse with EGit (in this how-to I am using Eclipse Indigo 3.7.2 with EGit 1.3.0)
- Create a folder to hold the workspace for your new project (You can skip this step if you want to use an existing workspace), I will use one of my project on Bitbucket in this how-to. It’s GreenMail web application. So I create a folder name greenmail-webapp
- Open the Git Repositories view (it’s under Windows -> Show View -> Other…, then under the Git category).
Click Clone a Git repository and paste in the whole Git repo URL to the URI textbox, EGit will automatically fill in other textbox with the right value (so cool!), all you need is to enter the correct password. Then click Next.
At the Branch Selection screen you are able to choose a branch to clone, my project has only one branch (master). If you clone an empty project from Bitbucket, just click Next.
At the Local Destination, browse to your workspace directory for this project. I usually don’t check-in the .project and .classpath files into the VCS, I just generate them locally right after I checkout/clone instead. If your build tool does not generate those files for you or you are the only one in this project, it’d better to check-in those files.
Now, let’s generate the Eclipse project files. I use Gradle as my build system, so it’s just a command away.
Before running this, make sure you’ve already applied the
eclipseplugin in your build.gradle. If you use Maven, please include the maven-eclipse-plugin into your pom.xml and run the command
The above commands will generate/overwrite the .project and .classpath for you.
Returning to your Eclipse, you can now Import your new cloned project into your workspace by right clicking on your in the Git Repository view, select Import Projects…
Select Import existing projects
Select the project you want to import.
Author Tinh Truong