|
View:
New views
11 Messages
—
Rating Filter:
Alert me
|
|
|
regexp-type <mapper> doesn't work as expected/(advertised?)Hello,
Take this example: ---- build@build ~ $ cat build.xml <project name="testme" default="doit" basedir="."> <target name="check"> <uptodate property="noneed"> <srcfiles dir="." includes="t.xml"/> <mapper type="regexp" from="xml$" to="txt"/> </uptodate> </target> <target name="doit" depends="check" unless="noneed"> <copy file="t.xml" tofile="t.txt" overwrite="true"/> </target> </project> ---- Say that t.txt doesn't exist. The first time the file is run, then it is created. So far, so good, that's what is expected. But the second time, it is _also_ executed, and that is totally unexpected. This has been verified with ant 1.6.5 and ant 1.7.1. If I run ant -v, here's what I see in the output: --- check: [uptodate] t.xml added as txt doesn't exist. ---- Uh! -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: regexp-type <mapper> doesn't work as expected/(advertised?)On 2009-10-09, Francis GALIEGUE <fge@...> wrote:
> <project name="testme" default="doit" basedir="."> > <target name="check"> > <uptodate property="noneed"> > <srcfiles dir="." includes="t.xml"/> > <mapper type="regexp" from="xml$" to="txt"/> > </uptodate> > </target> means map anything that ends with "xml" to "txt" - no prefix here. > Say that t.txt doesn't exist. The first time the file is run, then it > is created. So far, so good, that's what is expected. > run ant -v, here's what I see in the output: > --- > check: > [uptodate] t.xml added as txt doesn't exist. > ---- Note it says "txt", not "t.txt". You want <mapper type="regexp" from="(.*)xml$" to="\1txt"/> or even just <mapper type="glob" from="*.xml" to="*.txt"/> Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: regexp-type <mapper> doesn't work as expected/(advertised?)On Mon, Oct 12, 2009 at 07:00, Stefan Bodewig <bodewig@...> wrote:
> On 2009-10-09, Francis GALIEGUE <fge@...> wrote: > >> <project name="testme" default="doit" basedir="."> > >> <target name="check"> >> <uptodate property="noneed"> >> <srcfiles dir="." includes="t.xml"/> >> <mapper type="regexp" from="xml$" to="txt"/> >> </uptodate> >> </target> > > means map anything that ends with "xml" to "txt" - no prefix here. > Err, so what? A regex isn't supposed to match its whole input! -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: regexp-type <mapper> doesn't work as expected/(advertised?)On Mon, Oct 12, 2009 at 08:26, Francis GALIEGUE <fge@...> wrote:
> On Mon, Oct 12, 2009 at 07:00, Stefan Bodewig <bodewig@...> wrote: >> On 2009-10-09, Francis GALIEGUE <fge@...> wrote: >> >>> <project name="testme" default="doit" basedir="."> >> >>> <target name="check"> >>> <uptodate property="noneed"> >>> <srcfiles dir="." includes="t.xml"/> >>> <mapper type="regexp" from="xml$" to="txt"/> >>> </uptodate> >>> </target> >> >> means map anything that ends with "xml" to "txt" - no prefix here. >> > > Err, so what? A regex isn't supposed to match its whole input! > Let me be more precise about that. If I: echo t.xml | sed 's,xml$,txt' I get t.txt as an output. As expected. I know that Java's .matches() method on a String is a misnomer (it tries and matches the whole input, unlike what its name says, because /xml$/ DOES match t.xml), but I though that ant wouldn't make this error... -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: regexp-type <mapper> doesn't work as expected/(advertised?)On Mon, Oct 12, 2009 at 08:40, Francis GALIEGUE <fge@...> wrote:
[...] > > Let me be more precise about that. > > If I: > > echo t.xml | sed 's,xml$,txt' > > I get t.txt as an output. As expected. > > I know that Java's .matches() method on a String is a misnomer (it > tries and matches the whole input, unlike what its name says, because > /xml$/ DOES match t.xml), but I though that ant wouldn't make this > error... > [that should have been 's,xml$,txt,', with an ending comma, but the argument still stands] I should add that ant-contrib's <propertyregex> does not suffer from this problem. I know this since in another build system of mine, I don't use the regex mapper as I didn't know about it at the time, and it seems that I'll stick with it... -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
scriptconditionHi,
How can I write a scriptcondition macro? Eg. <scriptdef name="myscriptcondition" language="beanshell"> </scriptdef> <if> <myscriptcondition/> <then> Thanks |
|
|
Re: regexp-type <mapper> doesn't work as expected/(advertised?)On 2009-10-12, Francis GALIEGUE <fge@...> wrote:
> On Mon, Oct 12, 2009 at 07:00, Stefan Bodewig <bodewig@...> wrote: >> On 2009-10-09, Francis GALIEGUE <fge@...> wrote: >>> <project name="testme" default="doit" basedir="."> >>> <target name="check"> >>> <uptodate property="noneed"> >>> <srcfiles dir="." includes="t.xml"/> >>> <mapper type="regexp" from="xml$" to="txt"/> >>> </uptodate> >>> </target> >> means map anything that ends with "xml" to "txt" - no prefix here. > Err, so what? A regex isn't supposed to match its whole input! Not in general, but what I described is how the regex mapper works and how it is documented to work. The target file name is constructed from the to pattern exclusively. Any not-matched part of the file name or any part not explicitly added to the target file name via group references will be ignored. This may not be what you expected, but it is how the mapper works. Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: regexp-type <mapper> doesn't work as expected/(advertised?)On Fri, Oct 16, 2009 at 06:20, Stefan Bodewig <bodewig@...> wrote:
[...] > >> Err, so what? A regex isn't supposed to match its whole input! > > Not in general, but what I described is how the regex mapper works and > how it is documented to work. The target file name is constructed from > the to pattern exclusively. Any not-matched part of the file name or > any part not explicitly added to the target file name via group > references will be ignored. > > This may not be what you expected, but it is how the mapper works. > I then suggest that the documentation be reviewed to say that the regex must match all the filename. Simply telling "if the file name matches the regex in from" is misleading. -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: regexp-type <mapper> doesn't work as expected/(advertised?)On 2009-10-16, Francis GALIEGUE <fge@...> wrote:
> On Fri, Oct 16, 2009 at 06:20, Stefan Bodewig <bodewig@...> wrote: > [...] >>> Err, so what? A regex isn't supposed to match its whole input! >> Not in general, but what I described is how the regex mapper works and >> how it is documented to work. The target file name is constructed from >> the to pattern exclusively. Any not-matched part of the file name or >> any part not explicitly added to the target file name via group >> references will be ignored. >> This may not be what you expected, but it is how the mapper works. > I then suggest that the documentation be reviewed to say that the > regex must match all the filename. This is not really true, it doesn't matter whether the match is all of the file name or only part of it, the key is that the to attribute provides the target file name and nothing else - in particular not parts of the source file name that are not matched. The documentation currently says ,---- | If the source file name matches the from pattern, the target file name | will be constructed from the to pattern, using \0 to \9 as | back-references for the full match (\0) or the matches of the | subexpressions in parentheses. `---- If you can come up with a clearer way to say what the target file name is going to be, I'll happily change the wording. Cheers Stefan --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: regexp-type <mapper> doesn't work as expected/(advertised?)On Wed, Oct 21, 2009 at 08:33, Stefan Bodewig <bodewig@...> wrote:
[...] > >> I then suggest that the documentation be reviewed to say that the >> regex must match all the filename. > > This is not really true, it doesn't matter whether the match is all of > the file name or only part of it, the key is that the to attribute > provides the target file name and nothing else - in particular not parts > of the source file name that are not matched. > > The documentation currently says > > ,---- > | If the source file name matches the from pattern, the target file name > | will be constructed from the to pattern, using \0 to \9 as > | back-references for the full match (\0) or the matches of the > | subexpressions in parentheses. > `---- > > If you can come up with a clearer way to say what the target file name > is going to be, I'll happily change the wording. > What about: ---- The source filename is matched, in whole or in part, by the "from" pattern. The resulting filename is built using the "to" pattern, which can use backreferences (\0, \1, ...). Warning: unlike what happens with a casual regex substitution operation (f.e. perl's "s//" operator, Java's .replaceAll(), etc), the "to" pattern here is used to construct the _whole_ resulting filename. Therefore, if you want to, for instance, replace the extension of a file with a regex mapper, you should _not_ write: from="\.old$" to=".new" but: from="'(.*)\.old$" to="\1.new" (although for this particular case, you'd probably want to use a globmapper instead). ---- -- Francis Galiegue ONE2TEAM Ingénieur système Mob : +33 (0) 683 877 875 Tel : +33 (0) 178 945 552 fge@... 40 avenue Raymond Poincaré 75116 Paris --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
AW: scriptconditionYou cant.
JavaTasks vs. <scriptdef> JavaConditions vs. -- But you could write the condition directly: JavaTasks vs. <script> JavaConditions vs. <scriptcondition> Jan <project default="hello"> <condition property="german"> <scriptcondition language="javascript"> self.setValue( java.util.Locale.getDefault() == java.util.Locale.GERMANY ); </scriptcondition> </condition> <target name="hello.de" if="german"> <echo>Guten Morgen</echo> </target> <target name="hello.en" unless="german"> <echo>Good morning</echo> </target> <target name="hello" depends="hello.de,hello.en"/> </project> >-----Ursprüngliche Nachricht----- >Von: ext-simon.steiner@... [mailto:ext-simon.steiner@...] >Gesendet: Montag, 12. Oktober 2009 11:51 >An: user@... >Betreff: scriptcondition > >Hi, > >How can I write a scriptcondition macro? >Eg. > ><scriptdef name="myscriptcondition" language="beanshell"> > ></scriptdef> > ><if> > <myscriptcondition/> > <then> > >Thanks > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free embeddable forum powered by Nabble | Forum Help |