ant打包成jar文件代码片段
<target name="jar" depends="compile" description="Create jar and MANIFEST.MF">
<!-- create a property containing all .jar files, prefix lib/, and seperated with a space -->
<pathconvert property="libs.project" pathsep=" ">
<mapper>
<chainedmapper>
<!-- remove absolute path -->
<flattenmapper />
<!-- add lib/ prefix -->
<globmapper from="*" to="lib/*" />
</chainedmapper>
</mapper>
<path>
<!-- lib.home contains all jar files, in several subdirectories -->
<fileset dir="${lib.home}">
<include name="**/*.jar" />
</fileset>
</path>
</pathconvert>
<!-- create the jar -->
<jar jarfile="${jar.name}" basedir="${build.home}">
<!-- define MANIFEST.MF -->
<manifest>
<attribute name="Built-By" value="${user.name}" />
<attribute name="Main-Class" value="com.chenlb.demo.jetty.JettyEmbedServer" />
<section name="common">
<attribute name="Specification-Title" value="${component.name}" />
<attribute name="Specification-Version" value="${component.version}" />
<attribute name="Specification-Vendor" value="${component.vendor}" />
<attribute name="Implementation-Title" value="${component.name}" />
<attribute name="Implementation-Version" value="${component.version} ${TODAY}" />
<attribute name="Implementation-Vendor" value="${component.vendor}" />
</section>
<!-- finally, use the magically generated libs path -->
<attribute name="Class-Path" value="${libs.project}" />
</manifest>
</jar>
</target>