Return to Snippet

Revision: 51723
at October 2, 2011 05:40 by sankarsan


Initial Code
package com.sb.build.tool
/***
 * Builds a EJB Project into corresponding jar
 * @author sankarsan
 *
 */
class EJBBuilder {
	
	def ant = null
	EJBBuilder(ant){
		this.ant = ant;
	}
	/***
	 * Builds a EJB Project given the project/EJB name
	 * @param name
	 * @return
	 */
	def buildEJB(name)
	{
		def javacclasspath = ConfigManager.props["javac.classpath"]
		def jeeclasspath   = ConfigManager.props["j2ee.platform.classpath"]
		def classpath = javacclasspath+ConfigManager.props["classpath.seperator"]+jeeclasspath
		
		def projectroot = ConfigManager.props[name+ ".root"]
		
		def sourceroot = projectroot + ConfigManager.props["source.root"]
		def sourcedir =  sourceroot + ConfigManager.props["src.dir"]
		def confdir = sourceroot + ConfigManager.props["src.conf.dir"]
		
		def buildroot = projectroot + ConfigManager.props["build.dir"]
		def classdir  =  buildroot + ConfigManager.props["build.classes.dir"]
		def metainfdir  =  classdir + ConfigManager.props["build.metainf.dir"]
		
		def distdir   =  projectroot + ConfigManager.props["dist.dir"]
		
		println "Step1. Performing Clean for " + name + " EJB Project"
		
		ant.delete(dir:buildroot)
		ant.delete(dir:distdir)
		
		println "Step2. Creating directories"
		
		ant.mkdir(dir:buildroot)
		ant.mkdir(dir:classdir)
		ant.mkdir(dir:metainfdir)
		ant.mkdir(dir:distdir)
		
		println "Step3. Copy META-INF contents"
		
		ant.copy(todir: metainfdir) {
			fileset(dir : confdir);
		}
		
		println "Step4. Compiling Classes"
		
		ant.javac(
					srcdir:sourcedir,
					destdir:classdir,
					classpath:classpath,
					includeantruntime:false
				 )
		println "Step5. Creating EJB Jar"
		
		ant.jar(
				compress:true,
				jarfile:distdir + name + ".jar",
				manifest:metainfdir + "\\MANIFEST.MF"
			   ){
			   fileset(dir:classdir)
			   }
		println "Build Completed For EJB Project " + name
	}
}

Initial URL
ejbbuilder

Initial Description
Builds EJB Jar using AntBuilder

Initial Title
EJB Builder Using Groovy AntBuilder

Initial Tags

                                

Initial Language
Groovy