ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yyy Xxx <gj...@yahoo.com>
Subject RE: applying mappers to fileset
Date Tue, 24 Sep 2002 20:25:05 GMT
I second this wish.  I'd like to see fileset have a mapper element
which mapped includes, excludes and/or refid'd filesets.

Consider a build that puts files *and their MD5 checksums* into a ZIP. 
It creates and populates a fileset which is passed to the checksum
task.  The same fileset is then passed to the zip task.  What about the
*.MD5 files?   The zip task should receive two filesets: the source
fileset; and the source fileset globbed from "*" to "*.MD5".



My solution is to populate the second set in a Jython script:

---- mappedfileset.py ----
def getRef(prop):
	return project.getReferences().get(prop)

inputfileset  = getRef(map_inputfileset)
outputfileset = getRef(map_outputfileset)
mapper        = getRef(map_mapper).getImplementation()

scanner = inputfileset.getDirectoryScanner(project)

scanner.scan()

for name in scanner.getIncludedFiles():
  mappedNames = mapper.mapFileName(name)
  if mappedNames is not None:
  	for n in mappedNames: outputfileset.createInclude().setName(n)

outputfileset.getDirectoryScanner(project).scan()
------------


And to have this in my build:

  <fileset id="images.fileset" dir="${images.dir}">
     ... includes / excludes ...
  </fileset>

  <mapper type="glob" from="*" to="*.MD5" id="md5-glob"/>
  <fileset id="checksum.fileset" dir="${images.dir}"/>

  <property name="map_inputfileset" value="images.fileset"/>
  <property name="map_outputfileset" value="checksum.fileset"/>
  <property name="map_mapper" value="md5-glob"/>
  <script language="jpython"
src="${script-source.dir}/mappedFileSet.py"/>
  ...
  <zip destfile="${image-zip.location}" compress="no">
     <fileset refid="images.fileset"/>
     <fileset refid="checksum.fileset"/>
  </zip>









-----Original Message-----
I guess I'd like to create a new fileset from an old one.  I'd like to
use
foreach on the new fileset (or the 'right' side of the map, no longer
care about
the left).  I don't think the perforce tasks support wildcards, so I
thought I
could iterate through a fileset, but I need to flatten the filenames. 

dM

-----Original Message-----
From: Erik Hatcher [mailto:jakarta-ant@ehatchersolutions.com]
Sent: Tuesday, September 24, 2002 3:45 PM
To: Ant Users List
Subject: Re: applying mappers to fileset


No.  That doesn't really make sense in a general sense, at least to me.

  A fileset is a set of existing files, so mapping them doesn't
preserve 
that meaning.

Mappers are associated directly with several tasks, such as <copy>.

What do you have in mind specifically?

		 Erik


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com

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


Mime
View raw message