全自动的使用ANT编译,打包EJB项目,并且部署到Websphere服务器上面。

全自动的使用ANT编译,打包EJB项目,并且部署到Websphere服务器上面。

题外话,刚发现JAVAEYE没有EJB和WebSphere的板块,有点小郁闷。


首先我们可以在build.properties上面定义在编译部署过程中使用到的变量。

包括项目名,项目路径,部署路径等等

Xml代码 复制代码
  1. app.name = XXXXX   
  2. dist.home = C :/antoutput   
  3. encoding = UTF -8   
  4. project.home = C :/CVSROOT/src/XXXXX   
  5. deploy.path = C :/Program Files/IBM/SDP70/runtimes/base_v61/profiles/AppSrvWSFP01/installedApps/D1N4GGBXNode02Cell   
  6.   
  7. .   
  8. .   
  9. .   
  10. .  
然后是项目的CLASS_PATH。

Xml代码 复制代码
  1. project.class.path =   
  2.   
  3. XXX1_LIB =XXXXXXXX1   
  4. XXX2_LIB = XXXXXXXX2   
  5. XXX1_LIB.dir =${project.home}/${XXX1_LIB}   
  6. XXX2_LIB.dir =${project.home}/${XXX2_LIB}  


然后是Websphere相关的Lib的路径

Xml代码 复制代码
  1. websphere.base_v61.runtime.dir = C :/Program Files/ibm/SDP70/runtimes/base_v61   
  2.   
  3. websphere.runtime.lib.dir =${websphere.base_v61.runtime.dir}/lib   
  4. websphere.runtime.plugins.lib.dir =${websphere.base_v61.runtime.dir}/plugins   
  5. websphere.runtimes.webservice.lib.dir =${websphere.base_v61.runtime.dir}/runtimes  


在这些变量设置好了之后,我们就可以开始编译了。

在build.xml里面,

引用build.properties里面设置好的变量。
Xml代码 复制代码
  1. < property   file = "build.properties"   />   
设置CLASS_PATH

Xml代码 复制代码
  1. < path   id = "XXX1_LIB.classpath" >   
  2.      < fileset   dir = "${XXX1_LIB.dir}" >   
  3.          < include   name = "**/*.jar"   />   
  4.      </ fileset >   
  5. </ path >   
  6. < path   id = "XXX2_LIB.classpath" >   
  7.      < fileset   dir = "${XXX2_LIB.dir}" >   
  8.          < include   name = "**/*.jar"   />   
  9.      </ fileset >   
  10. </ path >   
  11. < path   id = "project.class.path" >   
  12.      < pathelement   path = "${project.class.path}"   />   
  13. </ path >   
  14. < path   id = "websphere.runtime.classpath" >   
  15.      < fileset   dir = "${websphere.runtime.lib.dir}" >   
  16.          < include   name = "**/*.jar"   />   
  17.      </ fileset >   
  18.      < fileset   dir = "${websphere.runtime.plugins.lib.dir}" >   
  19.          < include   name = "**/*.jar"   />   
  20.      </ fileset >   
  21.      < fileset   dir = "${websphere.runtimes.webservice.lib.dir}" >   
  22.          < include   name = "**/*.jar"   />   
  23.      </ fileset >   
  24. </ path >   

然后进行必要的文件目录的初始化。

Xml代码 复制代码
  1. < target   name = "clean" >   
  2.      < delete   dir = "${dist.home}"   />   
  3.     .   
  4.     .   
  5.     .   
  6.     .   
  7.        
  8. </ target >   
  9. < target   name = "init" >   
  10.      < mkdir   dir = "${dist.home}"   />   
  11.     .   
  12.     .   
  13.     .   
  14.     .   
  15.     .   
  16. </ target >   

