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 09:07: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 (30)</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" >h2. Prerequisites <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >Before you begin, you <span
class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">should</span>
<span class="diff-added-words"style="background-color: #dfd;">need to</span> have
the following tools installed on your system: <br></td></tr>
            <tr><td class="diff-unchanged" >* Java 5 or higher; Java 6 recommended
<br>* [Maven|http://maven.apache.org] 2.2.1 or later; enforced by the Sling parent pom
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h2. Environment Setup <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >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 <span class="diff-changed-words">Sling<span class="diff-added-chars"style="background-color:
#dfd;">.</span></span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. Java Heap Space <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* *Platforms* \- Windows XP, Mac OSX,
OpenSolaris <br>* *Fix* \- Increase the values of the maximum heap and perm space for
the build by setting or extending the {{MAVEN_OPTS}} environment variable: <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br>MAVEN_OPTS=&quot;-Xmx256M
-XX:MaxPermSize=128m&quot; <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" > <br>* *Problem* \- Build aborts
when trying to launch the integration tests with the message <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br>[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 <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >error=12, Not enough space <br>{noformat}
<br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">This
problem is caused by insufficient swap space. When running the integration tests in the {{launchpad/testing}}
modules, a process is launched by calling the {{exec}} 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. <br></td></tr>
            <tr><td class="diff-unchanged" >* *Platform* \- OpenSolaris <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">*
*Fix* \- This problem is caused by missing swap space. When running the integration tests
in the {{launchpad/testing}} modules, a process is launched by calling the {{exec}} 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. <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">*
*Fix* \- If this issue persists you will need to check your system requirements and configuration
with regard to swap, before taking action - if necessary. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h2. Configuring Maven <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >If you use the Subversive plugin make
sure you have installed the &quot;Subversive Integration for M2Eclipse Project&quot;
which can be found under the following Eclipse update site: [http://community.polarion.com/projects/subversive/download/integrations/update-site/].
<br> <br></td></tr>
            <tr><td class="diff-changed-lines" >Also, make sure that you have
installed either the &quot;Maven SCM handler for Subclipse&quot; or the &quot;Maven
SCM handler for <span class="diff-changed-words">Subversive&quot;<span class="diff-added-chars"style="background-color:
#dfd;">.</span></span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h4. Create a new workspace
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" ># Menu: File-&gt;Switch Workspace-&gt;Other...
<br># Enter a path for the new workspace and click OK <br></td></tr>
            <tr><td class="diff-changed-lines" ># When Eclipse has restarted <span
class="diff-changed-words">it<span class="diff-added-chars"style="background-color:
#dfd;">&#39;</span>s</span> time to adjust some configs <br></td></tr>
            <tr><td class="diff-unchanged" ># Turn off automatic build (Menu:
Project-&gt;Build Automatically) <br></td></tr>
            <tr><td class="diff-changed-lines" ># Go to menu: <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">Window-&gt;Preferences,</span>
<span class="diff-added-words"style="background-color: #dfd;">Eclipse-&gt;Preferences,</span>
in the preferences dialog select Java \-&gt; Compiler \-&gt; Errors/Warnings <br></td></tr>
            <tr><td class="diff-unchanged" ># Expand the &quot;Deprecated
and restricted API&quot; and change &quot;Forbidden references (access rules)&quot;
from &quot;Error&quot; to &quot;Warning&quot; <br># Click OK <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" ># Click Finish <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >Eclipse will now start to download
the source and import the Maven projects. You might encounter some &quot;Problem Occured&quot;
dialogs about &quot;An internal <span class="diff-changed-words">error...&quot;<span
class="diff-added-chars"style="background-color: #dfd;">,</span></span> 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 <span class="diff-changed-words">lap<span class="diff-added-chars"style="background-color:
#dfd;">top</span>)\!</span> <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">Maybe
something in sling-builder gets a bit messed up (I didn&#39;t ran into that problem, but
Pontus reported that) then you can simply fix it with revert: <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">Possibly
something in sling-builder might get a bit messed up (I didn&#39;t experience that problem,
but Pontus reported it) then you can simply fix it with revert: <br></td></tr>
            <tr><td class="diff-changed-lines" ># In the Project Explorer <span
class="diff-changed-words">right<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">
</span><span class="diff-added-chars"style="background-color: #dfd;">-</span>click</span>
on the &quot;sling-builder&quot; project and select the Team-&gt;Revert... menu
<br></td></tr>
            <tr><td class="diff-unchanged" ># A couple of changes will be displayed
<br># Click OK <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h3. With the Maven command line tool
<br> <br></td></tr>
            <tr><td class="diff-changed-lines" ># Enter the <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">directory
and</span> <span class="diff-added-words"style="background-color: #dfd;">directory,
then</span> do a full build and local install (below are unix/linux commands, slightly
different under windows) <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br>$ cd sling <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >$ mvn -s /dev/null clean install <br>{noformat}
<br></td></tr>
            <tr><td class="diff-changed-lines" >Note: On windows just leave out
<span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">the
/dev/null</span> <span class="diff-added-words"style="background-color: #dfd;">{{/dev/null}}</span>
and make sure you have an empty settings.xml file for maven (located in your user directory
under .m2). <br></td></tr>
            <tr><td class="diff-unchanged" ># Enter the {{launchpad/builder}}
directory and launch Sling for the first time <br>{noformat} <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >$ java -jar target/org.apache.sling.launchpad-*-standalone.jar
-c sling -f - <br>{noformat} <br></td></tr>
            <tr><td class="diff-changed-lines" >Messages should now be printed
to the console which is <span class="diff-added-words"style="background-color: #dfd;">being</span>
used as the &quot;log <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">file&quot;
because</span> <span class="diff-added-words"style="background-color: #dfd;">file&quot;;</span>
the {{\-f}} command line option is set to <span class="diff-changed-words">{{\-}}<span
class="diff-added-chars"style="background-color: #dfd;">,</span></span> indicating
<span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">to</span>
<span class="diff-added-words"style="background-color: #dfd;">the</span> use <span
class="diff-added-words"style="background-color: #dfd;">of</span> standard output
as the log file. The {{\-c sling}} command line option instructs Sling to use the {{sling}}
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 [Configuration] for more information). <br></td></tr>
            <tr><td class="diff-unchanged" >Use the {{-h}} option to see the list
of flags and options. <br></td></tr>
            <tr><td class="diff-changed-lines" >After all messages have been printed
you should <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">now</span>
be able to open the Sling Management Console by pointing your web browser at {{[http://localhost:8080/system/console]}}.
You will be prompted for a user name and password. Enter {{admin}} <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">as</span>
<span class="diff-added-words"style="background-color: #dfd;">for</span> both
the user name and the password (this may be set on <span class="diff-added-words"style="background-color:
#dfd;">the</span> _Configuration_ page later). From this console, you <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">may</span>
<span class="diff-added-words"style="background-color: #dfd;">can</span> manage
the installed bundles, modify configuration objects, dump a configuration status and <span
class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">get</span>
<span class="diff-added-words"style="background-color: #dfd;">see</span> some
system information. <br></td></tr>
            <tr><td class="diff-changed-lines" >To stop Sling, just hit {{Ctrl-C}}
<span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">at</span>
<span class="diff-added-words"style="background-color: #dfd;">in</span> the console
or click the _Stop_ button on the _System Information_ page of the Sling Management Console.
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>h3. With M2Eclipse <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" ># Make sure you&#39;re in the
Java perspective (Menu: Window-&gt;Open Perspective) <br># Menu: Run-&gt;Run
Configurations... <br></td></tr>
            <tr><td class="diff-changed-lines" ># In the Run Configurationa dialog
<span class="diff-changed-words">right<span class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">
</span><span class="diff-added-chars"style="background-color: #dfd;">-</span>click</span>
on &quot;Maven Build&quot; and select &quot;New&quot; <br></td></tr>
            <tr><td class="diff-unchanged" ># Change Name to &quot;Build Sling&quot;
<br># Click &quot;Browse Workspace...&quot; and select &quot;sling-builder&quot;
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h3. Alternative setup in Eclipse without
M2Eclipse plugin <br> <br></td></tr>
            <tr><td class="diff-deleted-lines" style="color:#999;background-color:#fdd;text-decoration:line-through;">In
case you do not want to use the M2Eclipse plugin there&#39;s another setup which lets
you have turned on the automatic build: <br># Checkout the whole sling trunk with subversive
or subclipse plugin from the SVN to a single project <br></td></tr>
            <tr><td class="diff-added-lines" style="background-color: #dfd;">In
the case that you do not want to use the M2Eclipse plugin there&#39;s another setup that
lets you have the automatic build turned on: <br># Checkout the whole sling trunk (with
subversive or the subclipse plugin) from SVN to a single project <br></td></tr>
            <tr><td class="diff-changed-lines" ># Then manually add all <span
class="diff-changed-words"><span class="diff-added-chars"style="background-color: #dfd;">{{</span>src/main/java<span
class="diff-added-chars"style="background-color: #dfd;">}}</span></span> and
<span class="diff-changed-words"><span class="diff-added-chars"style="background-color:
#dfd;">{{</span>src/test/java<span class="diff-added-chars"style="background-color:
#dfd;">}}</span></span> of the bundles to the project as source folders <br></td></tr>
            <tr><td class="diff-unchanged" ># Add all required libraries to the
build path <br># Now you can build either in Eclipse or even better use &quot;mvn
clean install&quot; on the command line <br> <br></td></tr>
            <tr><td class="diff-changed-lines" >If you use &quot;mvn clean
install&quot; to build Sling be sure you have set MAVEN_OPTS to &quot;-Xmx384m \-XX:PermSize=256m&quot;
otherwise you <span class="diff-added-words"style="background-color: #dfd;">will</span>
probably get OutOfmemory errors. <br></td></tr>
            <tr><td class="diff-unchanged" > <br></td></tr>
            <tr><td class="diff-changed-lines" >Congratulations \! You should
now have a running Sling instance, <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">which</span>
<span class="diff-added-words"style="background-color: #dfd;">that</span> you
<span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">may</span>
<span class="diff-added-words"style="background-color: #dfd;">can</span> start
playing around with. <br></td></tr>
            <tr><td class="diff-unchanged" > <br>h2. Further Tips and Tricks
<br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br># Open Menu Run-&gt;
Debug configurations <br></td></tr>
            <tr><td class="diff-changed-lines" ># <span class="diff-changed-words">Right<span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">
</span><span class="diff-added-chars"style="background-color: #dfd;">-</span>click</span>
on &quot;Remote Java Applications&quot; <br></td></tr>
            <tr><td class="diff-unchanged" ># Choose &quot;New&quot; <br></td></tr>
            <tr><td class="diff-changed-lines" ># <span class="diff-changed-words"><span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">i</span><span
class="diff-added-chars"style="background-color: #dfd;">I</span>n</span> the
&quot;Connect&quot; tab choose the Eclipse Sling Project for the field &quot;Project&quot;
with the browse button <br></td></tr>
            <tr><td class="diff-unchanged" ># Let the Connection type be &quot;Standard
(Socket Attach)&quot; <br></td></tr>
            <tr><td class="diff-changed-lines" ># <span class="diff-changed-words"><span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">t</span><span
class="diff-added-chars"style="background-color: #dfd;">T</span>he</span> host
should be localhost <br></td></tr>
            <tr><td class="diff-changed-lines" ># <span class="diff-changed-words"><span
class="diff-deleted-chars"style="color:#999;background-color:#fdd;text-decoration:line-through;">s</span><span
class="diff-added-chars"style="background-color: #dfd;">S</span>et</span> the
Port to 30303 <br></td></tr>
            <tr><td class="diff-changed-lines" ># On the source tab click <span
class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">on</span>
the &quot;Add&quot; button <br></td></tr>
            <tr><td class="diff-unchanged" ># Select &quot;Java Project&quot;
<br># Select all Sling projects and click OK <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >h3. Debug Maven Tests in Eclipse <br>
<br></td></tr>
            <tr><td class="diff-changed-lines" >In the same way <span class="diff-added-words"style="background-color:
#dfd;">as</span> you can debug the sling <span class="diff-changed-words">app<span
class="diff-added-chars"style="background-color: #dfd;">,</span></span> you
are also able to debug a maven test. Just run the maven tests like this <br></td></tr>
            <tr><td class="diff-unchanged" >{noformat} <br>mvn -Dmaven.surefire.debug
test <br></td></tr>
            <tr><td class="diff-snipped" >...<br></td></tr>
            <tr><td class="diff-unchanged" >* Now you can create, edit and compile
the files in Eclipse <br>* To create the bundle jar and install it, just use the command
line &quot;mvn clean install&quot; in the project directory <br></td></tr>
            <tr><td class="diff-changed-lines" >* If you have a running Sling
app you can install the bundle <span class="diff-deleted-words"style="color:#999;background-color:#fdd;text-decoration:line-through;">on</span>
<span class="diff-added-words"style="background-color: #dfd;">from</span> the
command line with &quot;mvn \-P autoInstallBundle clean install \-Dsling.url=[http://localhost:8080/system/console]&quot;
<br></td></tr>
            <tr><td class="diff-unchanged" > <br>If adding dependencies
to the poms, run mvn eclipse:eclipse again and refresh the project in Eclipse. Debugging works
as described above. <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.<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 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=30&originalVersion=29">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