Eclipse is one of the favourite development environments among JAVA developers. At first glance setting up Eclipse to work with Sling is confusing so this article is  intended to help you get going with Sling development using Eclipse without pain.

Eclipse can be used to checkout code from the Sling repository and source build using maven. You can add new modules and re-build using maven inside Eclipse.

The tutorial describes how to setup the development environment for Eclipse version 3.3.2 (Europa). 

Here is how you work this magic.

Install Subclipse plug-in for Eclipse

To use subversion in eclipse you have to install the Subclipse plug-in using the following Eclipse update location,

        http://subclipse.tigris.org/update_1.2.x

Steps to install Subclipse plug-in,

    1.  In Eclipse IDE go to Help - > Software Updates - >  Find and Install.

    2.  Select "Search for new features to Install" and clickk next.

    3.  Click on the button "New Remote Site" in the window and enter a name ex: Subclipse and the URL specified above in the URL: field and click "OK".

    4.  The new name you specified will appear in the "Sites to include in search:" window select this and click finish.

    5.  In "Select  features to install" window select Subclipse and click "Finish" button. Deselect Mylin and Buckminister Integrations if "Finish" Button appears inactive.( I didn't find any use in the integrations and the "Finish" button was not active until I deselected them).

   6.   Agree to the licence agreement and proceed to install once Eclipse prompts you.

   7.   After installing you have to restart Eclipse. You can view repositories by going to Open Perspective - > Other - > SVN Repository Exploring.

Install Maven2 plugin for Eclipse

 To use the maven 2 plug-in you have to install the maven 2  plug-in using the following Eclipse update location,

         http://m2eclipse.sonatype.org/update/

    Please follow the steps 1 to 4 described in "Install Subclipse plug-in for Eclipse" section using the above URL.

    in Step 5 as before deselect Mylin Integration if "Finish" Button appears inactive.( I didn't find any use in the integrations and the "Finish" button was not active until I deselected them).

    Then agree to the licence agreement and proceed to install once Eclipse prompts you. Once you restart it's possible to use maven.

Creating a Maven 2 + Java  project.

 To checkout and edit or add new modules to Sling you have to first create a Java + Maven 2 project in eclipse. You must see a red "m" icon and blue "J" icon on the project directory.

 Follow these steps to create a Maven 2 + Java project.

    You should create the project in your workspace level for successful results. For some reason checkout fails if projects are nested in levels below workspace.  (This was the result I observed in my case)

   1. Go to File - > New - > Project and select Maven Project by expanding Maven folder in the "Select a wizard" menu and click next.

I had to check the box "Create a simple project (skip archetype selection)" on this screen. AndreasHartmann

   2. select the location to you want to checkout source from the repository. and click next.

   3. Click next in this screen and when you come to the next screen then set the following.

      Group Id : org.apache
      Artifact Id : Sling

      Click finish.

      This is a step where the IDE creates a pom.xml file for the new project using the details entered in Step 3.
      The values we enter here are not important because we will be replacing this pom.xml when we are checking out the source.

      The IDE insists that there should be values entered in this step or you will not be allowed to create the project. Therefore don't worry much about what you entered in Step 3 before clicking "Finish".

Checking Out Sling source to the new project.

 Follow these steps to checkout the sling source from Sling repository.

    1. Right click on the project and select "import".

    2. In the "Import" screen select "Other - > Checkout projects from SVN" and click next.

    3. Select create new repository in the "Checkout from SVN" screen and click next.

    4. In the URL: field enter the path to sling trunk which is http://svn.apache.org/repos/asf/incubator/sling/trunk and click next.

    5. Click "Finish" to checkout.

Building with maven plug-in

 First you have to download Maven 2 from http://maven.apache.org/download.html and unzip it.

 Then follow these steps.

    1. Either  right click on  project go to  "Run  As  - > maven build"  or  select the green  play button and  click on "Open Run Dialog".

    2. In "Run" screen select "Main" tab and enter the directory of the project where you checked out the source , type "Install" as the goal and

        give the location to the unziped maven directory by browsing using "Configure - > Add" in the "Maven Runtime" field .

    3. Select  "JRE" tab and enter "-Xmx256M" into the "VM arguments" box to increase heap size.

    4.  Click  Apply  to save settings and  then Run to build.

    5. You can click console icon in the lower right corner to view progress.

    6. In order to run the launchpad after building change the base directory from the current location to the launchpad/webapp/ directory and change goal to "jetty:run"

        Click  Apply  to save settings and  then Run to build. Now you can run launchpad in yuor web browser after build completes.

Thats all you have to do to set up your Sling development environment in Eclipse IDE.

   
 

    

     

  • No labels