- 论坛徽章:
- 0
|
1.环境变量设置
首先,确定自己的/etc/profile或者/${HOME}/.bashrc下有如下的环境设置:
------
#set java env
export JAVA_HOME=xxx
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar:$CLASSPATH
#set tomcat env
export TOMCAT_HOME=xxx
#set ant env
export ANT_HOME=xxx
export PATH=$PATH:$ANT_HOME/bin
------
有了以上的设置,就可以使用来找到相关的环境变量。
在shell下可以
[root@localhost ~]# env
查看环境变量。
2.ant脚本位置
根据MyEclipse下Web工程的文件位置放置build.xml(与WebRoot同层):
------
|-src
|-WebRoot
|-WEB-INF
|-META-INF
|-build.xml
------
3.build.xml
该脚本可以将当前的Web工程编译并部署到你的Tomcat的webapps目录下,为避免在webapps下出现工程名相同而覆盖的情况,将使用当前部署时间作为工程名。注意,这里假定使用Tomcat6,它的/lib目录有别于Tomcat5。
[color="#0000ff"] [color="#ff0000"]version[color="#0000ff"]="1.0" [color="#ff0000"]encoding[color="#0000ff"]="utf-8"[color="#0000ff"]?>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="myDeploy" [color="#ff0000"]default[color="#0000ff"]="all" [color="#ff0000"]basedir[color="#0000ff"]="."[color="#0000ff"]>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="build.dir" [color="#ff0000"]value[color="#0000ff"]="${basedir}/build"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="src" [color="#ff0000"]value[color="#0000ff"]="${basedir}/src"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="build.webinf" [color="#ff0000"]value[color="#0000ff"]="${basedir}/build/WEB-INF"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="build.weblib" [color="#ff0000"]value[color="#0000ff"]="${basedir}/build/WEB-INF/lib"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="build.metainf" [color="#ff0000"]value[color="#0000ff"]="${basedir}/build/META-INF"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="build.dest" [color="#ff0000"]value[color="#0000ff"]="${basedir}/build/WEB-INF/classes"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]environment[color="#0000ff"]="env"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="init"[color="#0000ff"]>
[color="#0000ff"]
[color="#0000ff"] [color="#ff0000"]dir[color="#0000ff"]="${build.dir}"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]dir[color="#0000ff"]="${build.webinf}"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]dir[color="#0000ff"]="${build.weblib}"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]dir[color="#0000ff"]="${build.metainf}"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]dir[color="#0000ff"]="${build.dest}"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]todir[color="#0000ff"]="${build.dir}"[color="#0000ff"]>
[color="#0000ff"] [color="#ff0000"]dir[color="#0000ff"]="${basedir}/WebRoot"[color="#0000ff"]>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="**"[color="#0000ff"]/>
[color="#0000ff"]
[color="#0000ff"]
[color="#0000ff"]
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="compile" [color="#ff0000"]depends[color="#0000ff"]="init"[color="#0000ff"]>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="servletapi"
[color="#ff0000"]value[color="#0000ff"]="${env.TOMCAT_HOME}/lib/[color="#0000ff"]*[color="#0000ff"].jar"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="locallib"
[color="#ff0000"]value[color="#0000ff"]="${build.weblib}/*.jar"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]srcdir[color="#0000ff"]="${src}" [color="#ff0000"]destdir[color="#0000ff"]="${build.dest}" [color="#ff0000"]classpath[color="#0000ff"]="${servletapi};${locallib}"[color="#0000ff"]/>
[color="#0000ff"]
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="deploy" [color="#ff0000"]depends[color="#0000ff"]="compile"[color="#0000ff"]>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="deploy.dir" [color="#ff0000"]value[color="#0000ff"]="${env.TOMCAT_HOME}/webapps/${DSTAMP}${TSTAMP}"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]dir[color="#0000ff"]="${deploy.dir}"[color="#0000ff"]/>
[color="#0000ff"] [color="#ff0000"]todir[color="#0000ff"]="${deploy.dir}"[color="#0000ff"]>
[color="#0000ff"] [color="#ff0000"]dir[color="#0000ff"]="${build.dir}"[color="#0000ff"]>
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="**"[color="#0000ff"]/>
[color="#0000ff"]
[color="#0000ff"]
[color="#0000ff"]
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="clean" [color="#ff0000"]depends[color="#0000ff"]="init"[color="#0000ff"]>
[color="#0000ff"] [color="#ff0000"]dir[color="#0000ff"]="${build.dir}"[color="#0000ff"]/>
[color="#0000ff"]
[color="#0000ff"] [color="#ff0000"]name[color="#0000ff"]="all" [color="#ff0000"]depends[color="#0000ff"]="deploy,clean"
[color="#ff0000"]description[color="#0000ff"]="deploys the project to tomcat and cleans the build files."[color="#0000ff"]/>
[color="#0000ff"]
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u3/93926/showart_1873745.html |
|