标签:build ant
1)使用ant进行jar的打包
<native2ascii src="${project.root}" dest="${prop.tmp}" includes="build.properties" />
<property file="${prop.tmp}/build.properties"/>
<!-- Java编译CLASSPATH -->
<path id="master-classpath">
<fileset dir="${build.lib.dir}"/>
<fileset dir="${build.extlib.dir}"/>
<fileset file="${weblogic.jar}"/>
<fileset file="${javaee.jar}"/>
</path>
<target name="clean" description="清空所有输出文件包括build和部署目录">
<property name="build.classes.dir" value="${build.dir}/classes" />
<property name="build.test.dir" value="${build.dir}/test" />
<delete dir="${build.classes.dir}"/>
<delete dir="${build.test.dir}"/>
<delete dir="${deploy.exploded.dir}"/>
<delete dir="${rel.dir}"/>
<delete dir="${pubjar.dir}"/>
<delete file="${deploy.ear.dir}/${project.name}.ear"/>
<delete dir="${build.dir.risk}" />
<delete dir="${build.classes.dir.risk}" />
<delete file="${deploy.ear.dir}/${project.name}-app.jar" />
</target>
<target name="compile" description="编译Java文件" depends="init,info">
<available classname="xx.xx.PafaCoreContexton" classpathref="master-classpath" property="lib.present"/>
<fail unless="lib.present" message="给出的提示说明..." />
<javac destdir="${build.classes.dir}" target="1.6" debug="true" encoding="UTF-8"
deprecation="false" optimize="false" failonerror="true">
<src path="${src.java.dir}/com"/>
<classpath refid="master-classpath"/>
</javac>
<unzip dest="${build.classes.dir}">
<fileset dir="${extlib.dir}">
<include name="**/forkjoin_support.jar"/>
</fileset>
</unzip>
<delete includeEmptyDirs="true">
<fileset dir="${build.classes.dir}">
<include name="**/*.java"/>
</fileset>
</delete>
<!-- copy converter properties -->
<copy todir="${build.classes.dir}">
<fileset dir="${src.java.dir}" includes="**/converter/**/*.properties" />
</copy>
</target>
<target name="jar-prdTemplate" description="将产品模板打包">
<jar destfile="${pubjar.dir}/product-template.jar" >
<fileset dir="${src.jsp.dir}">
<include name="prdTemplate/**/*.*" />
</fileset>
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Specification-Version" value="${project.revision}" />
</manifest>
</jar>
</target>
<!-- 创建产品组件的jar包 -->
<target name="sdk-jar" depends="clean,compile" description="创建产品组件的jar包">
<!-- 创建目录 -->
<mkdir dir="${deploy.exploded.dir}/jar"/>
<!-- 创建class的内容 -->
<copy todir="${deploy.exploded.dir}/jar">
<fileset dir="${build.classes.dir}/">
<include name="**/product/config/dto/**"/>
<include name="**/product/support/remotecache/dto/**"/>
<include name="**/product/common/util/**"/>
<include name="**/product/common/PRODConstants.class"/>
<include name="**/product/dto/**"/>
</fileset>
</copy>
<copy todir="${deploy.exploded.dir}/jar/com/paic/product/engine">
<fileset dir="${build.classes.dir}/com/paic/product/engine/">
<exclude name="biz/service/impl/PreProductPojoService.class"/>
</fileset>
</copy>
<copy todir="${deploy.exploded.dir}/jar/com/paic/product/support/localcache">
<fileset dir="${build.classes.dir}/com/paic/product/support/localcache/">
</fileset>
</copy>
<copy todir="${deploy.exploded.dir}/jar">
<fileset dir="${src.java.dir}/">
<include name="**/product/config/dto/**"/>
<include name="**/product/support/cache/**"/>
<include name="**/product/support/remotecache/dto/**"/>
<include name="**/product/common/util/**"/>
<include name="**/product/common/ProdRemoteCacheDataSourceDAO.java"/>
<include name="**/product/dto/**"/>
</fileset>
</copy>
<copy todir="${deploy.exploded.dir}/jar/com/paic/product/engine">
<fileset dir="${src.java.dir}/com/paic/product/engine/">
<exclude name="biz/action/CacheProductTemplateAction.java"/>
<exclude name="biz/service/impl/ProdTmplRCPojoService.java"/>
</fileset>
</copy>
<copy todir="${deploy.exploded.dir}/jar/com/paic/product/support/localcache">
<fileset dir="${src.java.dir}/com/paic/product/support/localcache/">
<exclude name="provider/**"/>
<exclude name="dao/impl/**"/>
</fileset>
</copy>
<!-- 复制sqlmap -->
<copyfile src="${src.config.dir}/biz/sqlmap-mapping-product.xml"
dest="${deploy.exploded.dir}/jar/sqlmap-mapping-product.xml" />
<copyfile src="${src.config.dir}/core/context-product-personal-dict.properties"
dest="${deploy.exploded.dir}/jar/context-product-personal-dict.properties" />
<copyfile src="${src.config.dir}/web/web-context-product.xml"
dest="${deploy.exploded.dir}/jar/WEB-INF/web-context-product.xml" />
<!-- jar文件的输出路径 -->
<jar destfile="${pubjar.dir}/ums-product-sdk.jar" basedir="${deploy.exploded.dir}/jar">
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Specification-Version" value="${project.revision}" />
</manifest>
</jar>
</target>
<target name="exploded-ear" depends="clean,compile" description="EAR应用(开发模式)">
<!-- 创建app ear包 -->
<mkdir dir="${app.ear}/META-INF"/>
<copy todir="${app.ear}">
<fileset dir="${build.classes.dir}/">
<include name="**/product/**"/>
</fileset>
<fileset dir="${src.config.dir}/core" >
</fileset>
<fileset dir="${src.config.dir}/formula" >
<include name="**/*.formula"/>
</fileset>
<fileset dir="${src.config.dir}/biz">
<exclude name="*.properties"/>
</fileset>
</copy>
<!-- 创建web ear包 -->
<mkdir dir="${web.ear}/APP-INF/classes"/>
<mkdir dir="${web.ear}/APP-INF/lib"/>
<mkdir dir="${web.ear}/META-INF"/>
<mkdir dir="${web.ear}/${project.name}.war/WEB-INF/lib"/>
<mkdir dir="${web.ear}/${project.name}.war/WEB-INF/classes"/>
<!-- 创建 web ear META-INF -->
<copyfile src="${src.config.dir}/app/application-web.xml" dest="${web.ear}/META-INF/application.xml" />
<!-- 创建APP-INF的内容,包含web层和biz层共用的class, jar, xml -->
<copy todir="${web.ear}/APP-INF/classes">
<fileset dir="${build.classes.dir}/">
<exclude name="**/web/**"/>
<exclude name="**/biz/**"/>
<exclude name="**/service/**"/>
<exclude name="**/integration/**"/>
<exclude name="**/action/**"/>
</fileset>
<fileset dir="${src.config.dir}/core">
<exclude name="devlog.properties"/>
</fileset>
</copy>
<copy todir="${web.ear}/APP-INF/lib" preservelastmodified="true">
<fileset dir="${build.lib.dir}">
<!-- 只引入产品工厂独有的包,其它依赖包共享UMS的lib -->
<include name="pfs-only.jar"/>
</fileset>
</copy>
<!-- 创建WAR的内容 -->
<copy todir="${web.ear}/${project.name}.war/WEB-INF">
<fileset dir="${src.config.dir}/web">
<exclude name="*.properties"/>
</fileset>
</copy>
<!-- MessageBundle编码转换-->
<native2ascii src="${src.config.dir}/web"
dest="${web.ear}/${project.name}.war/WEB-INF/classes" includes="*.properties"/>
<copy todir="${web.ear}/${project.name}.war/WEB-INF/classes">
<fileset dir="${build.classes.dir}/">
<include name="**/web/**"/>
</fileset>
</copy>
<copy todir="${web.ear}/${project.name}.war">
<fileset dir="${src.jsp.dir}/"/>
</copy>
</target>
标签:build ant
原文地址:http://6817977.blog.51cto.com/6807977/1825390