ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From <Mehdi.Rakhsh...@gxs.com>
Subject Dependset not being able to use file names generated by filelist and pathconvert
Date Tue, 21 Mar 2006 19:57:37 GMT
Sorry for the long append.

 

In order to avoid listing file names multiple times I create a list of
file names using a property and use filelist and pathconvert to create
new lists. However, dependset does not seem to be able to use the
result.

 

Below is a modified copy of the relevant parts of my Ant file (along
with additional comments in all caps).

 

The directory structure looks like this:

basedir

            /schema

                        *.map files are here

                        /Base

                                    Some .xsd files

                        /Entity

                                    Some .xsd files

 

 

 

   <property name="schemas" value="

       Base/a.xsd,

       Entity/b.xsd

   " />

 

   <patternset id="schemaFiles" >

      <include name="${schemas}" />

   </patternset>

 

   <target name="init" >

 

      <filelist

         id="schemaFileList"

         dir="${basedir}/schema"

         files="${schemas}" />

 

      <pathconvert

         property="mapFiles"

         refid="schemaFileList" >

         <mapper type="glob" from="*.xsd" to="*.map" />

         <map from="${basedir}\schema\Base\" to="" />

         <map from="${basedir}\schema\Entity\" to="" />

      </pathconvert>

 

<!-- mapFiles NOW CONTAINS A SEMICOLON DELIMETED LIST OF .map FILE NAMES
WITH NO PATH -->

 

  </target>

 

 

   <target name="schemadependency" depends="init" >

 

      <echo message="${mapFiles}" />

      <!-- If any of the target files is out of date compared with

           the source files, we want all the target files to be deleted.

           Once the target files are deleted we use an available task

           to set a flag that forces the schemas to be built. Note that

           this works only if one of the schema files is updated, it
does

           not work if some of the map files are missing but at least

           one exists and is more up to date than the source files.

      -->

      <dependset>

         <srcfileset dir = "${basedir}/schema" >

            <patternset refid="schemaFiles" />

         </srcfileset>

         <targetfileset dir = "${basedir}/schema"

            includes="${mapFiles}" >

         </targetfileset>

      </dependset>

 

      <available property="noNewSchema"

         file="${basedir}/schema/a.map" />

 

<!-THE ABOVE DEPENDSET SAYS DELETING ALL TARGET FILES BUT DOES NOT
DELETE ANY -->

 

 

   </target>

 

   <target name="schema2java" >

      <schema.macro schemafile="${schemaFileName}" />

   </target>

 

   <target name="schema" depends="schemadependency" unless="noNewSchema"
>

      <echo message="Converting schema to java..." />

      <!--

         If one of the schema files is changed, we delete

         all the map files and rebuild them all.

         For each schema file, call the task schema2java

      -->

 

      <delete dir="${basedir}/schema/com" includeemptydirs="true" />

      <delete>

         <fileset dir="${basedir}/schema" includes="*.map" />

      </delete>

 

      <foreach list="${schemas}" trim="true" delimiter=","

         target="schema2java" param="schemaFileName" />

   </target>

 

When I run the target schema, I get:

 

Detected Java version: 1.4 in: C:\Tools\j2sdk1.4.2_09\jre

Detected OS: Windows XP

...

 

init:

[pathconvert] Set property mapFiles = a.map;b.map

...

 

schemadependency:

     [echo] a.map;b.map

[dependset] Deleting all target files.   << THIS SHOULD BUT DOES NOT
DELETE THE MAP FILES.

[available] Found: schema\a.map

 

schema:

Skipped because property 'noNewSchema' set.

 

 

BTW, I am open to any suggestions to simplify this.

 

Thanks,

Mehdi Rakhshani

 


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message