You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Scott Ellsworth <sc...@alodar.com> on 2002/08/15 07:45:28 UTC

How do I add an idref to a zipfileset?

I have been asked to put the contents of my resources directory at the 
top level.  What makes this hard is that the resources dirctory may not 
exist.

If I do:

     <jar
       jarfile="${jar.dist}/${jar.baseName}.jar"
       compress="${jar.compress}">
       <zipfileset dir="${project.work.dir}">
         <include name="resources/*" />
       </zipfileset>

on

foo
-resources
--blah.gif

the jar has
foo.jar
-resources
--blah.gif

when what i want it to have is

foo.jar
-blah.gif

I had thought I could resolve this via a clever dirset:

   <dirset id="jar.source.dirs" dir="${project.work.dir}">
     <include name="resources"/>
   </dirset>

   <target name="jar">
     <jar
       jarfile="${jar.dist}/${jar.baseName}.jar"
       compress="${jar.compress}" >
       <zipfileset dir="jar.source.dirs"/>
   </jar>

but zipfileset does not seem to accept an idref, complaining that this 
is actually a dirset.  I suppose that it is right, but my goal is to 
have zipfileset, or a plain old fileset, put my resources at the top 
level so getResource can find them, without requiring the resources 
directory to exist.

I note that
       <zipfileset dir="${project.work.dir}" prefix="..">
         <include name="resources/*" />
       </zipfileset>

puts the resources in
foo.jar
-..
--resources
---blah.gif

not quite what I had in mind...

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How do I add an idref to a zipfileset?

Posted by Scott Ellsworth <sc...@alodar.com>.
I just submitted a patch so that

>   <target name="jar-files" description="Jar files">
>     <available file="${jar.resources}" type="dir" 
> property="jar.resources.exists" />
>     <jar
>       jarfile="${jar.dist}/${jar.baseName}.jar"
>       compress="${jar.compress}" >
>       <fileset dir="${compile.classes}"/>
          <fileset dir="${jar.resources}" errorOnMissingDir="false"/>
>     </jar>
>   </target>

does what I think it should - throw errors if the dir compile.classes 
does not exist, but continue without problems if jar.resources does not 
exist.

I am not sure this satisfies everyone who posted about 11270, but it 
does seem to make at least one deal killer somewhat easier.

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: How do I add an idref to a zipfileset?

Posted by Scott Ellsworth <sc...@alodar.com>.
On Wednesday, August 14, 2002, at 10:45  PM, Scott Ellsworth wrote:

> I have been asked to put the contents of my resources directory at the 
> top level.  What makes this hard is that the resources dirctory may not 
> exist.

Further, doing

   <target name="jar-files" description="Jar files">
     <available file="${jar.resources}" type="dir" 
property="jar.resources.exists" />
     <jar
       jarfile="${jar.dist}/${jar.baseName}.jar"
       compress="${jar.compress}" >
       <fileset dir="${compile.classes}"/>
     </jar>
   </target>

   <target name="jar-resources" if="jar.resources.exists">
     <!-- icky hack, as jar only checks file timestamps in 1.5.  If they 
check internal timestamps as 1.4 did, this can be removed. -->
     <touch file="${jar.dist}/${jar.baseName}.jar" datetime="01/01/2000 
2:02 pm"/>
     <jar
       jarfile="${jar.dist}/${jar.baseName}.jar"
       update="true">
       <zipfileset dir="${jar.resources}" />
     </jar>
   </target>

   <target name="jar" depends="compile, jar-files, jar-resources, 
jar-manifest, jar-sign" description="Build jar"/>

> foo
> -resources
> --blah.gif

foo.jar
-blah.gif

as desired, but I get a rebuild on this jar with every execution.  This 
is _very_ expensive.

Is there a way to use an uptodate task to check each file against that 
in the jar, and to force a rebuild if the files do not exist?

NB, fixing 11270 would fix this for me, as I could then put all of my 
filesets in just one jar task.  Having fileset take an if would also do 
it, as then I could just ignore it.

Scott


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>