sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [CONF] Apache Sling Website > Getting and Building Sling
Date Wed, 30 Dec 2009 10:49:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=SLINGxSITE&amp;forWysiwyg=true"
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="">Getting
and Building Sling</a></h2>
     <h4>Page <b>edited</b> by             <a href="">Mike
     <div class="notificationGreySide">
         <h1><a name="GettingandBuildingSling-GettingandBuildingSling"></a>Getting
and Building Sling</h1>
<p>A quick guide for getting the Sling source, setting up Eclipse, and running the resulting
Sling instance.<br/>
Note that you don't <em>have</em> to build Sling yourself, if you don't need the
bleeding-edge stuff you can get prebuilt binaries from the <a href="/confluence/display/SLINGxSITE/Downloads"
title="Downloads">Downloads</a> page.</p>

<h2><a name="GettingandBuildingSling-Prerequisites"></a>Prerequisites</h2>

<p>Before you begin, you should have installed the following tools on your system:</p>
	<li>Java 5 or higher, Java 6 recommended</li>
	<li>Maven 2.0.7 (or later), Maven 2.1.0 recommended</li>

<p>To set up Eclipse you'll also need:</p>
	<li>Installed Eclipse Ganymede (tested with 3.4.2 on Win XP, SP3)</li>
	<li>Installed M2Eclipse plugin for Eclipse (sonatype) &#45;&gt; <a href=""
	<li>Installed <a href="" rel="nofollow">Subversive
plugin</a> or <a href="" rel="nofollow">Subclipse-plugin</a>
for Eclipse</li>

<h2><a name="GettingandBuildingSling-EnvironmentSetup"></a>Environment Setup</h2>

<p>The full build process requires quite some resources, so you may run into limits.
The following hints should show you what to setup before building Sling</p>

<h3><a name="GettingandBuildingSling-JavaHeapSpace"></a>Java Heap Space</h3>

	<li><b>Problem</b> &#45; Build aborts with report of <tt>java.lang.OutOfMemoryError:
Java heap space</tt>. This mostly happens while building the Jackrabbit Server module
	<li><b>Platforms</b> &#45; Windows XP, Mac OSX, OpenSolaris</li>
	<li><b>Fix</b> &#45; Set the a higher value for the maximum heap and
perm space for the build by setting or extending the <tt>MAVEN_OPTS</tt> environment

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=128m"

<h3><a name="GettingandBuildingSling-EnvironmentVariableSpace"></a>Environment
Variable Space</h3>

	<li><b>Problem</b> &#45; Build aborts when trying to launch the integration
tests with message</li>

<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>[INFO] Error while executing forked tests.; nested exception is
Error setting up environmental variables

error=12, Not enough space
	<li><b>Platform</b> &#45; OpenSolaris</li>
	<li><b>Fix</b> &#45; This problem is caused by missing swap space.
When running the integration tests in the <tt>launchpad/testing</tt> modules,
a process is launched by calling the <tt>exec</tt> system call. This copies the
process (copy-on-write, though) and thus allocates as much virtual memory as is owned by the
parent process. This may fail if swap space is exhausted.</li>

<h2><a name="GettingandBuildingSling-ConfiguringMaven"></a>Configuring Maven</h2>

<p>See <a href="/confluence/display/SLINGxSITE/MavenTipsAndTricks" title="MavenTipsAndTricks">MavenTipsAndTricks</a>.</p>

<h2><a name="GettingandBuildingSling-GettingtheSlingSource"></a>Getting
the Sling Source</h2>

<h3><a name="GettingandBuildingSling-WithSVN"></a>With SVN</h3>

	<li>Checkout Sling from the Repository.
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>$ svn checkout sling

<h3><a name="GettingandBuildingSling-WithEclipseSubversiveorSubclipse"></a>With
Eclipse Subversive or Subclipse</h3>

<p>If you use the Subversive plugin make sure you have installed the "Subversive Integration
for M2Eclipse Project" which can be found under the following Eclipse update site: <a href=""

<p>Also, make sure that you have installed either the "Maven SCM handler for Subclipse"
or the "Maven SCM handler for Subversive"</p>

<h4><a name="GettingandBuildingSling-Createanewworkspace"></a>Create a new

