Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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.

Table of Contents

TODOs

  1.  Deploydb:
    - see if we can use http://code.google.com/p/flyway/ etc. for database upgrading/migration during development (suggested by John Burwell <jburwell@basho.com>)
  2. Compile:
    - fix tomcat webapp compilation issue
  3. Unittests:
    - fix unittests so they are more useful during compilation
  4. Deploy and Debug:
    - configure tomcat plugin to do tomcat:deploy and tomcat:run, debug
  5. Site/doc generation with maven

Installing Maven

We need maven 3, you can either install it from distribution, or install it from maven binary. Following is the steps to install it from maven binary:

...

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

XML indentation

   Two spaces for XML files, which can be enforced  by editors.

...

Code Block
# sudo apt-get install libxml2-utils
# .vimrc
au FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null
# gg=G

Understanding POMs

POMs are the maven project configuration files. Here you can configure everything from mailinglists that belong to the project, compilation of the various pieces of the project all the way to the final deployment of release binaries.

...

As with anything, feel free to browse the documentation on maven: This guide is very helpfull.

What is -SNAPSHOT and why should i care

-SNAPSHOT is a special marker in maven that tell everybody that this particular piece of code is under development and might change at any time. Opposed to a normal versioned release like '4.0.0', a snapshot is never a stable release. Maven will often try to get a more recent version of a SNAPSHOT during compile. A stable release is fixed, once published there is no changing it anymore. Snapshots are normally used to indicate that a build is made of the HEAD or trunk of a project. Later on this page more about releases using maven.

Dependencies

Some modules, e.g. vmware/netscaler/netapp,  require dependencies that are not freely available or have an incompatible license. These dependencies you need to download yourself. See to following instructions to add them to your maven repository. 

...

Code Block
$ cd deps
$ mv cloud-manageontap.jar manageontap.jar
$ mv vmware-apputils.jar apputils.jar
$ mv vmware-vim.jar vim.jar
$ mv vmware-vim25.jar vim25_51.jar
$ unzip cloud-netscaler-jars.zip
$ ./install-non-oss.sh

Building CloudStack

Running the maven command in the top directory of the CloudStack sources will compile all sources for CloudStack. 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 (non-oss) libraries disabled. If you want to enable this, just add -D nonoss to the mvn command line or see the table below for more fine-grained options. The install goal will compile all sources, make war and jar files and add them to your local repository.

...

Code Block
$ mvn clean
$ mvn install -Dnonoss

Deploying Database

Note: The following is a WIP feature, use the old Ant command for a complete refresh. This command assumes you have a proper setup in utils/conf/db.properties and the cloud user already exists on your mysql database. If you have a root password, copy db.properties to db.properties.override and put your password there.

...

To customize hosts, password etc. just copy utils/conf/db.properties to utils/conf/db.properties.override (this is git ignored by default) and edit the properties as needed they will override the defaults in utils/conf/db.properties.

Running a server for test/debug purposes.

On can use maven to deploy and debug the management server. First export the MAVEN_OPTS variable to open a transport socket on port 8787 (same as before).

...

Warning
titleUnder development

This feature is still being developed and tested, might not work as expected

Integrated Simulator+Marvin test

The agent simulator and marvin are integrated into build steps to help a developer ensure that some simple tests pass before making a commit. The developer environment needs to have Marvin installed for the integration-test to work: These tests are lightweight and should ensure that your checkin doesn't break critical functionality for others working with branch: master.

To run the basic tests please refer to the Marvin wiki section on checkin tests.

Building Specific Versions of CloudStack

Warning
titleNOTE

Follow the following wiki page for building specific versions of CloudStack from source code.
Versions covered: 4.0 and above

Checkout Building where we document building process for specific version of CloudStack such as 4.0 oss/nonoss etc.

Packaging

Building RPM packages

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

Code Block
$ cd packaging/centos63
$ ./package.sh

Building DEB packages

On Master:

Code Block
$ mvn install -P deps && dpkg-buildpackage

...

Code Block
$ mvn package -P deb

Development with a IDE

Good Ol' Terminal

Following Building CloudStack section above.

IntelliJ IDEA

Import the project as Maven project. Build with maven, set socket type debugger on port 8787, follow Building CloudStack section above.

Eclipse

See Using Eclipse With CloudStack

Other Uses

RAT: ASF License Checking

Code Block
$ mvn --projects='org.apache.cloudstack:cloudstack' org.apache.rat:apache-rat-plugin:0.8:check

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

Site Generation and Reporting

Code Block
$ mvn site

Versioning / Releases

Update the version number of the project

...

Releases can also be done using the release plugin. This plugin will automagically take care of setting the currect version (removing the -SNAPSHOT), making a tag in SCM and deploying the jars to the maven repository. This should only be executed by the release engineer. Maven assumes that once a version is released it will never change anymore and released binaries will never be updated, so any subsequent releases will have to bump the version number.

Skip unit test

Code Block
mvn install -DskipTests=true

Troubleshooting

  • Offline Mode:

Set commandline parameter -o to force maven to only use the local repository. This might trigger build failures if artifacts are not available locally, but might speed up the build process in some cases.

...