Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
{warning:title=maven-waf branch}This article depends on the maven-waf branch{warning}

Maven uses the notion of a build life-cycle to which plugins can attach. Plugins are similar to Ant tasks. When a Maven build is invoked, we specify a point in the life-cycle up to which the build should proceed. The compile phase comes before test, and test comes before package, and package comes before install. Once we have Maven setup, we can invoke the Struts build, and specify which phase the build should use.
{toc}

h2. Installing Maven

Get Maven binary: [http://maven.apache.org/download.html]










*For Mac and Linux:*

Extract the latest stable binary release to /usr/local/maven

Add following to your .zshrc/.bashrc/.aliasrc:

{code}
export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:${PATH}
{code}
\*For Windows: *
{code}
Right click on my computer and click on Properties
Click on Advanced system settings
Click on Environment Variables
Click on New... under System variables
Add M2_HOME to Variable name and /usr/local/maven to Variable value
Find Path and click Edit...
Add ;%M2_HOME%/bin at the end
Click OK, OK, and close to get out of all the dialogues
Locate a copy of genosimage.exe.  It comes with cygwin and can be copied from %CYGWIN_HOME%\bin
copy %CYGWIN_HOME%\bin\genosimage.exe %SOURCE_HOME%\mkisofs
{code}

h3. Understanding POMs

POMs are top level build configuration files.

To debug POMs, read through the effective POM:

{code}
$ mvn help:effective-pom
{code}


h2. Dependencies

Running _mvn_ in source root will download and setup dependency jars in \~/.m2/repository.

{code}
$ mvn
$ mvn -P deps # or, explicitly specify the profile
{code}

Some modules require dependencies that are not freely available or have an incompatible license. These dependencies you need to donwload yourself. See to following instructions to add them to your maven repository.

1. Download the following jars and put them in the deps directory:
* cloud-iControl.jar
* cloud-netscaler.jar
* cloud-netscaler-sdx.jar
* cloud-manageontap.jar
* vmware-vim.jar
* vmware-vim25.jar
* vmware-apputils.jar

* [selenium-server-1.0.1.jar|https://maven.atlassian.com/content/groups/public/org/openqa/selenium/server/selenium-server/1.0.1/selenium-server-1.0.1.jar]
* [com.springsource.com.thoughtworks.selenium-1.0.1.jar|https://maven.atlassian.com/content/groups/public/com/thoughtworks/selenium/com.springsource.com.thoughtworks.selenium/1.0.1/com.springsource.com.thoughtworks.selenium-1.0.1.jar]

2. Go into the deps directory and run install-non-oss.sh

{code}
$ cd deps
$ ./install-non-oss.sh
{code}

h2. Building CloudStack

Running the maven command in the top directory of the CloudStack sources will compile all sources for CloudStack and run the unittests. The resulting jar files will be in the directory target in the subdirectory for a particular module. The default build will have all components that depends on non OpenSource libraries disabled. If you want to enable this, just add \-D nonoss to the mvn command line.

{code}
$ mvn [-D nonoss]
{code}

h3. Deploying Database

{code}
$ mvn -P developer -pl developer
{code}

h3. Temporary Build Process on ASF Master

This build process is based on ant, waf and maven. In future, we'll try to have maven do everything for us.


{code}
$ rm -fr ~/.m2 #optional
$ cd incubator-cloudstack
$ mvn -P deps # gets
$ ant clean-all build-all
$ ant deploy-server # ant deploy-server before you deploydb
$ ant deploydb # checkout how to deploy db with mvn above; usual ant stuff :)
{code}

To buid with nonoss plugins we need to apply a patch and copy nonoss libs (cloud-iControl.jar, cloud-netscaler.jar, cloud-netscaler-sdx.jar, cloud-manageontap.jar, vmware-vim.jar,vmware-vim25.jar, vmware-apputils.jar) to /deps:

{code}
$ wget http://bhaisaab.org/patches/cloudstack/0001-BUILD-Make-CloudStack-buildable-with-nonoss-libs.patch
$ git pull <branch; master>
$ git am <patch>
$ mvn -P deps
$ ./waf rpm # or, do ant build-all etc.
{code}

h3. Building RPM packages

Use waf to build packages for linux systems that use rpms, like RedHat, CentOS and fedora.

{info:title=prerelease flag}This flag is required as this makes the RPM use the SNAPSHOT versions.{info}

{code}
$ waf --package-version=4.0.0 --prerelease=rc1 --build-number=1 --oss rpm
{code}


{code}
$ mvn install -P deps && ./waf rpm
{code}

h3. Building DEB packages

On Master:

{code}
$ mvn install -P deps && dpkg-buildpackage
{code}

Package using deb profile (feature under development uses jdeb plugin, in [https://github.com/bhaisaab/incubator-cloudstack/tree/debs-maven] debs-maven branch):

{code}
$ mvn package -P deb
{code}

h2. Development

h3. Starting the debug server from maven

This replaces the old ant debug, but you still have to deploy the database using 'ant deploydb' for now.

{warning:title=Under development}This feature is still being developed and tested, might not work as expected{warning}

{code}
$ mvn -P client -pl client jetty:run
{code}

h3. Good Ol' Terminal

Zsh/Bash/Emacs/Vim/Grep/Sed/Awk/Javac...


{code}
$ sh deps/install-non-oss.sh

$ mvn -Dnonoss install

$ ant debug # Good ol' way of doing things
{code}

h3. IntelliJ IDEA

FIXME: Add on how to use IntelliJ IDEA with CS, building, debugging, editing, git checkouts


h3. Eclipse

FIXME: Add on how to use Eclipse with CS, building, debugging, editing, git checkouts

h2. Other Uses


h3. RAT: ASF License Checking

{code}
$ mvn --projects='org.apache.cloudstack:cloudstack' org.apache.rat:apache-rat-plugin:0.8:check
{code}

The output file is in ${project.build.directory}/rat.txt, by default in target/rat.txt


h3. Site Generation and Reporting

{code}
$ mvn site
{code}


h2. Troubleshooting

* Offline Mode:

{code}
$ mvn -o -Pextras,plugins,xwork
{code}

* Out of memory error, out of heap space:

{code}
// Bash
export MAVEN_OPTS=-Xmx512m
// Windows
set MAVEN_OPTS=-Xmx512m
{code}