<p>It's best to create a new workspace for the sling project:</p>
	<li>Menu: File-&gt;Switch Workspace-&gt;Other...</li>
	<li>Enter a path for the new workspace and click OK</li>
	<li>When Eclipse has restarted its time to adjust some configs</li>
	<li>Turn off automatic build (Menu: Project-&gt;Build Automatically)</li>
	<li>Go to menu: Window-&gt;Preferences, in the preferences dialog select Java &#45;&gt;
Compiler &#45;&gt; Errors/Warnings</li>
	<li>Expand the "Deprecated and restricted API" and change "Forbidden references (access
rules)" from "Error" to "Warning"</li>
	<li>Click OK</li>

<h4><a name="GettingandBuildingSling-CheckouttheSlingsource"></a>Checkout
the Sling source</h4>

	<li>Menu: File-&gt;Import</li>
	<li>In the Import wizard select Maven-&gt;"Check out Maven Projects from SCM"</li>
	<li>Click next</li>
	<li>In the "SCM URL" field pick "SVN" and enter the url ""</li>
	<li>Click Finish</li>

<p>Eclipse will now start to download the source and import the Maven projects. You
might encounter some "Problem Occured" dialogs about "An internal error..." but just click
OK on those and let Eclipse continue with the import. Be warned: This could take some time
(it was 30 minutes on my lap)&#33;</p>

<p>Maybe something in sling-builder gets a bit messed up (I didn't ran into that problem,
but Pontus reported that) then you can simply fix it with revert:</p>
	<li>In the Project Explorer right click on the "sling-builder" project and select the
Team-&gt;Revert... menu</li>
	<li>A couple of changes will be displayed</li>
	<li>Click OK</li>

<h2><a name="GettingandBuildingSling-BuildSling"></a>Build Sling</h2>

<h3><a name="GettingandBuildingSling-WiththeMavencommandlinetool"></a>With
the Maven command line tool</h3>

	<li>Enter the directory and do a full build and local install (below are unix/linux
commands, slightly different under windows)
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>$ cd sling
$ export MAVEN_OPTS="-Xmx256m -XX:MaxPermSize=128m"
$ mvn -s /dev/null clean install
<p>Note: On windows just leave out the /dev/null and make sure you have an empty settings.xml
file for maven (located in your user directory under .m2).</p></li>
	<li>Enter the <tt>launchpad/app</tt> directory and launch Sling for the
first time
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>$ cd launchpad/app
$ java -jar target/ -c sling -f -
<p>Messages should now be printed to the console which is used as the "log file" because
the <tt>&#45;f</tt> command line option is set to <tt>&#45;</tt>
indicating to use standard output as the log file. The <tt>&#45;c sling</tt>
command line option instructs Sling to use the <tt>sling</tt> directory in the
current directory for its data store, which is the Apache Felix bundle archive, the Jackrabbit
repository data and configuration. You may also specify another directory here, either a relative
or absolute path name (See also <a href="/confluence/display/SLINGxSITE/Configuration"
title="Configuration">Configuration</a> for more information).<br/>
After all messages have been printed you should now be able to open the Sling Management Console
by pointing your web browser at <tt><a href="http://localhost:8080/system/console"
rel="nofollow">http://localhost:8080/system/console</a></tt>. You will be prompted
for a user name and password. Enter <tt>admin</tt> as both the user name and the
password (this may be set on <em>Configuration</em> page later). From this console,
you may manage the installed bundles, modify configuration objects, dump a configuration status
and get some system information.<br/>
To stop Sling, just hit <tt>Ctrl-C</tt> at the console or click the <em>Stop</em>
button on the <em>System Information</em> page of the Sling Management Console.</p></li>

<h3><a name="GettingandBuildingSling-WithM2Eclipse"></a>With M2Eclipse</h3>

	<li>Make sure you're in the Java perspective (Menu: Window-&gt;Open Perspective)</li>
	<li>Menu: Run-&gt;Run Configurations...</li>
	<li>In the Run Configurationa dialog right click on "Maven Build" and select "New"</li>
	<li>Change Name to "Build Sling"</li>
	<li>Click "Browse Workspace..." and select "sling-builder"</li>
	<li>Enter "clean install" in Goals</li>
	<li>Click on the JRE tab</li>
	<li>Enter "-Xmx256m &#45;XX:MaxPermSize=128m" in "VM arguments"</li>
	<li>Click Apply</li>
	<li>Click Run</li>

