Ant - how to get the name of all files in a specific folder

Here is my Ant script for creating a jar package. I have a bunch of jar packages for the Class-Path attribute for the manifest, they are all in a specific folder.

I don’t want to hardcode 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

+2
source share
2 answers

You are on the right track, use the manifestclasspath task. The jarfile attribute is used to create relative references to banks contained in a set of files.

 <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> 
+2
source

Check out ant pathconvert . You can use this to expand an existing set of files into a list of files.

0
source

Source: https://habr.com/ru/post/906187/


All Articles