EJB Builder Using Groovy AntBuilder


/ Published in: Groovy
Save to your folder(s)

Builds EJB Jar using AntBuilder


Copy this code and paste it in your HTML
  1. package com.sb.build.tool
  2. /***
  3.  * Builds a EJB Project into corresponding jar
  4.  * @author sankarsan
  5.  *
  6.  */
  7. class EJBBuilder {
  8.  
  9. def ant = null
  10. EJBBuilder(ant){
  11. this.ant = ant;
  12. }
  13. /***
  14. * Builds a EJB Project given the project/EJB name
  15. * @param name
  16. * @return
  17. */
  18. def buildEJB(name)
  19. {
  20. def javacclasspath = ConfigManager.props["javac.classpath"]
  21. def jeeclasspath = ConfigManager.props["j2ee.platform.classpath"]
  22. def classpath = javacclasspath+ConfigManager.props["classpath.seperator"]+jeeclasspath
  23.  
  24. def projectroot = ConfigManager.props[name+ ".root"]
  25.  
  26. def sourceroot = projectroot + ConfigManager.props["source.root"]
  27. def sourcedir = sourceroot + ConfigManager.props["src.dir"]
  28. def confdir = sourceroot + ConfigManager.props["src.conf.dir"]
  29.  
  30. def buildroot = projectroot + ConfigManager.props["build.dir"]
  31. def classdir = buildroot + ConfigManager.props["build.classes.dir"]
  32. def metainfdir = classdir + ConfigManager.props["build.metainf.dir"]
  33.  
  34. def distdir = projectroot + ConfigManager.props["dist.dir"]
  35.  
  36. println "Step1. Performing Clean for " + name + " EJB Project"
  37.  
  38. ant.delete(dir:buildroot)
  39. ant.delete(dir:distdir)
  40.  
  41. println "Step2. Creating directories"
  42.  
  43. ant.mkdir(dir:buildroot)
  44. ant.mkdir(dir:classdir)
  45. ant.mkdir(dir:metainfdir)
  46. ant.mkdir(dir:distdir)
  47.  
  48. println "Step3. Copy META-INF contents"
  49.  
  50. ant.copy(todir: metainfdir) {
  51. fileset(dir : confdir);
  52. }
  53.  
  54. println "Step4. Compiling Classes"
  55.  
  56. ant.javac(
  57. srcdir:sourcedir,
  58. destdir:classdir,
  59. classpath:classpath,
  60. includeantruntime:false
  61. )
  62. println "Step5. Creating EJB Jar"
  63.  
  64. ant.jar(
  65. compress:true,
  66. jarfile:distdir + name + ".jar",
  67. manifest:metainfdir + "\\MANIFEST.MF"
  68. ){
  69. fileset(dir:classdir)
  70. }
  71. println "Build Completed For EJB Project " + name
  72. }
  73. }

URL: ejbbuilder

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.