Skip to Content

As stated in the first post of my “Essentials” series it’s all about lowering the entry barrier and helping newbies to get started with SAP NetWeaver Cloud. So, in this blog post I quickly want to provide you with the ‘bare necessities’ to install the required tooling for Git and Maven for Eclipse in order to simplify the process of getting examples from social code sharing sites such as Github up and running.

Note: Please do not expect me to provide you with the ultimate beginners guide to the stated technologies! By no means do I want give impression that I’ll serve you all you need to know on a silver plate. You’d certainly be well-advised to familiarize yourself with these tools IF you want to stay in control of what you’re doing! All I want to achieve with this post is to help you with getting your setup right in just a few minutes – establishing a basecamp if you will – you still have to climb the rest of the mountain yourself though. 😉

Installing EGit

Alright, in order to install the Git plugin for Eclipse (called EGit) you would need to do the following steps:

  1. In Eclipse, goto “Help > Install New Software…”
  2. Depending on which version of Eclipse you use (we currently support Juno and Indigo) you have to select the corresponding Update Site from the drop-down box
  3. Select the plugins/features checked in the following screenshot under the “Collaboration” node

/wp-content/uploads/2012/11/egit_updatesite_152858.jpeg

Installing Maven for Eclipse

Now that we got EGit installed, we want to add Maven support: m2e-wtp. That may sound a bit cryptic (gotta love developers, right!), so let’s explain: it’s a Maven plugin for Eclipse that allows to use Maven-based projects in conjunction with the Web Tools Platform (WTP).

  1. Again, goto “Help > Install New Software…”
  2. Enter “http://download.eclipse.org/m2e-wtp/releases/” in the drop-down box and click “Add”
  3. Select the plugins/features checked in the screenshot below:

/wp-content/uploads/2012/11/m2e_updatesite_152864.jpeg

EGit configuration

Next thing we do is to configure EGit. For that we have to perform the following steps:

  1. Goto “Preferences”
  2. Enter “Git” in the filter field in the top-left corner
  3. Select the “Configuration” node
  4. Copy & adjust the settings shown below as they match your environment (proxy, email, etc.)

/wp-content/uploads/2012/11/egit_config_152904.jpg

Maven configuration

Last remaining step is to configure Maven. It’s simple:

  1. Goto “Preferences”
  2. Enter “Maven” in the filter field in the top-left corner
  3. Select the “Installations” node
  4. If you already haven Maven installed you want to point to a (global) pre-existing settings file. If not, you may want to create a settings.xml file and point to it here. I attached a sample settings.xml file that shows you how-to speficy a proxy server.

So, that’s pretty much it… you may want to check that it all works fine by cloning one of the SAP NetWeaver Cloud samples on Github. Let’s do it together…

Cloning a git repo(sitory)

So, let’s got to one of the easier samples on our Github account: https://github.com/sapnwcloud/springrest

/wp-content/uploads/2012/11/github_cloning_152884.jpeg

