You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Kevin Duffey <KD...@castironsys.com> on 2004/07/06 21:53:57 UTC
Jar task blues
Hey all,
I am trying to build a jar file that may or may not have some dirs under the directory I want to jar up. Some might have the config dir, some might not. I am using a taskdef loop that I created which for brevity, just know that it works. It passes in each dir I want to jar up as separate jars. Each dir passed in is the root dir. Below it I have classes, src, config, lib and properties. The last three dirs are there some of the time, sometimes not. Using my loop task, I can provide a comma separated list of paths to jar up so that I don't have to write several <jar..> tasks. In fact, I use this loop in the compile, init, clean and javadoc tags as well so I can simply add a path to this one property, and the entire build process works. So far it all works except this issue with jarring.
The problem is, if the config, properties or lib dir is not present, the build fails. Now, I have used patternset, used available and if checks and all that. It works for the most part, but my main problem is, I want to include the /config, /properties and /lib stuff in the ROOT dir of the jar file. If I do:
<zipfileset dir="${module.path.dir}/properties" prefix="">
<...
</zipfileset>
this fails because if the /properties is NOT present, it breaks the build. <zipfileset, doesn't support the if call directly. By using the <fileset> or <patternset> approach, it almost works:
<available property="properties.present" type="dir" file="${module.path.dir}/properties"/>
<available property="config.present" type="dir" file="${module.path.dir}/config"/>
<fileset dir="${module.path.dir}">
<include name="**/properties/**" if="properties.present"/>
<include name="**/config/**" if="config.present"/>
</fileset>
Now, this works fine, but the files are found in the /config, and /properties inside the JAR. which I can't have. I need them to be at the root but yet still ONLY included IF the dir they reside at is present.
Can anyone provide some help on this? I seem to be almost there, just missing some key ingredient to get it to work.
Thanks.