Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Fixed missing {code} macro. (Cloudstack Hackathon 2013)

...

As

...

part

...

of

...

switching

...

to

...

Apache

...

Maven

...

for

...

building

...

CloudStack,

...

the

...

.classpath

...

and

...

.project

...

files

...

used

...

by

...

Eclipse

...

were

...

removed.

...

This

...

page

...

describes

...

how

...

to

...

get

...

CloudStack

...

loaded

...

into

...

an

...

Eclipse

...

workspace.

...

For

...

more

...

details

...

on

...

the

...

actual

...

build

...

process

...

with

...

maven

...

see

...

How

...

to

...

build

...

on

...

master branch

Use a Recent Eclipse Build

These steps have been tested with Eclipse Indigo and Eclipse Juno- it's suggested you use that or a newer build.

Start with a clean workspace

To minimize confusion, start with a clean workspace with no other projects.

Clone CloudStack via git

Download the CloudStack source code via git with:

Code Block
 branch]





h3. Use a Recent Eclipse Build

These steps have been tested with [Eclipse Indigo|http://www.eclipse.org/indigo/] and [Eclipse Juno|http://www.eclipse.org/juno/]\- it's suggested you use that or a newer build.

h3. Start with a clean workspace

To minimize confusion, start with a clean workspace with no other projects.

h3. Clone CloudStack via git

Download the CloudStack source code via git with:
{code}
git clone https://git-wip-us.apache.org/repos/asf/cloudstack.git
{code}

h3. Install M2E

This [wiki page|http://wiki.eclipse.org/Maven_Integration] shows how to install the Maven integration for Eclipse plugin. (For those using Yoxos, just search for M2E and add it to your Eclipse build)

After installing the plugin, restart Eclipse.

h3. Import CloudStack

Now you can import CloudStack using the M2E plugin:

* Go to 

Install M2E

This wiki page shows how to install the Maven integration for Eclipse plugin. (For those using Yoxos, just search for M2E and add it to your Eclipse build)

After installing the plugin, restart Eclipse.

Import CloudStack

Now you can import CloudStack using the M2E plugin:

  • Go to File->Import...

...

  • Under

...

  • Maven

...

  • select

...

  • "Existing

...

  • Maven

...

  • Projects"

...

  • and

...

  • click

...

  • Next

...

  • Browse

...

  • to

...

  • and

...

  • select

...

  • the

...

  • root

...

  • directory

...

  • of

...

  • the

...

  • CloudStack

...

  • source

...

  • tree.

...

  • Once

...

  • selected,

...

  • Eclipse

...

  • will

...

  • scan

...

  • the

...

  • source

...

  • for

...

  • pom.xml

...

  • files.

...

  • Make

...

  • sure

...

  • all

...

  • are

...

  • selected,

...

  • then

...

  • click

...

  • the

...

  • Finish

...

  • button.

...

Eclipse

...

will

...

import

...

the

...

projects

...

and

...

build

...

the

...

code.

...

At

...

this

...

point

...

you

...

should

...

be

...

able

...

to

...

develop

...

and

...

debug

...

code

...

as

...

usual

...

within

...

Eclipse.

...

Making

...

Eclipse

...

Work

...

Better

...

with

...

CloudStack

Give Eclipse More Memory

CloudStack is a big project and it requires more memory for Eclipse.  Here's how to give it more memory.

  • Wiki Markup
    cd \[eclipse home\]

...

  • vi

...

  • eclipse.ini

...

  • Change

...

  • or

...

  • add

...

  • the

...

  • following

...

  • properties

...

    • -Xms1024m

...

    • -Xmx2048m

...

    • -XX:PermSize=512m

...

    • -XX:MaxPermSize=1024M

...

Eliminate

...

duplicate

...

resources

...

CloudStack

...

has

...

a

...

lot

...

of

...

projects

...

that

...

are

...

really

...

just

...

for

...

grouping

...

the

...

different

...

type

...

of

...

projects.

...

 The problem is in Eclipse,

...

the

...

files

...

that

...

belong

...

in

...

sub-projects

...

also

...

show

...

up

...

in

...

the

...

projects.

...

 This causes a lot of problems with the Open Resource dialogue, which is often used to quickly get to a file if you know the filename already.  These problems include the multiple copies of the same .class files showing up and multiple copies of the same .java file showing up.  If you select the wrong .java file, then a lot of the references doesn't work.  Upon further inspection, the reason is because the same .java and .class file is included by both the project and the parent project.  To get rid of this problem, do the following.  Unfortunately, you have to do this for every parent project.

  • Right click on the project and select Properties.
  • Go to Resource->Resource Filters.
  • Click on Add...
  • Select Exclude all
  • Select Folders
  • Click Regular Expression
  • Wiki Markup
    In the entry box, type \[a-zA-Z0-9\].\*

...

  • Click

...

  • OK

...

  • Click

...

  • OK

...

What

...

this

...

does

...

is

...

to

...

tell

...

Eclipse

...

that

...

the

...

sub-directories

...

under

...

parent

...

projects

...

should

...

not

...

be

...

included

...

in

...

the

...

resource

...

list,

...

thus

...

avoiding

...

the

...

the

...

duplicate

...

resources

...

in

...

the

...

Open

...

Resource

...

dialogue

...

box.

...

 If the parent project does have a directory that you want, then you can add that to a include filter.  Note that you can not use * as the folders because that would exclude the .settings folder which eclipse uses to keep its metadata and will cause the m2e plugin to have problems.

Here's a list of parent projects you should do this with:

  • cloudstack
  • cloud-services
  • cloudstack-framework
  • cloud-engine
  • cloudstack-plugins
Avoiding conflicts between builds outside of Eclipse and Eclipse's auto-building

Eclipse by default uses the the Maven pom.xml to tell it where to put its generated files.  Unfortunately, that has one big disadvantage.  Everytime a "mvn clean" is done outside of Eclipse, Eclipse will start rebuilding.  To avoid this, CloudStack has an Eclipse profile that puts all of the Eclipse generated files in a directory called target-eclipse.  In order to activate this, you must do the following to every project.  There is a shortcut for the existing projects so please read the shortcut first before deciding to do the following.  You still need to perform these steps manually if a new project is added after you ran the shortcut.

  • Right click on the project and select Properties
  • Select Maven
  • In the entry box under "Active Maven Profile", type in eclipse
  • Click OK

CloudStack has a lot of projects so doing the above by hand for every project takes time so here's a shortcut provided for existing projects.

  • Exit Eclipse (assuming you've already installed the m2e plugin)
  • Wiki Markup
    cd \[cloudstack home\]

...

  • bash

...

  • -x

...

  • tools/eclipse/set-eclipse-profile.sh

...

  • Restart

...

  • Eclipse

...

Bonus

...

Track:

...

Running

...

CloudStack

...

Through

...

Eclipse

...

The

...

Maven

...

integration

...

makes

...

it

...

reasonably

...

easy

...

to

...

run

...

and

...

debug

...

CloudStack

...

through

...

Eclipse.

...

Basically,

...

you

...

can

...

add

...

the

...

'mvn'

...

command-line

...

calls

...

to

...

your

...

Eclipse

...

Workspace

...

by

...

defining

...

corresponding

...

Run

...

Configurations.

...

The

...

Maven

...

commands

...

we

...

want

...

to

...

add

...

as

...

Run

...

Configurations

...

are

...

discussed

...

in

...

detail

...

on

...

the

...

How

...

to

...

build

...

on

...

master

...

branch

...

page.

...

The

...

steps

...

we

...

want

...

to

...

add

...

can

...

be

...

summarised

...

as

...

  1. Clean (remove

...

  1. previous

...

  1. versions

...

  1. of

...

  1. source).

...

  1. Install

...

  1. (build

...

  1. new

...

  1. version

...

  1. of

...

  1. source)

...

  1. Database

...

  1. Setup

...

  1. (deploy

...

  1. a

...

  1. database

...

  1. with

...

  1. default

...

  1. settings,

...

  1. e.g.

...

  1. default

...

  1. password)

...

  1. Jetty-based

...

  1. server

...

  1. launch

...

  1. (Jetty

...

  1. is

...

  1. an

...

  1. alternative

...

  1. to

...

  1. Tomcat

...

  1. suited

...

  1. to

...

  1. development)

...

Now,

...

we

...

could

...

have

...

combined

...

steps

...

1

...

&

...

2

...

above,

...

but

...

splitting

...

them

...

allows

...

incremental

...

compilation.

...

In

...

contrast,

...

combining

...

them

...

will

...

make

...

for

...

a

...

very

...

slow

...

build.

...

  Also,

...

you

...

only

...

need

...

to

...

setup

...

the

...

database

...

once

...

after

...

doing

...

a

...

Clean.

...

WRT

...

to

...

debugging:

...

Use

...

the

...

Jetty-based

...

server

...

lauch

...

.

...

First,

...

tweak

...

this

...

Debug

...

Configuration

...

for

...

source-level

...

debugging:

...

Use

...

Run

...

->

...

Debug

...

Configurations,

...

and

...

check

...

the

...

Resolve

...

Workspace

...

Artifacts

...

flag.

...

Creating

...

a

...

Run

...

Configuration

...

For

...

each

...

Run

...

Configuration

...

to

...

be

...

added:

...

  1. From

...

  1. menu

...

  1. bar,

...

  1. select

...

  1. R

...

  1. un

...

  1. ->

...

  1. Run

...

  1. Configurations...

...

  1. Double

...

  1. click

...

  1. on

...

  1. Maven

...

  1. Build

...

  1. .

...

  1.   This

...

  1. will

...

  1. create

...

  1. a

...

  1. Maven

...

  1. run

...

  1. configuration

...

  1. with

...

  1. the

...

  1. name

...

  1. New_configuration

...

  1. Update

...

  1. the

...

  1. N

...

  1. ame

...

  1. to

...

  1. something

...

  1. corresponding

...

  1. to

...

  1. what

...

  1. happens

...

  1. in

...

  1. the

...

  1. step,

...

  1. and

...

  1. set

...

  1. Base

...

  1. Directory

...

  1. to

...

  1. $project_loc:cloudstack

...

  1. (This

...

  1. tells

...

  1. Eclipse

...

  1. that

...

  1. the

...

  1. base

...

  1. directory

...

  1. for

...

  1. execution

...

  1. is

...

  1. the

...

  1. folder

...

  1. with

...

  1. a

...

  1. _pom.xml

...

  1. _

...

  1. that

...

  1. has

...

  1. an

...

  1. <artifactId>

...

  1. with

...

  1. the

...

  1. value

...

  1. cloudstack

...

  1. )

...

  1. From

...

  1. each

...

  1. mvn

...

  1. command,

...

  1. place

...

  1. the

...

  1. -P

...

  1. argument

...

  1. in

...

  1. the

...

  1. P

...

  1. rofiles:

...

  1. textbox,

...

  1. A

...

  1. dd...

...

  1. any

...

  1. parameters

...

  1. expressed

...

  1. as

...

  1. key=value

...

  1. ,

...

  1. and

...

  1. place

...

  1. the

...

  1. remainder

...

  1. of

...

  1. the

...

  1. command

...

  1. in

...

  1. the

...

  1. G

...

  1. oals:

...

  1. textbox.

...

Maven

...

will

...

download

...

everything

...

needed

...

to

...

run

...

CloudStack

...

with

...

Jetty,

...

build

...

the

...

code,

...

and

...

run

...

the

...

UI.

...

You

...

can

...

connect

...

to

...

it

...

via

...

http://localhost:8080/client

...

.

...

The

...

following

...

commands

...

were

...

correct

...

at

...

the

...

time

...

of

...

writing.

...

  If

...

they

...

don't

...

work,

...

double

...

check

...

the

...

How

...

to

...

build

...

on

...

master

...

branch

...

page,

...

and

...

if

...

you

...

have

...

any

...

compassion

...

update

...

this

...

section

...

of

...

the

...

wiki.

...

...

Clean:

...

{
Code Block
}
 mvn clean
{code}

Base

...

directory:

...

$project_loc:cloudstack

...


Goals:

...

clean

...

install

...


Profiles:

...

<empty>

Install (i.e.

...

build):
{
Code Block
}
 mvn install
{code}

Base

...

directory:

...

$project_loc:cloudstack

...


Goals:

...

clean

...

install

...


Profiles:

...

<empty>

Deploy Database (do

...

once

...

after

...

a

...

'Clean'):

...

mvn

...

install:
{
Code Block
}
 mvn -P developer -pl developer -Ddeploydb=true
{code}

Base

...

directory:

...

$project_loc:cloudstack

...


Goals:

...

-pl

...

developer

...


Profiles:

...

developer
Parameter Name:

...

deploydb=true

...

Jetty-based

...

launch

...

(of

...

management

...

server)
{
Code Block
}
 mvn -pl client jetty:run
{code}

Base

...

directory:

...

$project_loc:/cloud-client-ui

...


Goals:

...

jetty:run

...


Profiles:

...

<empty>

(Optional)

...

launch

...

the

...

jetty

...

based

...

awsapi

...

server:
{
Code Block
}
 mvn -pl awsapi jetty:run
{code}

Base

...

directory:

...

$project_loc:cloudstack

...


Goals:

...

-pl

...

awsapi

...

jetty:run

...


Profiles:

...

<empty>

Remote Debugging

You can use Eclipse to attach to the Management Server and debug CloudStack. You setup a Remote Debug Session (Run > Debug Configuration), connect to Port 8787. Typically you would use the project you want to debug as the target and include other projects that you need to debug, e.g. cloud-agent, cloud-api, cloud-core and cloud-server.