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:
    - fix root/cloud

...

  1. permission

...

  1. issue

...


  1. -

...

  1. create

...

  1. cloud

...

  1. user

...

  1. is

...

  1. it

...

  1. does

...

  1. not

...

  1. exist

...


  1. -

...

  1. remove

...

  1. developer/pom.xml

...

  1. to

...

  1. a

...

  1. profile

...

  1. in

...

  1. root

...

  1. pom.xml

...


  1. -

...

  1. create

...

  1. schema/tables

...

  1. for

...

  1. cloud_usage

...

  1. and

...

  1. cloudbridge

...

  1. databases

...

  1. Compile:

...


  1. -

...

  1. fix

...

  1. tomcat

...

  1. webapp

...

  1. compilation

...

  1. issue

...


  1. -

...

  1. fix

...

  1. compilation

...

  1. of

...

  1. some

...

  1. projects

...

  1. still

...

  1. under

...

  1. WIP

...

  1. Deploy

...

  1. and

...

  1. Debug:

...


  1. -

...

  1. configure

...

  1. tomcat

...

  1. plugin

...

  1. to

...

  1. do

...

  1. tomcat:deploy

...

  1. and

...

  1. tomcat:run,

...

  1. debug

...

  1. Packaging:

...


  1. -

...

  1. deb

...

  1. packaging

...


  1. -

...

  1. rpm

...

  1. packaging

...

  1. Site/doc

...

  1. generation

...

  1. with

...

  1. maven

...

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 Block
}
export M2_HOME=/usr/local/maven
export PATH=${M2_HOME}/bin:${PATH}
{code}
\

*For

...

Windows:

...

*

{
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

Understanding POMs

POMs are top level build configuration files.

To debug POMs, read through the effective POM:

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

Dependencies for ant

Running mvn in source root will download and setup dependency jars the deps directory for use with the old ant system.

Code Block

$ 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:

  • cloud-iControl.jar
  • cloud-netscaler.jar
  • cloud-netscaler-sdx.jar

...

  • cloud-manageontap.jar

...

  • vmware-vim.jar

...

  • vmware-vim25.jar

...

  • vmware-apputils.jar

...

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

{
Code Block
}
$ 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 

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 jars files and add he to your local repository.

Code Block

$ mvn clean line.

{code}
$ mvn -P deps                  # for non-oss, add: -D nonoss
$ mvn clean                    # to clean old build targets
$ ant clean-all clean-tomcat   # cleans ant dists and targets
$ ant build-all
{code}

h3. Deploying Server

{code}
$ ant deploy-server
{code}

Note: The following is a WIP tomcat-plugin feature, use the above Ant command for now.

{code}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

Example, if you want to build CloudStack with all ASF components and the vmware plugin, use the following command

Code Block

mvn -P vmware install

Deploying Database

Note: The following is a WIP feature, use the above Ant command for now.

Code Block

$ mvn -P developer -pl developer -Ddeploydb

Running a server for test/debug purposes.

This will run a jetty server on localhost port 8080 with the management server.

Code Block

$ mvn  -pl :cloud-client-ui -am jetty:run

Note: The following is a WIP tomcat-plugin feature, use the above jetty command for now.

Code Block
$ mvn org.apache.tomcat.maven:tomcat7-maven-plugin:2.0-beta-1:run -pl :cloud-client-ui -am -Pclient
{code}

h3. Deploying Database

{code}
$ ant deploydb
{code}

Note: The following is a WIP feature, use the above Ant command for now.

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

h3. Starting the Server

{code}
$ ant debug
{code}

Open the following URL on your browser to access the Management Server UI:
    [

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.

{:=
Warning
title
Under
development
}

This

feature

is

still

being

developed

and

tested,

might

not

work

as expected

Temporary Build Process on ASF Master

Warning
titletemporary

The project is migrating from ant/waf to maven next to some changes on how to do distributions and binary releases. Below are the instructions used until the 4.1.0 version was set on master. Most of these instructions are still valid for 4.1.0, but check back regularly as maven might introduce some changes to the build process

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

Code Block
 expected
{warning}

{code}
$ mvn -P client -pl client jetty:run
{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 Block
}
$ 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}

For

...

nonoss

...

builds

...

only:

...

After

...

installing

...

these

...

packages,

...

user

...

is

...

required

...

copy

...

nonoss

...

libs

...

in

...

/usr/share/java

...

(or

...

some

...

place)

...

and

...

update

...

classpath

...

to

...

each

...

jar

...

in

...

/etc/cloud/management/classpath.conf

Building RPM packages

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

Info
titleprerelease flag

This flag is required as this makes the RPM use the SNAPSHOT versions.

Code Block



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 Block

}


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

h3.

Building DEB packages

On Master:

Code Block
 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 Block
}
$ mvn package -P deb
{code}

h2. Development with a IDE


h3. Good Ol' Terminal

Development with a IDE

Good Ol' Terminal

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

Code Block



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

$ mvn -Dnonoss install

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

h3. IntelliJ IDEA

IntelliJ IDEA

FIXME:

...

Add

...

on

...

how

...

to

...

use

...

IntelliJ

...

IDEA

...

with

...

CS,

...

building,

...

debugging,

...

editing,

...

git checkouts

Eclipse

The move to maven also means that a better integration with Eclipse is possible. To setup maven make sure that the latest version of the m2e plugin is correcly installed.

You can checkout the project yourself and import it as a maven project using the Eclipse UI, or directly checkout the maven project using the checkout from SCM option in the maven section of the import dialog.

For easy building and launching you can setup several run configurations. I'm using the following configurations:

  • CloudStack rebuild (full rebuild of cloudstack code)
    Base directory: ${project_loc:cloudstack}
    Goals: clean install
    Profiles: <empty>
  • CloudStack launch (launch the jetty based management server)
    Base directory: ${project_loc:cloudstack}
    Goals: -pl client jetty:run
    Profiles: <empty>
  • CloudStack rebuild (full rebuild of cloudstack code)
    Base directory: ${project_loc:cloudstack}
    Goals: -pl developer
    Profiles: developer
    Parameters: deploydb = true

Other Uses

RAT: ASF License Checking

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

Site Generation and Reporting

Code Block



h3. Site Generation and Reporting

{code}
$ mvn site
{code}


Versioning / Releases

Update the version number of the project

Code Block

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.

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.

Code Block
h2. Troubleshooting

* Offline Mode:

{code}
$ mvn -o 
  • Out of memory error, out of heap space:
Code Block
-Pextras,plugins,xwork
{code}

* Out of memory error, out of heap space:

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