Using Eclipse With CloudStack
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 CloudStack
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:
git clone https: //git-wip-us.apache.org/repos/asf/cloudstack.git |
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.
- 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
- 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)
- 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 CloudStack 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. 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:
- From menu bar, select Run -> Run Configurations...
- Double click on Maven Build. This will create a Maven run configuration with the name New_configuration
- 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) - 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.
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 CloudStack page, and if you have any compassion update this section of the wiki.
Clean:
mvn clean |
Base directory: $project_loc:cloudstack
Goals: clean install
Profiles: <empty>
Install (i.e. build):
mvn install |
Base directory: $project_loc:cloudstack
Goals: clean install
Profiles: <empty>
Deploy Database (do once after a 'Clean'): mvn install:
mvn -P developer -pl developer -Ddeploydb= true |
Base directory: $project_loc:cloudstack
Goals: -pl developer
Profiles: developer
Parameter Name: deploydb=true
Jetty-based launch (of management server)
mvn -pl client jetty:run |
Base directory: $project_loc:/cloud-client-ui
Goals: jetty:run
Profiles: <empty>
(Optional) launch the jetty based awsapi server:
mvn -pl awsapi jetty:run |
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.
Using Eclipse With CloudStack的更多相关文章
- 虚拟化平台cloudstack(7)——新版本的调试
调试环境 ubuntu 12.04 JDK1.7 apache-maven-3.10 eclipse 4.2 Juno mysql 5 源码下载及调试 上面的几个软件在上一篇中已经介绍了. 在新的版本 ...
- 虚拟化平台cloudstack(6)——使用maven:jetty调试
调试环境 ubuntu 12.04 JDK1.7 apache-maven-3.10 eclipse 4.2 Juno mysql 5 apache ant JDK的配置和安装 安装可以参考: htt ...
- CloudStack 4.2 新功能:集成SNMP进行系统监控(原理篇)
作者微博:http://weibo.com/tianchunfeng CloudStack 4.2 版本发布在即,相信不久后对 4.2 版本新功能(共有13个)的介绍会逐渐多起来.因为无论是从架构底层 ...
- 虚拟化平台cloudstack新版本的调试
虚拟化平台cloudstack(7)——新版本的调试 调试环境 ubuntu 12.04 JDK1.7 apache-maven-3.10 eclipse 4.2 Juno mysql 5 源码下载及 ...
- java+ssh+eclipse开发过程问题记录
原文 http://www.sdfengxi.com/?p=408 最近在忙着的项目是基于cloudstack平台的管理平台,因为CloudStack使用java开发,管理机上已部署好rhel+t ...
- eclipse 快捷键大全
注:因eclipse版本.电脑配置等原因 有些快捷键可能导致不可用(遇到些许问题可在下方评论) [Ct rl+T] 搜索当前接口的实现类 1. [ALT +/] 此快捷键为用户编辑的好帮手,能为 ...
- tomcat开发远程调试端口以及利用eclipse进行远程调试
一.tomcat开发远程调试端口 方法1 WIN系统 在catalina.bat里: SET CATALINA_OPTS=-server -Xdebug -Xnoagent -Djava.compi ...
- Eclipse中启动tomcat报错java.lang.OutOfMemoryError: PermGen space的解决方法
有的项目引用了太多的jar包,或者反射生成了太多的类,异或有太多的常量池,就有可能会报java.lang.OutOfMemoryError: PermGen space的错误, 我们知道可以通过jvm ...
- 修改eclipse皮肤
习惯了vim黑色背景的程序猿们想必用eclipse时会倍感的不适应吧,不过没关系,因为eclipse的皮肤是可以自己定制的! 下面是我电脑上的eclipse界面,看到这个是不是找回了vim的感觉呢? ...
随机推荐
- hbase+hive应用场景
一.Hive应用场景本文主要讲述使用 Hive 的实践,业务不是关键,简要介绍业务场景,本次的任务是对搜索日志数据进行统计分析.集团搜索刚上线不久,日志量并不大 .这些日志分布在 5 台前端机,按小时 ...
- Kyoto Cabinet(DBM) + Kyoto Tycoon(网络层)
项目原地址kyotocabinet: http://fallabs.com/kyotocabinet/ kyototycoon: http://fallabs.com/kyototyc ...
- linux下mysql操作的命令
最近在学习mysql,还是只菜鸟,找到下面篇文章对初学者挺有用的,所以共享下 1.linux下启动mysql的命令: mysqladmin start /ect/init.d/mysql star ...
- linux中ulimit作用
一.作用 Linux对于每个用户,系统限制其最大进程数.为提高性能,可以根据设备资源情况,设置各linux 用户的最大进程数. ulimit主要是用来限制进程对资源的使用情况的,它支持各种类型的限制, ...
- 关于COUNT STOPKEY的工作机制(转载)
SQL> select rownum rn ,a.* from cnmir.ew_auctions a where rownum<50000; Execution Plan-------- ...
- Intellij IDEA开发第一个Android应用
1.创建一个项目 File——>New Project——>.......——>Finish 2.创建模块 3.MyActivity.java package com.example ...
- 14个最受欢迎的Python开源框架
本文从GitHub中整理出的14个最受欢迎的Python开源框架.这些框架包括事件I/O,OLAP,Web开发,高性能网络通信,测试,爬虫等. Django: Python Web应用开发框架 Dja ...
- 使用Thrift RPC编写程序(服务端和客户端)
1. Thrift类介绍 Thrift代码包(位于thrift-0.6.1/lib/cpp/src)有以下几个目录: concurrency:并发和时钟管理方面的库processor:Processo ...
- 编写服务说明.thrift文件
1.数据类型 基本类型: bool:布尔值,true 或 false,对应 Java 的 boolean byte:8 位有符号整数,对应 Java 的 byte i16:16 位有符号整数,对应 J ...
- ASP.NET MVC3 系列教程 - 部署你的WEB应用到IIS 6.0
I:ASP.NET MVC3 部署的前期工作 1.确认部署的服务器操作系统环境 首先我们确认服务器的操作系统版本 可以从系统命令行工具里输入: systeminfo 获取相关操作系统信息例如 然后再确 ...