Ant自动打包配置

<?xmlversion="1.0"encoding="UTF-8"?>

<projectname="my_ebo"basedir="."default="package-jar">

<propertyname="my_ebw.name"value="my_ebw"/>

<propertyname="src.dir"value="src/main/java"/>

<propertyname="lib.dir"value="lib"/>

<propertyname="classes.dir"value="bin"/>

<propertyname="my_ebw.webapp.lib.dir"value="../${my_ebw.name}/WebRoot/WEB-INF/lib"/>

<propertyname="build.dir"value="build"/>

<propertyname="dist.dir"value="dist"/>

<!--DEFINEPROJECTCLASSPATH-->

<pathid="project.classpath">

<filesetdir="${lib.dir}">

<includename="**/*.jar"/>

</fileset>

<pathelementlocation="${classes.dir}"/>

</path>

<targetname="prepare">

<echomessage="makessuretheneededdirectorystructureisinplace..."/>

<echomessage="deletebuildfolder"/>

<deletedir="${build.dir}"/>

<echomessage="createbuildanddistfolder"/>

<mkdirdir="${build.dir}"/>

<mkdirdir="${dist.dir}"/>

</target>

<!--Compilejavasrc-->

<targetname="compile"depends="prepare"

description="Compilemainsourcetreejavafilesintoclassfiles">

<echomessage="compilejavasrc..."/>

<javacdestdir="${build.dir}"fork="true"source="1.5"target="1.5"encoding="utf-8"

debug="false"deprecation="false"optimize="false"failonerror="true">

<srcpath="${src.dir}"/>

<classpathrefid="project.classpath"/>

</javac>

</target>

<!--Packagejarfile-->

<targetname="package-jar"description="Generatejarfiles"depends="compile">

<echo>copyormfiles...</echo>

<copytodir="${build.dir}"overwrite="true"includeemptydirs="false">

<filesetdir="${src.dir}">

<includename="**/*"/>

</fileset>

</copy>

<echo>packtojarfile...</echo>

<jarjarfile="${dist.dir}/${name}.jar"compress="true">

<filesetdir="${build.dir}">

<includename="**/*"/>

</fileset>

</jar>

<echo>copymy_ebo.jartomy_ebw/WebRoot/WEB-INF/lib...</echo>

<copytodir="${my_ebw.webapp.lib.dir}"overwrite="true"includeemptydirs="false">

<filesetdir="${dist.dir}">

<includename="my_ebo.jar"/>

</fileset>

</copy>

<deletedir="${build.dir}"/>

</target>

</project>

相关推荐