ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicolas Girard <Nicolas.Gir...@IReS.in2p3.fr>
Subject Re: Apply task and missing directories
Date Sun, 25 Jul 2004 14:30:00 GMT
On Wed, Jul 21, 2004 at 09:27:14AM -0500, Dominique Devienne wrote:
> 
> Interesting. Sounds like you could do it with Ant-Contrib's <for> which can
> accept a <fileset> to iterate on (I think), then <dirname> to extract the
> directory, then Ant-Contrib's <propertyregexp> to simulate the mapper, then
> <mkdir> to create the re-parented directory name.
> 
> Another option might be to use Ant-Contrib's <outofdate> with your fileset
> as source file, and a mapper that extracts either the target .png file, or
> if possible directly the target directory of the .png, and then does a <for>
> over these directories. In theory, we'd loop only over the directory you
> need to add, by extracting the out-of-date target files (with <outofdate>
> allows you to do).
> 
> The last option is to write a <script>, which wouldn't be very difficult.
> 
> A long time ago, I proposed (and used coded) allowing to pass a <dirset> to
> <mkdir>, but this wasn't accepted. If <mkdir> accepted a <dirset>,
with a
> nested mapper, then you'd have a ready made solution ;-)
> 
> None of the above has been tested. Just my thoughts on what I'd try in your
> shoes. --DD
> 
Dominique,
many thanks for your thoughts !

I examined the possible solutions, and it appeared that the key point is
to generate the png images in-place first, then moving them to the
desired directory, thereby using the ability of the <move> task to
create directories recursively on-the-fly.

For those who'd be interested, here's a general-purposed <dia2png>
macro, intended to be called against :
- a 'dir' directory containing dia diagrams, say:

    dir
     |_a
       |_dummy.txt
       |_diagram1.dia
       \_diagram2.dia

- a 'todir' directory where the generated png images will take place:

    dir
     |_a
       |_diagram1.png
       \_diagram2.png

The macro takes care of ignoring the diagrams that have not changed since the last generation.

Cheers,
Nicolas


------------------

                <macrodef name="dia2png">
                  <attribute name="dir"/>
                  <attribute name="todir"/>
                  <sequential>
                    <mkdir dir="@{todir}"/>
                    <apply executable="dia" dest="@{todir}">
                      <arg value="-e"/>
                      <targetfile/>
                      <srcfile/>
                      <fileset dir="@{dir}" includes="**/*.dia">
                        <modified/>
                      </fileset>
                      <mapper type="glob" from="*.dia" to="*.png"/>
                    </apply>
                    <move todir="@{todir}">
                      <fileset dir="@{dir}">
                        <include name="**/*.png"/>
                      </fileset>
                    </move>
                  </sequential>
                </macrodef>
                
                <target name="GenerateImagesFromDiaDiagrams">
                    <dia2png dir="${src.design}" todir="${build.design}"/>
                </target>



---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Mime
View raw message