incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Sling Website > Getting and Building Sling
Date Fri, 13 Aug 2010 10:27:00 GMT
<html>
<head>
    <base href="https://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1810/9/1/_/styles/combined.css?spaceKey=SLINGxSITE&amp;forWysiwyg=true"
type="text/css">
    </head>
<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="https://cwiki.apache.org/confluence/display/SLINGxSITE/Getting+and+Building+Sling">Getting
and Building Sling</a></h2>
    <h4>Page <b>edited</b> by             <a href="https://cwiki.apache.org/confluence/display/~aheimoz">Alison
Heimoz</a>
    </h4>
        <br/>
                         <h4>Changes (1)</h4>
                                 
    
<div id="page-diffs">
            <table class="diff" cellpadding="0" cellspacing="0">
            <tr><td class="diff-unchanged" >h1. Getting and Building Sling <br>{excerpt}A
quick guide for getting the Sling source, then building and running the resulting Sling instance;
both without and with Eclipse.{excerpt} <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">
<br>Sling can easily be built: <br>* from the command line (using SVN and the
Maven command line tool) <br>* or using Eclipse <br> <br></td></tr>
            <tr><td class="diff-unchanged" >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 [Downloads] page. <br> <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
        </table>
</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; both without and with Eclipse.</p>

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


<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="/confluence/display/SLINGxSITE/Downloads"
title="Downloads">Downloads</a> page.</p>

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

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


<p>If you want to set up Eclipse (not required to build Sling) you'll also need the
following installed:</p>
<ul>
	<li>Eclipse (tested with 3.4.2 and 3.5.x on Win XP, SP3); 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="http://m2eclipse.sonatype.org/installing-m2eclipse.html"
class="external-link" rel="nofollow">instructions</a></li>
	<li><a href="http://www.polarion.com/products/svn/subversive.php" class="external-link"
rel="nofollow">Subversive plugin</a> or <a href="http://subclipse.tigris.org"
class="external-link" rel="nofollow">Subclipse-plugin</a> for Eclipse</li>
</ul>


<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>

<ul>
	<li><b>Problem</b> &#45; Build aborts with reports of <tt>java.lang.OutOfMemoryError:
Java heap space</tt>. This mostly happens while building the Jackrabbit Server module
<tt>jcr/jackrabbit-server</tt>.</li>
	<li><b>Platforms</b> &#45; Windows XP, Mac OSX, OpenSolaris</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
variable:
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>MAVEN_OPTS="-Xmx256M -XX:MaxPermSize=128m"
</pre>
</div></div></li>
</ul>


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

<ul>
	<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
panelContent">
<pre>[INFO] Error while executing forked tests.; nested exception is org.apache.maven.surefire.booter.shade.org.codehaus.plexus.util.cli.CommandLineException:
Error setting up environmental variables

error=12, Not enough space
</pre>
</div></div>
<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
necessary.</li>
</ul>


<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>

<ol>
	<li>Checkout Sling from the Repository.
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>$ svn checkout http://svn.apache.org/repos/asf/sling/trunk sling
</pre>
</div></div></li>
</ol>


<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="http://community.polarion.com/projects/subversive/download/integrations/update-site/"
class="external-link" rel="nofollow">http://community.polarion.com/projects/subversive/download/integrations/update-site/</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
workspace</h4>

<p>It's best to create a new workspace for the sling project:</p>
<ol>
	<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>
</ol>


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

<ol>
	<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 "http://svn.apache.org/repos/asf/sling/trunk"</li>
	<li>Click Finish</li>
</ol>


<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>
<ol>
	<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>
</ol>


<h2><a name="GettingandBuildingSling-BuildingSling"></a>Building Sling</h2>


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

<ol>
	<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
panelContent">
<pre>$ cd sling
$ export MAVEN_OPTS="-Xmx256m -XX:MaxPermSize=128m"
$ mvn -s /dev/null clean install
</pre>
</div></div>
<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
panelContent">
<pre>$ cd launchpad/builder
$ java -jar target/org.apache.sling.launchpad-*-standalone.jar -c sling -f -
</pre>
</div></div>
<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></li>
</ol>


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

<ol>
	<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>
</ol>


<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>
<ol>
	<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>
</ol>


<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>
<ol>
	<li>start Sling from the command line with
<div class="preformatted panel" style="border-width: 1px;"><div class="preformattedContent
panelContent">
<pre>java -Xmx384M -agentlib:jdwp=transport=dt_socket,address=30303,server=y,suspend=n
-jar org.apache.sling.launchpad.app-6-SNAPSHOT.jar
</pre>
</div></div></li>
	<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>
</ol>


<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
panelContent">
<pre>mvn -Dmaven.surefire.debug test
</pre>
</div></div>

<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="http://maven.apache.org/plugins/maven-surefire-plugin/examples/debugging.html"
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>
<ul>
	<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>
</ul>


<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>
        <div id="commentsSection" class="wiki-content pageSection">
        <div style="float: right;">
            <a href="https://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
        </div>
        <a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Getting+and+Building+Sling">View
Online</a>
        |
        <a href="https://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=76181&revisedVersion=31&originalVersion=30">View
Changes</a>
                |
        <a href="https://cwiki.apache.org/confluence/display/SLINGxSITE/Getting+and+Building+Sling?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message