<h3><a name="GettingandBuildingSling-AlternativesetupinEclipsewithoutM2Eclipseplugin"></a>Alternative
setup in Eclipse without M2Eclipse plugin</h3>

<p>In case you do not want to use the M2Eclipse plugin there's another setup which lets
you have turned on the automatic build:</p>
	<li>Checkout the whole sling trunk with subversive or subclipse plugin from the SVN
to a single project</li>
	<li>Then manually add all src/main/java and src/test/java of the bundles to the project
as source folders</li>
	<li>Add all required libraries to the build path</li>
	<li>Now you can build either in Eclipse or even better use "mvn clean install" on the
command line</li>

<p>If you use "mvn clean install" to build Sling be sure you have set MAVEN_OPTS to
"-Xmx384m &#45;XX:PermSize=256m" otherwise you probably get OutOfmemory errors.</p>

<p>Congratulations &#33; You should now have a running Sling instance, which you
may start playing around with.</p>

<h2><a name="GettingandBuildingSling-FurtherTipsandTricks"></a>Further Tips
and Tricks</h2>

<h3><a name="GettingandBuildingSling-DebugSlinginEclipse"></a>Debug Sling
in Eclipse</h3>

<p>You can use remote debugging to debug Sling in Eclipse, here's a little How-To</p>
	<li>start Sling from the command line with
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>java -Xmx384M -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n
	<li>Open Menu Run-&gt; Debug configurations</li>
	<li>Right click on "Remote Java Applications"</li>
	<li>Choose "New"</li>
	<li>in the "Connect" tab choose the Eclipse Sling Project for the field "Project" with
the browse button</li>
	<li>Let the Connection type be "Standard (Socket Attach)"</li>
	<li>the host should be localhost</li>
	<li>set the Port to 30303</li>
	<li>On the source tab click on the "Add" button</li>
	<li>Select "Java Project"</li>
	<li>Select all Sling projects and click OK</li>
	<li>Click "Debug"</li>

<p>Now you should be able to set breakpoints, evaluate properties, and so on as usual.</p>

<h3><a name="GettingandBuildingSling-DebugMavenTestsinEclipse"></a>Debug
Maven Tests in Eclipse</h3>

<p>In the same way you can debug the sling app you are also able to debug a maven test.
Just run the maven tests like this</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>mvn -Dmaven.surefire.debug test

<p>The tests will automatically pause and await a remote debugger on port 5005. You
can then attach to the running tests using Eclipse. You can setup a "Remote Java Application"
launch configuration via the menu command "Run" &gt; "Open Debug Dialog..." (see above).<br/>
For more information on this see the <a href=""
rel="nofollow">Maven Surefire Docu</a>.</p>

<h3><a name="GettingandBuildingSling-SimplewaytodevelopnewbundleinEclipseforSling"></a>Simple
way to develop new bundle in Eclipse for Sling</h3>

<p>The easiest way that I found is to create a new folder in the existing Eclipse workspace.
After that you can follow these steps:</p>
	<li>Start by copying and adapting an existing Sling pom.xml (eg. the pom.xml from the
espblog sample)</li>
	<li>Generate the Eclipse project files using mvn eclipse:eclipse</li>
	<li>Choose File/Import in Eclipse and select "Existing projects into workspace"</li>
	<li>Now you can create, edit and compile the files in Eclipse</li>
	<li>To create the bundle jar and install it, just use the command line "mvn clean install"
in the project directory</li>
	<li>If you have a running Sling app you can install the bundle on the command line
with "mvn &#45;P autoInstallBundle clean install &#45;Dsling.url=<a href="http://localhost:8080/system/console"

<p>If adding dependencies to the poms, run mvn eclipse:eclipse again and refresh the
project in Eclipse. Debugging works as described above.</p>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href=""
class="grey">Change Notification Preferences</a>

       <a href="">View
       <a href="">View
       <a href=";showCommentArea=true#addcomment">Add

View raw message