incubator-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 Thu, 15 Nov 2012 13:41:00 GMT
    <base href="">
            <link rel="stylesheet" href="/confluence/s/2042/9/1/_/styles/combined.css?spaceKey=SLINGxSITE&amp;forWysiwyg=true"
<body style="background: white;" bgcolor="white" class="email-body">
<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="">Carsten
                         <h4>Changes (1)</h4>
<div id="page-diffs">
                    <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* or using Eclipse <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >Note that you don&#39;t _have_
to build Sling yourself, if you don&#39;t need the bleeding-edge stuff you can get prebuilt
binaries from the <span class="diff-changed-words">[Downloads<span class="diff-added-chars"style="background-color:
#dfd;">|</span>]</span> page. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>A full build of Sling takes
5-10 minutes on a recent computer once your local Maven repository is up to date. The first
build may take much longer than that if you start with an empty local Maven repository, as
Maven will then download its plugins and all the required dependencies. <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
    </div>                            <h4>Full Content</h4>
                    <div class="notificationGreySide">
        <h1><a name="GettingandBuildingSling-GettingandBuildingSling"></a>Getting
and Building Sling</h1>
<p>A quick guide for getting the Sling source, then building and running the resulting
Sling instance; either without or with Eclipse.</p>

<p>Sling can easily be built:</p>
	<li>from the command line (using SVN and the Maven command line tool)</li>
	<li>or using Eclipse</li>

<p>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=""
class="external-link" rel="nofollow">Downloads</a> page.</p>

<p>A full build of Sling takes 5-10 minutes on a recent computer once your local Maven
repository is up to date. The first build may take much longer than that if you start with
an empty local Maven repository, as Maven will then download its plugins and all the required

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

<p>Before you begin, you need to have the following tools installed on your system:</p>
	<li>Java 5 or higher; Java 6 recommended</li>
	<li><a href="" class="external-link" rel="nofollow">Maven</a>
3.0.2 or later; enforced by the Sling parent pom</li>

<p>If you want to set up Eclipse (not required to build Sling) you'll also need the
following installed:</p>
	<li>Eclipse (tested with 3.4.2 and 3.5.x on Win XP, SP3, 3.6.x on Win7, 3.7 on MacOS
X 10.6); just a plain installation of the platform runtime binary and the JDT will be adequate
(you can install the IDE for Java Developers for convenience)</li>
	<li>M2Eclipse plugin for Eclipse (sonatype) &#45;&gt; <a href=""
class="external-link" rel="nofollow">instructions</a></li>
	<li><a href="" class="external-link"
rel="nofollow">Subversive plugin</a> or <a href=""
class="external-link" rel="nofollow">Subclipse-plugin</a> for Eclipse</li>

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

<p>The full build process requires quite a lot of 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 reports of <tt>java.lang.OutOfMemoryError:
Java heap space</tt>. Alternatively the build may randomly fail during the integration
	<li><b>Platforms</b> &#45; This happens on all platforms</li>
	<li><b>Fix</b> &#45; Increase the values of the maximum heap and perm
space for the build by setting or extending the <tt>MAVEN_OPTS</tt> environment

<p>For 32bit platforms you should use</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=256m"

<p>For 64bit platforms, you should use</p>
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>MAVEN_OPTS="-Xmx512M -XX:MaxPermSize=512m"

<p>For more information see <a href=""
class="external-link" rel="nofollow">SLING-443</a> and <a href=""
class="external-link" rel="nofollow">SLING-1782</a>.</p>

<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 the message
<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
<p>This problem is caused by insufficient 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.</p></li>
	<li><b>Platform</b> &#45; OpenSolaris</li>
	<li><b>Fix</b> &#45; If this issue persists you will need to check
your system requirements and configuration with regard to swap, before taking action - if

<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>First note how simple the above SVN instructions are...but if you <em>really</em>
want to do this, read on.</p>

<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=""
class="external-link" rel="nofollow"></a>.</p>

<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 it's time to adjust some configs</li>
	<li>Turn off automatic build (Menu: Project-&gt;Build Automatically)</li>
	<li>Go to menu: Eclipse-&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 laptop)&#33;</p>

<p>Possibly something in sling-builder might get a bit messed up (I didn't experience
that problem, but Pontus reported it) 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-BuildingSling"></a>Building Sling</h2>

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

	<li>Enter the directory, then 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 <tt>/dev/null</tt> 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/builder</tt> directory and launch Sling for
the first time
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
<pre>$ cd launchpad/builder
$ java -jar target/*-standalone.jar -c test -f -

<div class='panelMacro'><table class='noteMacro'><colgroup><col width='24'><col></colgroup><tr><td
valign='top'><img src="/confluence/images/icons/emoticons/warning.gif" width="16" height="16"
align="absmiddle" alt="" border="0"></td><td>When starting Sling inside the
<tt>launchpad/builder</tt> folder you should not use the default Sling Home folder
name <tt>sling</tt> because this folder is removed when running <tt>mvn

<p>Messages should now be printed to the console which is being used as the "log file";
the <tt>&#45;f</tt> command line option is set to <tt>&#45;</tt>,
indicating the use of 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/>
Use the <tt>-h</tt> option to see the list of flags and options.<br/>
After all messages have been printed you should be able to open the Sling Management Console
by pointing your web browser at <tt><a href="http://localhost:8080/system/console"
class="external-link" rel="nofollow">http://localhost:8080/system/console</a></tt>.
You will be prompted for a user name and password. Enter <tt>admin</tt> for both
the user name and the password (this may be set on the <em>Configuration</em>
page later). From this console, you can manage the installed bundles, modify configuration
objects, dump a configuration status and see some system information.<br/>
To stop Sling, just hit <tt>Ctrl-C</tt> in the console or click the <em>Stop</em>
button on the <em>System Information</em> page of the Sling Management Console.</p>

<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 the case that you do not want to use the M2Eclipse plugin there's another setup
that lets you have the automatic build turned on:</p>
	<li>Checkout the whole sling trunk (with subversive or the subclipse plugin) from SVN
to a single project</li>
	<li>Then manually add all <tt>src/main/java</tt> and <tt>src/test/java</tt>
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 will probably get OutOfmemory errors.</p>

<p>Congratulations &#33; You should now have a running Sling instance, that you
can 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 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 as 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=""
class="external-link" 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 from the command line
with "mvn &#45;P autoInstallBundle clean install &#45;Dsling.url=<a href="http://localhost:8080/system/console"
class="external-link" rel="nofollow">http://localhost:8080/system/console</a>"</li>

<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