Importing Git Repos in Eclipse

Adam Treister edited this page Feb 2, 2018 · 3 revisions

This is assuming you have already followed the README to clone the repositories and can get a successful build on the command line using maven.

Installing Eclipse and Adding Git Repo

  • Download latest version of eclipse, probably “eclipse for java developers”, from eclipse.org/downloads.
  • Unpack the archive and run eclipse.
  • Go to the git perspective: Window > Perspective > Open Perspective….
  • In the Git Repositories view, select Add an existing local git repository to this view from the icon options.
  • In the Directory field, enter /your/path/to/git/cytoscape/cytoscape, then click the Search button. (you may need to check the look for nested repositories checkbox). Make sure to choose the second level cytoscape directory -- cytoscape/cytoscape.
  • Select all the cytoscape repositories and click Finish. The Git Repositories view should now look something like this:

Maven plugin for Eclipse

Before you can import the projects into eclipse you need to install the maven-git bridge plugin.

  • Go to File > Import….
  • Select Maven > Check out Maven projects from SCM and click Next.
  • In the dialog click the link that says Find more SCM connectors in the m2e marketplace.
  • Find and select m2e-egit, then install by clicking Finish and then clicking through subsequent dialogs.
  • Restart Eclipse.

Import Maven Projects

  • Now go back to the Git perspective.
  • We’ll start by importing the API projects.
  • Expand the api repository
  • Right click on the Working Tree directory
  • Select Import Projects…
  • Select all the projects and click Finish -- loading projects may take a while.
  • If you go to the Package Explorer in the Java perspective you should see all the projects, and there shouldn’t be any compile errors. Note: it may take a minute for the folder icons to acquire the maven "M". You can find most Eclipse icons described here.
  • If the Package Explorer shows compilation errors, it could be that the api repository has a defective taglets sub-project. Close the taglets project and rebuild via Project > Clean.

This step is no longer required since the Oxygen release of Eclipse. If you are current, skip down to "Review and Repeat"

  • The maven importer sets up the projects as maven projects, but does not set them up properly as git projects.
  • Delete all the projects you just imported (no, I’m not joking), but ***do not *** delete contents on disk.
  • Click Continue to ignore warning about git sync state of the api-parent project.
  • Now go back to the git perspective and right click on the Working Tree node in the api repository again. This time select Import Projects… (not Import Maven Projects…).
  • Select “Import existing Eclipse projects” and click next.
  • Select all the projects and click Finish.

Review and Repeat

Back in the Package Explorer you should now have perfectly functional Java/Maven/Git projects for the api repo. Repeat the process for the impl repository, and maybe also the apps repository -- you probably don’t need the other ones. Everything should work as you'd expect in Eclipse (e.g., content assist, debugging, etc.), although sometimes you get double-hits when doing a file search. If this becomes annoying you can delete (or just close) the xxx-parent projects. In fact, you don’t really need anything that does not end in -api or -impl.

Note: You get the apps repo by running ./cy.sh apps (see main readme). The apps repository has some extra quirks because it uses submodules. Expand the Submodules node and make sure each core app is on the master branch. If not right-click on each one and select checkout and then select the master branch. You can then import them using the above process.

If you are curious why the “double import" steps, as far as I can tell the m2e-egit importer does not actually set up the git connection properly. But when you import the projects the first time it has the side effect of creating the .project files. After deleting the projects you can import them again as regular eclipse projects because the .project files are still there. The normal importer appears to set things up correctly.

Package Management in Eclipse

Now that you have dozens of projects -api and -impl littering your Package Explorer in Eclipse and two or three closed parent projects, scattered among your other potential projects in Eclipse, you may want to tidy things up a bit:

  • Create a new working set with File > New > Java Working Set.
  • In the creation dialog, move all the projects files you've imported above into this new working set. You might name it somethings like, "Cytoscape3Git", for example.
  • Via the pulldown icon in the upper-right of the Package Explorer, choose Top Level Elements > Working Sets. You should now see your Cytoscape3Git working set, plus "Other Projects" and any other working sets you've made previously.
  • Now you have all the relevant cytoscape project folders in one place. You can now easily see if you have local changes within any of the nested repos of the Cytoscape project from this view.

Git Management in Eclipse

  • To check out code from git, select the Git perspective, select all the cytoscape repositories, right click and select Pull. There’s an extra step to check out code for core-apps, expand the Submodules node and select all the core apps, then right click and select Pull.
  • The Git Staging view is where you will do most of your work with git.
  • Egit is pretty complicated. Here is a link to their user guide.
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.