Copy the URL to the repo (https://github.com/sapnwcloud/springrest.git) by clicking the little notepad icon. (Note: As you can see from the screenshot I’ve been logged on with my Github user and as I’m a contributor to this project I have both Read + Write access.)

Now, let’s go back to Eclipse and open the Git perspective via the “Windows > Open Perspective > Other…” menu entry and the selecting the “Git Repository Exploring” option. In this perspective you have the “Git Repositories” view on the left. In the corresponding menu (top-right of the view), click on the “Clone Git repository and add the clone to this view” icon.

In the pop-up window, select “URI” as the repository source. Click next to get to the next step of the wizard. Here, all the details should already be pre-filled (if you have used the notepad button on Github!) If you should have a Github user and you do want to contribute to the respective repo, you may want to maintain your username/password in the authentication section at the bottom. But cloning the repo should equally well work without it. Press “Next” and skip over the next wizard step – there is no need to make any changes. On the third and last page, select the directory to clone this repo to. In general, it’s a good idea to store all your git repositories in a dedicated folder. Click on “Finish” to clone the repository.

/wp-content/uploads/2012/11/github_cloning2_152894.jpeg

Let’s switch to the “Java EE” perspective and use the “File > Import…” menu and then the “Existing Maven projects” option. Provide the link to the root directory and click on Finish. Now, the project sources should be imported into your workspace. We’re almost there…

Open up the project properties by using the context-menu of the project in the “Project Explorer” view. Select ‘Properties’ and then “Project Facets”. here, you need to convert the project to facted form (This is an Eclipse-specific setting and hence – by design – not part of the Maven project nor the project repo.) Once this has happened you should see a “Dynamic Web Module” Facet being active. Select it. On the right hand side you should see a “Details/Runtimes” toggle. Switch to the “Runtimes” option and select “SAP NetWeaver Cloud” as the designated runtime.

Last thing you need to do is to use the context.menu of the project to trigger the build by using the “Run As > Maven install” option. Once the build has ended successfully you can add the project to a local or remote server as you would do with non-Maven projects….

Hope this blog post is useful to some of you… let me know about your experiences (good AND bad!)

To report this post you need to login first.

10 Comments

You must be Logged on to comment or reply to a post.

    1. Chris Paine

      Very useful video – helps with little things like explaining changing the maven project to be a multi-faceted web one so that it can be deployed to a HANA Cloud Platform instance.

      Thanks for posting. 🙂

      (0) 
  1. Kaloyan Raev

    Nice post, Matthias.

    By the way, installing add-ons in Eclipse is much easier and friendlier through the Help > Eclipse Marketplace wizard than the Help > Install New Software one.

    Very soon the additional steps for installing EGit and m2e-wtp won’t be necessary because with the release in 2013 (Kepler) they will be included by default in the Eclipse IDE for Java EE Developers package.

    (0) 
  2. Robert Russell

    Hi Matthias,

    Thanks for the blog, I followed the link from the enterprise granny blog

    http://scn.sap.com/community/developer-center/cloud-platform/blog/2013/05/27/enterprise-granny-part-2-making-it-run-like-never-before

    One thing that I noted from this blog is the git link – to quote

    So, let’s got to one of the easier samples on our Github account: https://github.com/sapnwcloud/springrest

    After cloning and nothing importing and no errors and no project to select, I went back to the gitub page and scrolled down and found.

    “We have moved to https://github.com/SAP/cloud-springrest

    So after cloning that,I have published to the cloud.

    Back to the Granny blog for me now.

    Best Regards,

    Robert

    (0) 
  3. Chris Paine

    Hi Matthias,

    would you have some advice for what Maven archetype to use when creating a new (rather than cloning from an existing repo) project?

    Finding it harder than I thought to migrate my project (which was not built using Maven) to maven and jpa.

    As a first attempt I’ve just updated my pom.xml to look like enterprise granny’s and will remove/add dependencies as I go along.

    Do let me know if you can think of a better way to get a quick start. (guess I really should post this in the forums… )

    Thanks,

    Chris

    (0) 
    1. Matthias Steiner Post author

      Hi Chris,

      hm, I usually skip the archetype selection altogether and just start off with a plain pom.xml and add my dependencies manually.

      Can’t remember if I ever migrated a non-Maven project at all to be honest, hence I’m not sure what challenges you faced. There’s an eclipse feature to turn a project into a “Maven project/facet” from what I know. I’d assume that the biggest difference between a Maven project and a non-Maven project would be the source folder structuring. Maybe the simplest way would be to create an empty Maven project and simply copy the sources and he web-app resources into the corresponding folders ?!?

      Cheers,

      Matthias

      (0) 
      1. Chris Paine

        Thanks!

        I had the added complexity of already having my non maven project synced to github. In the end, created new maven project, imported the existing code from git repo, then created a new branch and went to town on moving/renaming all the folders. After a reasonable amount of work, code deploys and runs successfully. As I previously mentioned, I did have issues with eclipse not deploying the maven built war to saphcp server, but building its own war each time according to the details in the web deployment option in the project properties. Once I pointed this to the maven snapshot everything worked and deployment included the maven dependencies.

        Next step to get my jpa models to start storing some data.

        Cheers,

        Chris

        (0) 
  4. Nigel James

    5*’s just for the note in the second paragraph.

    Dev’s dig in and learn new skills. You will love yourself for it.

    Thanks for a great blog Mattias.

    (0) 

Leave a Reply