1. Download Tomcat source code
(1) from official webside: http://apache.etoak.com/tomcat/tomcat-7/v7.0.42/src/apache-tomcat-7.0.42-src.zip
(2) from svn: http://svn.apache.org/repos/asf/tomcat/tc7.0.x/tags/TOMCAT_7_0_27/
Directory of source code in my machine: F:\svn\tomcat7
2. Install Apache Ant
(1) http://apache.etoak.com//ant/binaries/apache-ant-1.9.2-bin.zip
(2) extract it under a directory, mine is D:\Program Files\apache-ant-1.9.2
(3) Add System Env Variable: append 'D:\Program Files\apache-ant-1.9.2\bin' to PATH (need reboot to take effect)
3. Build Eclipse Project
(1) open CMD window, go to your source code directory(mine is F:\svn\tomcat7), enter cmd as:
ant ide-eclipse
(2) If console gives you BUILD SUCCESSFUL message, that's great.
(3) if console gives you BUILD FAILED, you need check what error infromation it gives to you. For like what I met here: can't find javac to complie, JAVA_HOME is point to ****. To correct it, you need recheck your JAVA_HOME, or just put tool.jar under jdk/lib(D:\Program Files\Java\jdk1.6.0_26\lib) into the lib folder for ant(D:\Program Files\apache-ant-1.9.2\bin)
4. Import Project into Eclipse
(1) Import Existing Project
(2) You may have some error after imported, please check Problems View of your eclipse to see details
(3) Add two Classpath variables: Perferences -> Java -> Build Path -> Classpath Variables -> New
(4) these two variables are: ANT_HOME - D:\Program Files\apache-ant-1.9.2, TOMCAT_LIBS_BASE - F:\usr\share (this folder is created when you doing build with Ant)
5. Run
(1) Everything would be ok now, you can start to run project
(2) Visit Tomcat welcome page by: localhost:8080