从cvs上面下载更新代码
Xml代码 复制代码
  1.     < target   name = "deleteCvsHome" >   
  2.      < delete   dir = "C:/cvstest"   />   
  3. </ target >   
  4. < target   name = "cvsCheckout" >   
  5.      < mkdir   dir = "C:/cvstest"   />   
  6.      < property   name = "cvsroot"   value = ":pserver:user:passwd@IP:/cvsroot/data/XXX"   />   
  7.      < property   name = "projectName"   value = "XXXXXXXXXXX"   />   
  8.      < tstamp >   
  9.          < format   property = "today"   pattern = "yyyy-MM-dd hh:mm:ss"   />   
  10.      </ tstamp >   
  11.      < echo   message = "${today}"   />   
  12.      < cvs   cvsRoot = "${cvsroot}"   dest = "C:/cvstest"   package = "${projectName}"   />   
  13. </ target >   
  14. < target   name = "cvsUpdate" >   
  15.         < property   name = "cvsroot"   value = ":pserver:user:passwd@IP:/cvsroot/data/XXX"   />   
  16.         < property   name = "projectName"   value = "XXXXXXXXXXX"   />   
  17.         < tstamp >   
  18.             < format   property = "today"   pattern = "yyyy-MM-dd hh:mm:ss"   />   
  19.         </ tstamp >   
  20.      < echo   message = "${today}"   />   
  21.      < cvs   cvsRoot = "${cvsroot}"   command = "update"   dest = "C:/cvstest"   package = "${projectName}"   />   
  22. </ target >   

编译,注意配置好项目目的依赖关系就好了

Xml代码 复制代码
  1. < target   name = "buildxxxxDto"   depends = "init" >   
  2.      < mkdir   dir = "${xxxx.dto.classes}"   />   
  3.      < javac   srcdir = "${xxxx.dto.src}"   destdir = "${xxxx.dto.classes}"   encoding = "${encoding}"   debug = "true"   deprecation = "true"   nowarn = "false" >   
  4.          < classpath   refid = "project.class.path"   />   
  5.          < classpath   refid = "websphere.runtime.classpath"   />   
  6.          < classpath   refid = "XXX1_LIB.classpath"   />   
  7.          < classpath   refid = "XXX2_LIB.classpath"   />   
  8.      </ javac >   
  9. </ target >   
  10.   
  11.   
  12. < target   name = "buildxxxxEjbClient"   depends = "init,buildxxxxDto" >   
  13.      < mkdir   dir = "${xxxx.ejbclient.classes}"   />   
  14.      < javac   srcdir = "${xxxx.ejbclient.src}"   destdir = "${xxxx.ejbclient.classes}"   encoding = "${encoding}"   debug = "true"   deprecation = "true"   nowarn = "false" >   
  15.          < classpath   refid = "project.class.path"   />   
  16.          < classpath   refid = "websphere.runtime.classpath"   />   
  17.          < classpath   refid = "XXX1_LIB.classpath"   />   
  18.          < classpath   refid = "XXX2_LIB.classpath"   />   
  19.      </ javac >   
  20.      < copy   todir = "${xxxx.ejbclient.classes}" >   
  21.          < fileset   dir = "${xxxx.ejbclient.resources}" >   
  22.              < include   name = "**/*.properties"   />   
  23.              < include   name = "**/*.xml"   />   
  24.          </ fileset >   
  25.      </ copy >   
  26. </ target >   
  27. < target   name = "buildxxxxEjb"   depends = "init,buildxxxxDto,buildxxxxEjbClient" >   
  28.      < mkdir   dir = "${xxxx.ejb.classes}"   />   
  29.      < javac   srcdir = "${xxxx.ejb.src}"   destdir = "${xxxx.ejb.classes}"   encoding = "${encoding}"   debug = "true"   deprecation = "true"   nowarn = "false" >   
  30.          < classpath   refid = "project.class.path"   />   
  31.          < classpath   refid = "websphere.runtime.classpath"   />   
  32.          < classpath   refid = "XXX1_LIB.classpath"   />   
  33.          < classpath   refid = "XXX2_LIB.classpath"   />   
  34.      </ javac >   
  35. </ target >   
  36.   
  37. < target   name = "buildxxxxSrvBizImpl"   depends = "init,buildxxxxEjbClient" >   
  38.      < mkdir   dir = "${xxxx.srv.classes}"   />   
  39.      < javac   srcdir = "${xxxx.srv.src}"  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值