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, 31 Jul 2009 14:30:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=SLINGxSITE&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/SLINGxSITE/Getting+and+Building+Sling">Getting
and Building Sling</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~mykee">Mike
Mueller</a>
    </h4>
     
          <br/>
     <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>
<ul>
	<li>Java 5 or higher, Java 6 recommended</li>
	<li>Maven 2.0.7 (or later), Maven 2.1.0 recommended</li>
</ul>


<p>To set up Eclipse you'll also need:</p>
<ul>
	<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="http://m2eclipse.codehaus.org/Installing_Maven_2.0_plugin_for_Eclipse.html"
rel="nofollow">instructions</a></li>
	<li>Installed <a href="http://www.polarion.com/products/svn/subversive.php" rel="nofollow">Subversive
plugin</a> or <a href="http://subclipse.tigris.org" 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 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>

<ul>
	<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
<tt>jcr/jackrabbit-server</tt>.</li>
	<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
variable:</li>
</ul>


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

<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 message</li>
</ul>


<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>
<ul>
	<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>
</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>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/"
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 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>
</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 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>
<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-BuildSling"></a>Build Sling</h2>


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

<ol>
	<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
panelContent">
<pre>$ cd sling
$ export MAVEN_OPTS="-Xmx256m -XX:MaxPermSize=128m"
$ mvn -s /dev/null clean install
</pre>
</div></div></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
panelContent">
<pre>$ cd launchpad/app
$ java -jar target/org.apache.sling.launchpad.app-2.x.x-SNAPSHOT.jar -c sling -f -
</pre>
</div></div>
<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>
</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 case you do not want to use the M2Eclipse plugin there's another setup which lets
you have turned on the automatic build:</p>
<ol>
	<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>
</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 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>
<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 on 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-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 on the command line
with "mvn &#45;P autoInstallBundle clean install &#45;Dsling.url=<a href="http://localhost:8080/system/console"
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="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/SLINGxSITE/Getting+and+Building+Sling">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=76181&revisedVersion=23&originalVersion=22">View
Change</a>
              |
       <a href="http://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