当前位置: 代码迷 >> Web前端 >> Ant将多个jar封装为一个jar
  详细解决方案

Ant将多个jar封装为一个jar

热度:341   发布时间:2012-09-09 09:27:54.0
Ant将多个jar打包为一个jar

参考:http://blog.csdn.net/unetman/article/details/6721248

?

本来用Fat-jar插件试了下,结果打出来的包不行

?

修改ant脚本如下

?

<project name="common-jars-lib" default="main">

	<property name="home" value="." />
	<property name="jarname" value="common-jars-lib.jar" />

	<echo message="start ....................." />
	<target name="main" depends="jar">
		<delete dir="${home}/output/classes" />
	</target>

	<target name="clean">
		<mkdir dir="${home}/output" />
		<delete includeEmptyDirs="true">
			<fileset dir="${home}/output" includes="**/*" />
		</delete>

	</target>
	<target name="unzip" depends="clean">

		<unzip src="${home}/lib/icu4j-3.4.4.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>
		<unzip src="${home}/lib/iri-0.8.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>
		<unzip src="${home}/lib/jena-2.6.4.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>
		<unzip src="${home}/lib/log4j-1.2.13.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>
		<unzip src="${home}/lib/lucene-core-2.3.1.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>
		<unzip src="${home}/lib/slf4j-api-1.5.8.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>
		<unzip src="${home}/lib/slf4j-log4j12-1.5.8.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>
		<unzip src="${home}/lib/stax-api-1.0.1.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>
		<unzip src="${home}/lib/xercesImpl-2.7.1.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>
		<unzip src="${home}/lib/wstx-asl-3.2.9.jar" dest="${home}/output/classes/">
			<patternset>
				<exclude name="META-INF" />
				<exclude name="META-INF/MANIFEST.MF" />
			</patternset>
		</unzip>



	</target>



	<target name="jar" depends="unzip">
		<jar jarfile="${home}/output/${jarname}">
		<fileset dir="${home}/output/classes/" includes="**/*" />
		</jar>
	</target>

</project>

?

  相关解决方案