I got one thing here. I was testing the last David script on windows into a eclipse 3.3 and so I got that error..but in my linux desktop that worked well. I guess the ant version into eclipse is old. I will keep studying Ant. Thanks a lot.
2009/7/24 Júlio Cesar Bueno Cotta <[email protected]> > Thanks again! :D > That "messsage" come from your code David. :D > > I had try to run the newst code ..and I just copy and paste your code and > got this. > BUILD FAILED > bla bla bla loadresource doesn't support the nested "concat" element. > > :( > help > > 2009/7/24 David Weintraub <[email protected]> > > A few things: >> >> - You have "messsage" instead of "message" in your fail statement. >> (Three >> "s" instead of just 2). >> - In the second to the last line, you have <\target> instead of >> </target>. (This is what is causing the error message). Make sure you're >> using the fractional slash and not the backslash. >> - You are attempting to combine the <fail> statement with the >> <loadresource>. I'm not 100% sure that is possible. It is possible in >> the >> <length> condition not to give it a string, but instead use nested >> resources. Then, it might be possible to concat them, and then have the >> <length> test against that. However, even if that is successful, the >> <fail> >> statement would have nothing to print out. >> >> The best thing to do is set the property "nonreplaced.lines", so you >> have >> something to print out in the <fail> task, and then test the length of >> this >> property against the <length> condition in the <fail> task. >> >> Try this: >> >> *<?xml version="1.0"?> >> <project name="test" basedir="." default="search"> >> <property name="property.dir" value="${basedir}/test"/> >> >> <target name="search"> >> >> <!--Setting nonreplaced.lines with all lines not filled in--> >> <loadresource property="nonreplaced.lines"> >> <concat> >> <fileset dir="${property.dir}"/> >> <filterchain> >> <linecontainsregexp> >> <regexp pattern="@[\w]+@"/> >> </linecontainsregexp> >> </filterchain> >> </concat> >> </loadresource> >> >> <!-- Now test to see if "nonreplaced.lines" is not zero --> >> <fail message="Lines not >> replaced:${line.separator}${nonreplaced.lines}"> >> <condition> >> <length string="${nonreplaced.lines}" when="greater" length="0"/> >> </condition> >> </fail> >> </target> >> </project> >> * >> >> >> 2009/7/24 Júlio Cesar Bueno Cotta <[email protected]> >> >> > I am sorry, if I spent too much time to give a answer here..but I was >> busy >> > with other things.. >> > well.. >> > Thanks a lot David. >> > You gave me the answer, and a good explanation about this. >> > But..I still need some help with this.. >> > I had try to do a test with this >> > ----------------------------------------------------------------- >> > <?xml version="1.0"?> >> > <project name="test" basedir="." default="search"> >> > <property name="property.dir" value="/test/"/> >> > <target name="search"> >> > <fail messsage="Lines not replaced: ${nonreplaced.lines}"> >> > <condition> >> > <loadresource property="nonreplaced.lines"> >> > <concat> >> > <fileset dir="${property.dir}"/> >> > <filterchain> >> > <linecontainsregexp> >> > <regexp pattern="@[\w]+@"/> >> > </linecontainsregexp> >> > </filterchain> >> > </concat> >> > </loadresource> >> > <length string="${nonreplaced.lines}" when="greater" >> count="0"/> >> > </condition> >> > </fail> >> > <\target> >> > </project> >> > >> > >> ---------------------------------------------------------------------------------------------- >> > >> > I had create the directory test in the directory where I ran the script >> > ..and inside of that directory a text file with a line @test@ >> > >> > when I try to run "ant" command and I get "BUILD FAILED" :( >> > "The content of elements must consist of well-formed character data or >> > markup." >> > >> > I am really sorry..I guess I can doing something wrong too much noob. >> > Please, if someone can tell me what is wrong.. >> > Thanks all. >> > >> > 2009/7/22 David Weintraub <[email protected]> >> > >> > > Actually, I think this solution might be more of what you want. The >> first >> > > solution I gave you will only tell you that there were parameters that >> > > weren't replaced, but won't tell you which parameters weren't >> replaced. >> > > Imagine if you had 100 parameters, and you only replaced 99 of them. >> It >> > > would take you a long time to find that one parameter out of the 100 >> that >> > > didn't get replaced. >> > > >> > > This solution will actually give you the lines that weren't >> substituted: >> > > >> > > *<loadresource property="nonreplaced.lines">* >> > > * <concat>* >> > > * <fileset dir="${property.dir}"/>* >> > > * <filterchain>* >> > > * <linecontainsregexp>* >> > > * <regexp pattern="@[\w]+@"/> >> > > </linecontainsregexp> >> > > </filterchain> >> > > </concat> >> > > </loadresource> * >> > > >> > > The property *nonreplaced.lines* will now contain all the lines that >> > > weren't >> > > replaced. Thus, it would be much easier to correct the situation. >> You'd >> > > know >> > > which one you were missing. >> > > >> > > This could be put into a fail message to fail the build if any lines >> were >> > > detected: >> > > >> > > *<fail messsage="Lines not replaced: ${nonreplaced.lines}"> >> > > <condition> >> > > <length string="${nonreplaced.lines}" when=greater" count="0"/> >> > > </condition> >> > > </fail> >> > > >> > > * >> > > We (including me) really should start looking more into filterchains >> and >> > > resources. They're a bit harder to understand than standard ant tasks >> > like >> > > "copy", but they offer a lot of power. >> > > >> > > On Wed, Jul 22, 2009 at 3:40 PM, Scot P. Floess <[email protected]> >> > wrote: >> > > >> > > > >> > > > Ew - thats a really nice solution :) Now to remove my foot from my >> > > mouth >> > > > ;) >> > > > >> > > > >> > > > On Wed, 22 Jul 2009, David Weintraub wrote: >> > > > >> > > > Ah! You want to see if the "replace" failed! >> > > >> >> > > >> Try this: >> > > >> >> > > >> *<resoucecount property="files.not.replaced">* >> > > >> * <fileset dir="${property.dir}">* >> > > >> * <containsregexp expression="@[...@][^@]*@"/>* >> > > >> * <fileset>* >> > > >> *</resourcecount>* >> > > >> * >> > > >> <echo>Files failing replace: ${files.not.replaced}</echo> >> > > >> <fail message="Some value didn't get replaced by replacement >> macro!"> >> > > >> <condition> >> > > >> <not> >> > > >> <equal arg1="${files.not.replaced}" arg2="0"/> >> > > >> </not> >> > > >> <condition> >> > > >> </fail> >> > > >> * >> > > >> >> > > >> Let's take this apart: >> > > >> >> > > >> The *<fileset dir="${property.dir}">* should be the directory that >> > > >> contains >> > > >> the files with the variables being replaced. You then use the * >> > > >> <containregexp>* to find the files that contain the regular >> expression >> > > "* >> > > >> @[...@][^@]...@*" >> > > >> >> > > >> The *<resourcecount>* counts the number of files that your >> > > >> *<fileset>*selects. Thus if the count is greater than zero, at >> least >> > > >> one file has a >> > > >> parameter that wasn't replaced. >> > > >> >> > > >> 2009/7/22 Júlio Cesar Bueno Cotta <[email protected]> >> > > >> >> > > >> I alread have a ant script to replace the variables..and it is >> > working. >> > > >>> What I need is check if all the variables are beeing replaced. >> > > >>> I have a dev.properties where I have lines like this >> > > >>> @v...@=test >> > > >>> >> > > >>> each @vari@ is replaced to "test" after I run the script. >> > > >>> >> > > >>> But >> > > >>> If I forget to add the variable in the dev.properties , that >> variable >> > > >>> wont >> > > >>> be replaced. >> > > >>> I want to search all the varibles not replaced. >> > > >>> Thanks. >> > > >>> >> > > >>> 2009/7/22 David Weintraub <[email protected]> >> > > >>> >> > > >>> You can do this with the <copy> task via the <filter>: >> > > >>>> >> > > >>>> A good example is given on this page: >> > > >>>> >> > > >>>> <http://ant.apache.org/manual/CoreTasks/copy.html> >> > > >>>> >> > > >>>> Look for the text "*Copy a set of files to a directory, replacing >> > > >>>> @ti...@with Foo Bar in all files." >> > > >>>> >> > > >>>> *You can also look here: http://ant.apache.org/manual/index.htmlat >> > > the >> > > >>>> <filter> task. >> > > >>>> >> > > >>>> And, take a look over here too: >> > > >>>> >> > > >>>> <http://ant.apache.org/manual/CoreTypes/filterset.html> >> > > >>>> >> > > >>>> This one shows the concept of a "filterset" and how it works with >> > the >> > > >>>> <copy> >> > > >>>> task. It also has some excellent examples. >> > > >>>> >> > > >>>> 2009/7/22 Júlio Cesar Bueno Cotta <[email protected]> >> > > >>>> >> > > >>>> Hello there, >> > > >>>>> I am new over here and I need some help. >> > > >>>>> There is a script that replace variables in the files. >> > > >>>>> And I am trying to write a ant script to find in the replaced >> files >> > ( >> > > >>>>> >> > > >>>> into >> > > >>>> >> > > >>>>> a >> > > >>>>> folder like workspace/web-inf/ ) variables witch were not >> > replaced.. >> > > >>>>> Someone can help me? >> > > >>>>> Is there some task to do that? >> > > >>>>> >> > > >>>>> I am sorry if I am not clear..my English is not pretty good. >> > > >>>>> Thanks all. >> > > >>>>> >> > > >>>>> -- >> > > >>>>> Júlio Cesar Bueno Cotta >> > > >>>>> Graduando em ciência da computação >> > > >>>>> Universidade Federal de Viçosa >> > > >>>>> >> > > >>>>> >> > > >>>> >> > > >>>> >> > > >>>> -- >> > > >>>> David Weintraub >> > > >>>> [email protected] >> > > >>>> >> > > >>>> >> > > >>> >> > > >>> >> > > >>> -- >> > > >>> Júlio Cesar Bueno Cotta >> > > >>> Graduando em ciência da computação >> > > >>> Universidade Federal de Viçosa >> > > >>> >> > > >>> >> > > >> >> > > >> >> > > >> -- >> > > >> David Weintraub >> > > >> [email protected] >> > > >> >> > > >> >> > > > Scot P. Floess >> > > > 27 Lake Royale >> > > > Louisburg, NC 27549 >> > > > >> > > > 252-478-8087 (Home) >> > > > 919-890-8117 (Work) >> > > > >> > > > Chief Architect JPlate http://sourceforge.net/projects/jplate >> > > > Chief Architect JavaPIM http://sourceforge.net/projects/javapim >> > > > >> > > > Architect Keros http://sourceforge.net/projects/keros >> > > > >> > > > >> > > > >> --------------------------------------------------------------------- >> > > > To unsubscribe, e-mail: [email protected] >> > > > For additional commands, e-mail: [email protected] >> > > > >> > > >> > > >> > > >> > > -- >> > > David Weintraub >> > > [email protected] >> > > >> > >> > >> > >> > -- >> > Júlio Cesar Bueno Cotta >> > Graduando em ciência da computação >> > Universidade Federal de Viçosa >> > >> >> >> >> -- >> David Weintraub >> [email protected] >> > > > > -- > Júlio Cesar Bueno Cotta > Graduando em ciência da computação > Universidade Federal de Viçosa > > -- Júlio Cesar Bueno Cotta Graduando em ciência da computação Universidade Federal de Viçosa
