Ant内置任务之manifestclasspath

一、概述

        manifestclasspath是Ant1.7引入的任务,用于将path转换为适合于manifest的class-path属性。当启动程序使用非常长的路径时,这个任务通常用于解决windows上的命令行限制。通常在命令行上指定的长类路径被一个单一的列出了所有classpath应包含的jar和zip文件的class-path属性的jar文件所取代。所创建的属性值可能比每行的清单的最大72个字符长,但用<manifest>元素按Jar规范正确地包装,其中定义的属性被重新引用。

二、属性

        property:要设置的属性的名称,属性必须没有被设置过。
        jarfile:包含使用此任务将设置的属性的清单的jar文件名,文件的父目录必须存在。
        maxParentLevels:允许遍历的最大父目录数,以便从jar文件导航到路径条目,也就是从jarfile指定的文件到给定类路径的相对路径中允许的最大的“..”数目,若设置为0表示jar文件与路径条目在相同目录,默认为2。

三、简单示例

<project >
	<path id="classpath">
		<fileset dir="../../../Program Files/apache-ant-1.8.4/lib"> 
			<include name="*.jar" />
		</fileset>
	</path>

	<manifestclasspath property="jar.classpath" jarfile="acme.jar" maxparentlevels="3">
		<classpath refid="classpath"/>
	</manifestclasspath>
	<manifest file="MANIFEST.MF">
		<attribute name="Built-By" value="runner"/>
		<section name="common">
			<attribute name="Specification-Title" value="Example"/>
			<attribute name="Specification-Version" value="1.0.0"/>
			<attribute name="Specification-Vendor" value="Example Organization"/>
			<attribute name="Implementation-Title" value="common"/>
			<attribute name="Implementation-Version" value="1.0.0 "/> 
			<attribute name="Implementation-Vendor" value="Example Corp."/>
		</section>
		<section name="common/class1.class">
			<attribute name="Sealed" value="false"/>
		</section>
		
		<attribute name="Class-Path" value="${jar.classpath}" />
	</manifest>
</project>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值