Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Wiki Markup
As part of switching to [Apache Maven|http://maven.apache.org/] 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

...

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.

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.

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 be 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 previous versions of source).
  2. Install (build new version of source)
  3. Database Setup (deploy a database with default settings, e.g. default password)
  4. Jetty-based server launch (Jetty is an alternative to Tomcat suited to 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 menu bar, select Run -> Run Configurations...
  2. Double click on Maven Build.  This will create a Maven run configuration with the name New_configuration
  3. Update the Name to something corresponding to what happens in the step, and set Base Directory to $project_loc:cloudstack (This tells Eclipse that the base directory for execution is the folder with a _pom.xml_ that has an <artifactId> with the value cloudstack)
  4. From each mvn command, place the -P argument in the Profiles: textbox, Add... any parameters expressed as key=value , and place the remainder of the command in the Goals: textbox.

...

 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. 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 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.

h3. 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 be 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

# Clean  (remove previous versions of source).
# Install (build new version of source)
# Database Setup (deploy a database with default settings, e.g. default password)
# Jetty-based server launch (Jetty is an alternative to Tomcat suited to 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.&nbsp; 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.

h4. Creating a Run Configuration


For each Run Configuration to be added:

# From menu bar, select _{+}R{+}{_}{_}un \-> Run Configurations..._
# Double click on _Maven Build_.&nbsp; This will create a Maven run configuration with the name _New_configuration_
# Update the _{+}N{+}{_}{_}ame_ to something corresponding to what happens in the step, and set _Base Directory_ to {{$project_loc:cloudstack}} (This tells Eclipse that the base directory for execution is the folder with a \_pom.xml\_ that has an _<artifactId>_ with the value _cloudstack_)
# From each _mvn_ command, place the \-P argument in the _{+}P{+}{_}{_}rofiles:_ textbox, _{+}A{+}{_}{_}dd..._ any parameters expressed as _key=value_ , and place the remainder of the command in the _{+}G{+}{_}{_}oals:_ 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.

...

&nbsp; 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.

...




h6. Clean:


{code
}
 mvn clean
{code}
Base directory: {{$project_loc:cloudstack

...

}}
Goals: {{clean install

...

}}
Profiles:

...

 _<empty>_

h6. Install (i.e. build):


{code
}
 mvn install
{code}
Base directory: {{$project_loc:cloudstack

...

}}
Goals: {{clean install

...

}}
Profiles:

...

 _<empty>_

h6. Deploy Database (do once after a 'Clean'): mvn install:


{code
}
 mvn -P developer -pl developer -Ddeploydb=true
{code}
Base directory: {{$project_loc:cloudstack

...

}}
Goals: {{\-pl developer

...

}}
Profiles:

...

 {{developer}}
Parameter Name: {{deploydb=true

...

}}

h6. Jetty-based launch (of management server)


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

Base directory:

...

 ${project_loc:

...

/cloud-client-ui}
Goals: {{jetty:run

...

}}
Profiles:

...

 _<empty>_

h6. (Optional) launch the jetty based awsapi server:


{code
}
 mvn -pl awsapi jetty:run
{code}

Base directory: {{$project_loc:cloudstack

...

}}
Goals: {{\-pl awsapi jetty:run

...

}}
Profiles: _<empty>_