| Problem encountered with <mapper > | Problem encountered with <mapper > 2003-03-25 - By Dominique Devienne
Several things:
1) First, I realized the escaping of $ is wrong... The property replacement code of Ant will run without caring about the backslash, which ends up being passed as is to the regex engine. I still think though that one needs to escape the file separator for Windows, since it's the escape character of the regex pattern. 2) Second, I looked at Uptodate.java, and unlike other tasks, it passes an absolute path name (local platform file separator) to the mapper (calls File#getAbsolutePath()) 3) The replaced path name can use forward slashes instead of backslashes to simplify the to pattern (java.io.File deals with a mix of slashes just fine)
<!-- RegexFileSeparator --> <property name="rfs" value="\\"/> <!-- Windows --> <property name="rfs" value="/" /> <!-- Unix - IGNORED HERE -->
<property name="srcfiles.dir" location="${topdir}/src"/>
<path id="targetfiles.path"> <pathelement location="${topdir}/subdir" /> </path> <pathconvert property="targetfiles.dir" targetos="unix" refid="targetfiles.path" />
<uptodate> <srcfiles dir="${srcfiles.dir}"> <include name="beandir/com/foo/server/**/*Bean.java" /> </srcfiles> <mapper type="regexp" from=".*${rfs}beandir${rfs}(.*)${rfs}server${rfs}(.*)Bean.java" to="${targetfiles.dir}/\1/spi/\2Local.java" /> </uptodate>
Maybe this time this will work, but somehow I doubt it... --DD
-----Original Message----- From: Alex Zhao [mailto:azhao@(protected)] Sent: Monday, March 24, 2003 6:09 PM To: Ant Users List Subject: Re: Problem encountered with <mapper>
Nope, it doesn't work. Tried it before and tried it again just now.
-Alex ----- Original Message ----- From: "Dominique Devienne" <DDevienne@(protected)> To: "'Ant Users List'" <user@(protected)> Sent: Monday, March 24, 2003 4:01 PM Subject: RE: Problem encountered with <mapper>
> I suspect you need to escape the ${fs} which resolves to \ windows, which is > also a special character for the regex: > > <mapper type="regexp" > from="^(.*)\${fs}server\${fs}(.*)Bean.java" > to="\${gen.src.dir}\\${fs}\1\\${fs}spi\\${fs}\2Local.java"/> > > Sorry if it doesn't work. Gotta go. --DD > > -----Original Message----- > From: Alex Zhao [mailto:azhao@(protected)] > Sent: Monday, March 24, 2003 5:56 PM > To: Ant Users List > Subject: Re: Problem encountered with <mapper> > > Dominique, > > Thanks a lot for looking at this for me! Here is more detail: > > <uptodate> > <srcfiles dir="${topdir}/src"> > <include name="beandir/com/foo/server/**/*Bean.java" > /> > </srcfiles> > <mapper > type="regexp" > from="^(.*)\${fs}server\${fs}(.*)Bean.java" > > to="\${gen.src.dir}\${fs}\1\${fs}spi\${fs}\2Local.java"/> > </uptodate> > > An example would be to map C:\topdir\src\beandir\com\foo\server\BarBean.java > to > C:\topdir\subdir\com\foo\spi\BarLocal.java. > > When I ran ant with -v option, Ant complains that it cannot find > C:\topdirsubdir\com\foo\spi\BarLocal. > > Hopefully this is what you are looking for. > > -Alex > ----- Original Message ----- > From: "Dominique Devienne" <DDevienne@(protected)> > To: "'Ant Users List'" <user@(protected)> > Sent: Monday, March 24, 2003 3:45 PM > Subject: RE: Problem encountered with <mapper> > > > > Please provide an example input path, what it should be mapped to, and the > > context in which the <mapper> is used, as well as the data type (fileset?) > > used to gather the input files, with explicit value of the dir attribute > (in > > case a variable is used). Thanks, --DD > > > > -----Original Message----- > > From: Alex Zhao [mailto:azhao@(protected)] > > Sent: Monday, March 24, 2003 5:40 PM > > To: 'Ant Users List' > > Subject: Re: Problem encountered with <mapper> > > > > Thanks, but it didn't work. > > > > -Alex > > ----- Original Message ----- > > From: "Dominique Devienne" <DDevienne@(protected)> > > To: "'Ant Users List'" <user@(protected)> > > Sent: Monday, March 24, 2003 3:35 PM > > Subject: RE: Problem encountered with <mapper> > > > > > > > The first <property> must use value=, while the second should use > > > location=... Sorry about the typo. --DD > > > > > > -----Original Message----- > > > From: Dominique Devienne [mailto:DDevienne@(protected)] > > > Sent: Monday, March 24, 2003 5:32 PM > > > To: 'Ant Users List' > > > Subject: RE: Problem encountered with <mapper> > > > > > > Try > > > > > > <property name="fs" value="${file.separator}"/> > > > <property name="gen.src.dir" location="topdir/subdir"/> > > > > > > <mapper type="regexp" > > > from="^(.*)\${fs}server\${fs}(.*)Bean.java" > > > to="${gen.src.dir}\${fs}\1\${fs}spi\${fs}\2Local.java"/> > > > > > > --DD > > > > > > -----Original Message----- > > > From: Alex Zhao [mailto:azhao@(protected)] > > > Sent: Monday, March 24, 2003 5:25 PM > > > To: user@(protected) > > > Subject: Problem encountered with <mapper> > > > > > > Hi, > > > > > > I am working on a build.xml file in which I'd like to check that certain > > > dependent files are > > > up to date with respect to its source. I am using Ant 1.5.2 on Window > > 2000. > > > > > > The mapper tag essentially tries to find the generated Local interface > of > > > some EJB's. Everything seems to work > > > except a property associated with directory ${gen.src.dir}. Unless I > > > "hardcode" it, i.e., put "C:\\topdir\\subdir", nothing works. > > > > > > I tried: > > > > > > <property name="gen.src.dir" value="topdir${file.separator}subdir"/> > > > or > > > <property name="gen.src.dir" value="topdir\${file.separator}subdir"/> > > > and > > > <property name="gen.src.dir" value="topdir\\\${file.separator}subdir"/> > > > > > > In each case, the "\" between topdir and subdir gets eaten and > > consequently > > > causes the mapper not finding files it should find. > > > > > > <mapper type="regexp" > > > > > > from="^(.*)\${file.separator}server\${file.separator}(.*)Bean.java" > > > > > > > > > to="${gen.src.dir}\${file.separator}\1\${file.separator}spi\${file.separator > > > }\2Local.java"/> > > > > > > > > > Please help. > > > > > > > > > -Alex > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: user-unsubscribe@(protected) > > > For additional commands, e-mail: user-help@(protected) > > > > > > --------------------------------------------------------------------- > > > To unsubscribe, e-mail: user-unsubscribe@(protected) > > > For additional commands, e-mail: user-help@(protected) > > > > > > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@(protected) > > For additional commands, e-mail: user-help@(protected) > > > > --------------------------------------------------------------------- > > To unsubscribe, e-mail: user-unsubscribe@(protected) > > For additional commands, e-mail: user-help@(protected) > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@(protected) > For additional commands, e-mail: user-help@(protected) > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@(protected) > For additional commands, e-mail: user-help@(protected) >
--------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@(protected) For additional commands, e-mail: user-help@(protected)
|
|
 |