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.
This is written for master branch, version 4.1.0
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:
export M2_HOME=/usr/local/maven export PATH=${M2_HOME}/bin:${PATH}
*For Windows: *
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
Two spaces for XML files, which can be enforced by editors.
In Eclipse,
Window -> Preferences -> XML -> Editor -> select "Indent using spaces", also set "Indentation size 2 spaces"
In VIM:
# sudo apt-get install libxml2-utils # .vimrc au FileType xml setlocal equalprg=xmllint\ --format\ --recover\ -\ 2>/dev/null # gg=G
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.
To debug POMs, read through the effective POM:
$ mvn help:effective-pom
To see how the dependencies are related to the modules:
$ mvn dependency:tree
As with anything, free free to browse the documentation on maven: This http://maven.apache.org/guides/getting-started/index.html is very helpfull.
-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.
Running mvn in source root will download and setup dependency jars the deps directory for use with the old ant system.
$ mvn -P deps install
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:
2. Go into the deps directory and run install-non-oss.sh
$ cd deps $ ./install-non-oss.sh
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 jars files and add he to your local repository.
$ mvn clean $ mvn install
Available profiles |
Enabled by property |
Requires profiles |
Description |
---|---|---|---|
deps |
|
|
Enables a convenience download for all dependencies into the deps directory, usage mvn -P deps -pl deps install |
developer |
|
|
Enables a convenience pom with developer functions |
vmware |
nonoss |
|
Enables the build of vmware-base and the vmware plugin, requires vmware SDK to be present. |
netapp |
nonoss |
|
Enables the build of the netapp plugin, requires NetApp manageontap sdk. |
f5 |
nonoss |
|
Enables the build of the f5 plugin, requires f5 iControl library |
netscaler |
nonoss |
|
Enables the build of the netscaler plugin, requires additional libraries. |
srx |
nonoss |
|
Enables the build of the juniper srx plugin, requires additional libraries. |
Available properties |
|
Required profile |
Description |
deploydb |
|
developer |
Clears and creates the cloud database in the mysql server configured utils/conf/db.properties |
nonoss |
|
|
Enables all modules that are not part of the standard ASF build |
systemvm |
|
|
Enabled the build of the systemvm.iso, requires mkisofs to be available on the commandline |
For nonoss, just do a mvn -Dnonoss <goal>.
Example, if you want to build CloudStack with all ASF components and the vmware plugin, use the following command
mvn -P vmware install
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.
$ mvn -P developer -pl developer -Ddeploydb
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).
$ export MAVEN_OPTS="-Xmx1024m -Xdebug -Xrunjdwp:transport=dt_socket,address=8787,server=y,suspend=y"
If you don't export using above configuration, the management server will run with no debugger attached.
This will run a jetty server on localhost port 8080 with the management server.
$ mvn -pl :cloud-client-ui jetty:run
Note: The following is a WIP tomcat-plugin feature, use the above jetty command for now.
$ mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-beta-1:run -pl :cloud-client-ui -am -Pclient
Open the following URL on your browser to access the Management Server UI:
http://localhost:8080/client/
Or,
http://management-server-ip-address:8080/client
The default credentials are; user: admin, password: password and the domain
field should be left blank which is defaulted to the ROOT domain.
Under development
This feature is still being developed and tested, might not work as expected
NOTE
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.
Use waf to build packages for linux systems that use rpms, like RedHat, CentOS and fedora.
prerelease flag
This flag is required as this makes the RPM use the SNAPSHOT versions.
$ waf --package-version=4.0.0 --prerelease=rc1 --build-number=1 --oss rpm
$ mvn install -P deps && ./waf rpm
On Master:
$ mvn install -P deps && dpkg-buildpackage
WIP: Package using deb profile (feature under development uses jdeb plugin, in https://github.com/bhaisaab/incubator-cloudstack/tree/debs-maven debs-maven branch):
$ mvn package -P deb
Following Building CloudStack section above.
Import the project as Maven project. Build with maven, set socket type debugger on port 8787, follow Building CloudStack section above.
See Using Eclipse With CloudStack
$ 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
$ mvn site
Update the version number of the project
mvn release:update-versions -DautoVersionSubmodules=true -Dnonoss -Pdeps,developer -DdevelopmentVersion=<version>-SNAPSHOT
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.
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.
$ mvn -o
// Bash export MAVEN_OPTS=-Xmx512m // Windows set MAVEN_OPTS=-Xmx512m