lib下面的包不分子目录:
<project default="jar" name="Acid">
<!-- 工程目录结构
project
|-bin
|-src
|-lib
|-out
|-build.xml
-->
<property name="lib.dir" value="lib" />
<property name="src.dir" value="src" />
<property name="config.dir" value="config" />
<property name="output.dir" value="build" />
<property name="classes.dir" value="${output.dir}/classes" />
<property name="out.config.dir" value="${output.dir}/config" />
<property name="jarname" value="run_persit_engine.jar" />
<property name="mainclass" value="com.tydic.entrance.HFileGeneratorEntrance" />
<!-- 第三方jar包的路径 -->
<path id="lib-classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- 1. 初始化工作,如创建目录等 -->
<target name="init">
<delete dir="${classes.dir}" />
<delete dir="${output.dir}" />
<delete dir="${out.config.dir}" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${output.dir}" />
<mkdir dir="${out.config.dir}" />
</target>
<!-- 2. 编译 -->
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="on">
<compilerarg line="-encoding UTF-8" />
<classpath refid="lib-classpath" />
</javac>
</target>
<!-- 3. 打包jar文件 -->
<target name="jar" depends="compile">
<copy todir="${output.dir}/lib">
<!-- 将要打的jar复制进去 -->
<fileset dir="${lib.dir}" includes="**/hive-*.jar" />
<fileset dir="${lib.dir}" includes="**/mysql-*.jar" />
<!-- hbase -->
<fileset dir="${lib.dir}" includes="**/hbase-*.jar" />
<fileset dir="${lib.dir}" includes="**/htrace-core-*.jar" />
<!-- spring_ibatis -->
<fileset dir="${lib.dir}" includes="**/aspectjweaver-*.jar" />
<fileset dir="${lib.dir}" includes="**/spring.jar" />
<fileset dir="${lib.dir}" includes="**/cglib-nodep-*.jar" />
<fileset dir="${lib.dir}" includes="**/ibatis-*.jar" />
<!--将配置文件复制到build/config下,集群的配置文件hdfs-site.xml、core-site.xml等文件不打进jar中-->
</copy>
<copy todir="${out.config.dir}">
<fileset dir="${config.dir}" excludes="*-site.xml"/>
</copy>
<!--用于在MANIFEST.MF中标明classpath,
Create a property containing all .jar files,
prefix lib/, and seperated with a space-->
<pathconvert property="mf.classpath" pathsep=" ">
<mapper>
<chainedmapper>
<!-- jar包文件只留文件名,去掉目录信息 -->
<flattenmapper />
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*" />
</chainedmapper>
</mapper>
<path refid="lib-classpath" />
</pathconvert>
<!-- jar文件的输出路径 -->
<jar destfile="${output.dir}/${jarname}" basedir="${classes.dir}">
<manifest>
<attribute name="Main-class" value="${mainclass}" />
<attribute name="Class-Path" value="${mf.classpath}" />
</manifest>
<fileset dir="${out.config.dir}" includes="**/*" />
<fileset dir="${output.dir}" includes="lib/*" />
</jar>
</target>
</project>
-------------------------------------------------------------------------------------------------------------------------------------------------------------
lib下面的包分子目录:
<project default="jar" name="Acid">
<!-- 工程目录结构
project
|-bin
|-src
|-lib
|-config
|-build.xml
-->
<property name="lib.dir" value="lib" />
<property name="src.dir" value="src" />
<property name="config.dir" value="config" />
<property name="output.dir" value="build" />
<property name="classes.dir" value="${output.dir}/classes" />
<property name="out.config.dir" value="${output.dir}/config" />
<property name="jarname" value="run_persit_engine.jar" />
<property name="mainclass" value="com.tydic.entrance.HFileGeneratorEntrance" />
<!-- 第三方jar包的路径 -->
<path id="lib-classpath">
<fileset dir="${lib.dir}">
<include name="**/*.jar" />
</fileset>
</path>
<!-- 1. 初始化工作,如创建目录等 -->
<target name="init">
<delete dir="${classes.dir}" />
<delete dir="${output.dir}" />
<delete dir="${out.config.dir}" />
<mkdir dir="${classes.dir}" />
<mkdir dir="${output.dir}" />
<mkdir dir="${out.config.dir}" />
</target>
<!-- 2. 编译 -->
<target name="compile" depends="init">
<javac srcdir="${src.dir}" destdir="${classes.dir}" includeantruntime="on">
<compilerarg line="-encoding UTF-8" />
<classpath refid="lib-classpath" />
</javac>
</target>
<!-- 3. 打包jar文件 -->
<target name="jar" depends="compile">
<copy todir="${output.dir}/lib">
<!-- 将要打的jar复制进去 -->
<fileset dir="${lib.dir}/hive" includes="hive-*.jar" />
<fileset dir="${lib.dir}/common" includes="mysql-*.jar" />
<!-- hbase -->
<fileset dir="${lib.dir}/hbase" includes="hbase-*.jar" />
<fileset dir="${lib.dir}/hbase" includes="htrace-core-*.jar" />
<!-- spring_ibatis -->
<fileset dir="${lib.dir}/spring" includes="aspectjweaver-*.jar,spring.jar,cglib-nodep-*.jar,ibatis-*.jar" />
<!--将配置文件复制到build/config下,集群的配置文件hdfs-site.xml、core-site.xml等文件不打进jar中-->
</copy>
<copy todir="${out.config.dir}">
<fileset dir="${config.dir}" excludes="*-site.xml"/>
</copy>
<!--用于在MANIFEST.MF中标明classpath,
Create a property containing all .jar files,
prefix lib/, and seperated with a space-->
<pathconvert property="mf.classpath" pathsep=" ">
<mapper>
<chainedmapper>
<!-- jar包文件只留文件名,去掉目录信息 -->
<flattenmapper />
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*" />
</chainedmapper>
</mapper>
<path refid="lib-classpath" />
</pathconvert>
<!-- jar文件的输出路径 -->
<jar destfile="${output.dir}/${jarname}" basedir="${classes.dir}">
<manifest>
<attribute name="Main-class" value="${mainclass}" />
<attribute name="Class-Path" value="${mf.classpath}" />
</manifest>
<fileset dir="${out.config.dir}" includes="**/*" />
<fileset dir="${output.dir}" includes="lib/*" />
</jar>
</target>
</project>