Here is my Ant script for generating jar package. I have bunch of jar packages for manifest Class-Path attribute, they are all in an specific folder.
I don't want to hard code it, how can I get them automatically?
<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>
Thanks
You're on the right track, use manifestclasspath task. The jarfile attribute is used to create relative links to the jars contained in the fileset.
<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>
Check out the ant pathconvert task. You can use this to expand an existing fileset into a list of files.
精彩评论