全自动的使用ANT编译,打包EJB项目,并且部署到Websphere服务器上面。
题外话,刚发现JAVAEYE没有EJB和WebSphere的板块,有点小郁闷。
首先我们可以在build.properties上面定义在编译部署过程中使用到的变量。
包括项目名,项目路径,部署路径等等
然后是项目的CLASS_PATH。
然后是Websphere相关的Lib的路径
在这些变量设置好了之后,我们就可以开始编译了。
在build.xml里面,
引用build.properties里面设置好的变量。
设置CLASS_PATH
然后进行必要的文件目录的初始化。
从cvs上面下载更新代码
编译,注意配置好项目目的依赖关系就好了
题外话,刚发现JAVAEYE没有EJB和WebSphere的板块,有点小郁闷。
![](https://i-blog.csdnimg.cn/blog_migrate/34ee22ea28118a6d0f49933ccc3d69af.gif)
首先我们可以在build.properties上面定义在编译部署过程中使用到的变量。
包括项目名,项目路径,部署路径等等
- app.name = XXXXX
- dist.home = C :/antoutput
- encoding = UTF -8
- project.home = C :/CVSROOT/src/XXXXX
- deploy.path = C :/Program Files/IBM/SDP70/runtimes/base_v61/profiles/AppSrvWSFP01/installedApps/D1N4GGBXNode02Cell
- .
- .
- .
- .
- project.class.path =
- XXX1_LIB =XXXXXXXX1
- XXX2_LIB = XXXXXXXX2
- XXX1_LIB.dir =${project.home}/${XXX1_LIB}
- XXX2_LIB.dir =${project.home}/${XXX2_LIB}
然后是Websphere相关的Lib的路径
- websphere.base_v61.runtime.dir = C :/Program Files/ibm/SDP70/runtimes/base_v61
- websphere.runtime.lib.dir =${websphere.base_v61.runtime.dir}/lib
- websphere.runtime.plugins.lib.dir =${websphere.base_v61.runtime.dir}/plugins
- websphere.runtimes.webservice.lib.dir =${websphere.base_v61.runtime.dir}/runtimes
在这些变量设置好了之后,我们就可以开始编译了。
在build.xml里面,
引用build.properties里面设置好的变量。
- < property file = "build.properties" />
- < path id = "XXX1_LIB.classpath" >
- < fileset dir = "${XXX1_LIB.dir}" >
- < include name = "**/*.jar" />
- </ fileset >
- </ path >
- < path id = "XXX2_LIB.classpath" >
- < fileset dir = "${XXX2_LIB.dir}" >
- < include name = "**/*.jar" />
- </ fileset >
- </ path >
- < path id = "project.class.path" >
- < pathelement path = "${project.class.path}" />
- </ path >
- < path id = "websphere.runtime.classpath" >
- < fileset dir = "${websphere.runtime.lib.dir}" >
- < include name = "**/*.jar" />
- </ fileset >
- < fileset dir = "${websphere.runtime.plugins.lib.dir}" >
- < include name = "**/*.jar" />
- </ fileset >
- < fileset dir = "${websphere.runtimes.webservice.lib.dir}" >
- < include name = "**/*.jar" />
- </ fileset >
- </ path >
然后进行必要的文件目录的初始化。
- < target name = "clean" >
- < delete dir = "${dist.home}" />
- .
- .
- .
- .
- </ target >
- < target name = "init" >
- < mkdir dir = "${dist.home}" />
- .
- .
- .
- .
- .
- </ target >
从cvs上面下载更新代码
- < target name = "deleteCvsHome" >
- < delete dir = "C:/cvstest" />
- </ target >
- < target name = "cvsCheckout" >
- < mkdir dir = "C:/cvstest" />
- < property name = "cvsroot" value = ":pserver:user:passwd@IP:/cvsroot/data/XXX" />
- < property name = "projectName" value = "XXXXXXXXXXX" />
- < tstamp >
- < format property = "today" pattern = "yyyy-MM-dd hh:mm:ss" />
- </ tstamp >
- < echo message = "${today}" />
- < cvs cvsRoot = "${cvsroot}" dest = "C:/cvstest" package = "${projectName}" />
- </ target >
- < target name = "cvsUpdate" >
- < property name = "cvsroot" value = ":pserver:user:passwd@IP:/cvsroot/data/XXX" />
- < property name = "projectName" value = "XXXXXXXXXXX" />
- < tstamp >
- < format property = "today" pattern = "yyyy-MM-dd hh:mm:ss" />
- </ tstamp >
- < echo message = "${today}" />
- < cvs cvsRoot = "${cvsroot}" command = "update" dest = "C:/cvstest" package = "${projectName}" />
- </ target >
编译,注意配置好项目目的依赖关系就好了
- < target name = "buildxxxxDto" depends = "init" >
- < mkdir dir = "${xxxx.dto.classes}" />
- < javac srcdir = "${xxxx.dto.src}" destdir = "${xxxx.dto.classes}" encoding = "${encoding}" debug = "true" deprecation = "true" nowarn = "false" >
- < classpath refid = "project.class.path" />
- < classpath refid = "websphere.runtime.classpath" />
- < classpath refid = "XXX1_LIB.classpath" />
- < classpath refid = "XXX2_LIB.classpath" />
- </ javac >
- </ target >
- < target name = "buildxxxxEjbClient" depends = "init,buildxxxxDto" >
- < mkdir dir = "${xxxx.ejbclient.classes}" />
- < javac srcdir = "${xxxx.ejbclient.src}" destdir = "${xxxx.ejbclient.classes}" encoding = "${encoding}" debug = "true" deprecation = "true" nowarn = "false" >
- < classpath refid = "project.class.path" />
- < classpath refid = "websphere.runtime.classpath" />
- < classpath refid = "XXX1_LIB.classpath" />
- < classpath refid = "XXX2_LIB.classpath" />
- </ javac >
- < copy todir = "${xxxx.ejbclient.classes}" >
- < fileset dir = "${xxxx.ejbclient.resources}" >
- < include name = "**/*.properties" />
- < include name = "**/*.xml" />
- </ fileset >
- </ copy >
- </ target >
- < target name = "buildxxxxEjb" depends = "init,buildxxxxDto,buildxxxxEjbClient" >
- < mkdir dir = "${xxxx.ejb.classes}" />
- < javac srcdir = "${xxxx.ejb.src}" destdir = "${xxxx.ejb.classes}" encoding = "${encoding}" debug = "true" deprecation = "true" nowarn = "false" >
- < classpath refid = "project.class.path" />
- < classpath refid = "websphere.runtime.classpath" />
- < classpath refid = "XXX1_LIB.classpath" />
- < classpath refid = "XXX2_LIB.classpath" />
- </ javac >
- </ target >
- < target name = "buildxxxxSrvBizImpl" depends = "init,buildxxxxEjbClient" >
- < mkdir dir = "${xxxx.srv.classes}" />
- < javac srcdir = "${xxxx.srv.src}"