Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
253 views
Welcome To Ask or Share your Answers For Others

1 Answer

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>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...