Ant-如何获取所有文件';指定文件夹中的名称
这是我生成jar包的Ant脚本。对于manifest类Path属性,我有很多jar包,它们都在一个特定的文件夹中 我不想硬编码,我怎样才能自动得到它们Ant-如何获取所有文件';指定文件夹中的名称,ant,Ant,这是我生成jar包的Ant脚本。对于manifest类Path属性,我有很多jar包,它们都在一个特定的文件夹中 我不想硬编码,我怎样才能自动得到它们 <jar jarfile="${client_deploy_dir}/HelloWorld.jar" basedir="${client_work_dir}/compiled"> <manifest> <attribute name="Main-Class" value="HelloWor
<jar jarfile="${client_deploy_dir}/HelloWorld.jar"
basedir="${client_work_dir}/compiled">
<manifest>
<attribute name="Main-Class" value="HelloWorld.Main"/>
<attribute name="Class-Path" value="???"/>
</manifest>
</jar>
谢谢查看ant任务。您可以使用它将现有文件集扩展为文件列表 如果您的思路正确,请使用manifestclasspath任务。jarfile属性用于创建指向文件集中包含的jar的相对链接
<manifestclasspath property="jar.classpath" jarfile="${client_work_dir}/HelloWorld.jar">
<classpath>
<fileset name="" dir="${client_work_dir}/lib" includes="*.jar"/>
</classpath>
</manifestclasspath>
<jar jarfile="${client_deploy_dir}/HelloWorld.jar" basedir="${client_work_dir}/compiled">
<manifest>
<attribute name="Main-Class" value="HelloWorld.Main"/>
<attribute name="Class-Path" value=""${jar.classpath}"/>
</manifest>
</jar>
是的,pathconvert确实帮助了我。我设置了属性pathsep=“${line.separator}lib/”。不需要pathconvert。manifestclasspath任务能够生成指向最终JARFilePath的相对链接。在Ant 1.9.4上测试此解决方案时,我发现错误“manifestclasspath不支持嵌套的“fileset”元素。”@Sèb Thx,我的错。我已经更正了这个示例,以包含“classpath”标记。