BitsPlayer 2011-03-03
ant打包成Jar文件及发布Ejb.若你是Ejb程序,Jboss环境变量OK,name的名称随便你自己定义。
build.xml文件代码如下:
<?xmlversion="1.0"encoding="UTF-8"?>
<projectname="EjbTwo"basedir="."><!--name生成Jar的名称-->
<propertyname="src.dir"value="${basedir}\src"></property>
<propertyenvironment="env"></property><!--定义属性-->
<propertyname="jboss.home"value="${env.JBOSS_HOME}"></property><!--JBOSS环境变量-->
<propertyname="jboss.server.config"value="default"></property>
<propertyname="build.dir"value="${basedir}\build"></property>
<pathid="build.classpath">
<filesetdir="${jboss.home}\client">
<includename="*.jar"/>
</fileset>
<pathelementlocation="${build.dir}"/>
</path>
<targetname="prepare">
<deletedir="${build.dir}"></delete>
<mkdirdir="${build.dir}"/>
</target>
<targetname="compile"depends="prepare"description="编译">
<javacsrcdir="${src.dir}"destdir="${build.dir}">
<classpathrefid="build.classpath"></classpath>
</javac>
</target>
<targetname="ejbjar"depends="compile"description="创建EJB发布包">
<jarjarfile="${basedir}\${ant.project.name}.jar">
<filesetdir="${build.dir}">
<includename="**/*.class"/>
</fileset>
<metainfdir="${src.dir}\META-INF"></metainf><!--打包(persistence.xml)文件-->
</jar>
</target>
<targetname="deploy"depends="ejbjar"description="发布ejb">
<copyfile="${basedir}\${ant.project.name}.jar"todir="${jboss.home}\server\${jboss.server.config}\deploy"></copy>
</target>
<targetname="undeploy"description="卸载ejb">
<deletefile="${jboss.home}\server\${jboss.server.config}\deploy\${ant.project.name}.jar"></delete>
</target>
</project>