Here's our collection of tips and tricks for building Sling with Maven.
The first time you run a Maven build, or when Maven needs additional build components, it downloads plugins and dependencies under its local repository folder on your computer. By default, this folder is named .m2/repository in your home directory.
Maven uses this repository as a cache for artifacts that it might need for future builds, which means that the first Sling build usually takes much longer than usual, as Maven needs to download many tools and dependencies into its local repository while the build progresses.
The build might fail if one of those downloads fails, in that case it might be worth retrying the build, to check if that was just a temporary connection problem, or if there's a more serious error.
In some cases, the local Maven repository might get corrupted - if your build fails on a computer and works on another one, clearing the local repository before restarting the build might be worth trying.
To make sure you're getting the same results as we are when building Sling, it is recommend to ignore any local settings.
On unixish platforms, using
does the trick.
|Does anyone have a similar command-line option that works under Windows?|
The MAVEN_OPTS environment variable defines options for the JVM that executes Maven.
Set it according to your platform, i.e. export MAVEN_OPTS=... on unixish systems or set MAVEN_OPTS=... on Windows.
If getting an OutOfMemoryException when running mvn, try setting
to allocate 256MB of RAM to Maven.
To run the Sling launchpad webapp in debug mode from Maven, for example, use something like
And then connect to port 30303 with a remote JVM debugger (most IDEs do this).
Some Maven plugins do not like spaces in paths. It is better to avoid putting your Maven repository, or your code, under paths like Documents and Settings, for example.