|
View:
New views
8 Messages
—
Rating Filter:
Alert me
|
|
|
Creating a fileset from a list of filenamesHi All;
I'm trying to identify modified java files in an SVN working copy and run checkstyle on these files. So far I've got a property with a list of everything modified like: /path/file1;/path/file2;/path/file3 It seems like I need something the opposite of pathconvert to turn this property into a FileSet. Any suggestions? The relevant part of my build file follows: <exec executable="svn" outputproperty="svn.status.out"> <arg value="status" /> <arg value="${basedir}/.." /> <arg value="--xml" /> </exec> <xmlproperty prefix="svnstat" collapseattributes="true" delimiter=";"> <propertyset> <propertyref name="svn.status.out"/> </propertyset> </xmlproperty> <!-- Now svnstat.status.target.entry.path contains all of the modified files and folders as a semicolon separated list This needs to be filtered to just .java files --> <echo message="unfiltered list of modified files: ${svnstat.status.target.entry.path}"/> <!-- This fails, the list is not a pathid --> <checkstyle config="./Checkstyle.xml"> <fileset pathid="svnstat.status.target.entry.path"/> </checkstyle> Thank you Nathan The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. |
|
|
Re: Creating a fileset from a list of filenames--- On Tue, 11/3/09, Wray, Nathan <Nathan.Wray@...> wrote: > From: Wray, Nathan <Nathan.Wray@...> > Subject: Creating a fileset from a list of filenames > To: user@... > Date: Tuesday, November 3, 2009, 7:16 AM > Hi All; > > > > I'm trying to identify modified java files in an SVN > working copy and > run checkstyle on these files. So far I've got a > property with a list > of everything modified like: > > > > /path/file1;/path/file2;/path/file3 > > > > It seems like I need something the opposite of pathconvert > to turn this > property into a FileSet. > If you needed the new fileset for a task that had been updated to use resource collections, you could use the paths you have directly in a <files> collection. However, since <checkstyle> doesn't seem to support the broader resource collection interface, it will be a bit more complicated. See below: > Any suggestions? The relevant part of my build file > follows: > > > > <exec executable="svn" > outputproperty="svn.status.out"> > > <arg value="status" /> > > <arg value="${basedir}/.." /> > > <arg value="--xml" /> > > </exec> > > > > <xmlproperty prefix="svnstat" collapseattributes="true" > delimiter=";"> > > <propertyset> > > <propertyref name="svn.status.out"/> > > </propertyset> > > </xmlproperty> > > > > <!-- > > Now svnstat.status.target.entry.path contains all of the > modified files > > and folders as a semicolon separated list > > This needs to be filtered to just .java files > > --> > > <echo message="unfiltered list of modified files: > ${svnstat.status.target.entry.path}"/> > > > > <!-- > > This fails, the list is not a pathid > > --> > > <checkstyle config="./Checkstyle.xml"> > > <fileset pathid="svnstat.status.target.entry.path"/> > > </checkstyle> > > This is untested, but: <pathconvert property="includespattern" pathsep=","> <path path="${svnstat.status.target.entry.path}" /> <globmapper from="${basedir}/*" to="*" handledirsep="true" /> </pathconvert> And then your fileset would be: <fileset dir="${basedir}" includes="${includespattern}"> <filename name="**/*.java" /> </fileset> HTH, Matt > > > > > > Thank you > > Nathan > > > > > > > The contents of this e-mail are intended for the named > addressee only. It contains information that may be > confidential. Unless you are the named addressee or an > authorized designee, you may not copy or use it, or disclose > it to anyone else. If you received it in error please notify > us immediately and then destroy it. > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Creating a fileset from a list of filenamesJust curious: Why are you using Ant for this?
Why not have a post-commit script that runs the check on these files? Or, even better, use Hudson which is a continuous build system. It'll automatically run your build everytime someone does a Subversion checkin. Plus, it has a CheckStyle plugin which easily find the new files, run against them, and report back. Hudson: <https://hudson.dev.java.net/> CheckStyle Plugin for Hudson: < http://wiki.hudson-ci.org//display/HUDSON/Checkstyle+Plugin> By the way, if you are able to get your files into a path, you can use the AntContrib <for> or <foreach> tasks to parse through this list and run checkstyle on each of these. -- David Weintraub qazwart@... |
|
|
RE: Creating a fileset from a list of filenamesHi David,
It has to do with the procedures I'm trying to piggyback onto. The ant target creates some required code review documentation. The goal is to have the ant target fail, rather than having the commit fail as you typically would with a pre-commit hook script (or a report as you might with a post-commit hook script). We're using Hudson as well, but again, it doesn't help me run checkstyle at the point that I need to run it. Nathan The contents of this e-mail are intended for the named addressee only. It contains information that may be confidential. Unless you are the named addressee or an authorized designee, you may not copy or use it, or disclose it to anyone else. If you received it in error please notify us immediately and then destroy it. From: David Weintraub [mailto:qazwart@...] Sent: Tuesday, November 03, 2009 12:34 PM To: Ant Users List Subject: Re: Creating a fileset from a list of filenames Just curious: Why are you using Ant for this? Why not have a post-commit script that runs the check on these files? Or, even better, use Hudson which is a continuous build system. It'll automatically run your build everytime someone does a Subversion checkin. Plus, it has a CheckStyle plugin which easily find the new files, run against them, and report back. Hudson: <https://hudson.dev.java.net/> CheckStyle Plugin for Hudson: < http://wiki.hudson-ci.org//display/HUDSON/Checkstyle+Plugin> By the way, if you are able to get your files into a path, you can use the AntContrib <for> or <foreach> tasks to parse through this list and run checkstyle on each of these. -- David Weintraub qazwart@... --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Creating a fileset from a list of filenames>
> On Tue, Nov 3, 2009 at 1:33 PM, Wray, Nathan <Nathan.Wray@...>wrote: > Hi David, > > It has to do with the procedures I'm trying to piggyback onto. The ant > target creates some required code review documentation. The goal is to > have the ant target fail, rather than having the commit fail as you > typically would with a pre-commit hook script (or a report as you might > with a post-commit hook script). We're using Hudson as well, but again, > it doesn't help me run checkstyle at the point that I need to run it. > Will the <for> or <foreach> task help in this circumstance? If I understand it, you already have a list of files separated by semicolons, and all you need is someway to run checkstyle on these. The <for> and <foreach> will work on such a list without having to convert it into a fileset. and the CheckStyle Ant task can work on individual files. -- David Weintraub qazwart@... |
|
|
RE: Creating a fileset from a list of filenamesMatt, David;
Using pathconvert/fileset worked 90% of the time. For some reason it failed under cygwin and instead of seeing the one changed file it would seek all the files from the base directory (I'd assume a globmapper failure, but I never found the exact issue). I was surprised to find that the project already had ant-contrib installed, so I was able to use <for> after all: <for list="${svnstat.status.target.entry.path}" param="modifiedFile"> <sequential> <if> <matches pattern="^.*?\.java$" string="@{modifiedFile}" /> <then> <checkstyle config="${basedir}/Checkstyle.xml" failOnViolation="true" maxErrors="25" maxWarnings="25" file="@{modifiedFile}" > </checkstyle> </then> <!-- this "else" is debugging info <else> <echo message="Skipping file, not java: @{modifiedFile}" /> </else> --> </if> </sequential> </for> One downside of processing each file individually is that the target fails after the first failed file; in a perfect world I'll figure out how to report all of the failures in every file, and then have the outer task fail. Thanks for your help! Nathan -----Original Message----- From: Matt Benson [mailto:gudnabrsam@...] Sent: Tuesday, November 03, 2009 8:59 AM To: Ant Users List Subject: Re: Creating a fileset from a list of filenames --- On Tue, 11/3/09, Wray, Nathan <Nathan.Wray@...> wrote: > From: Wray, Nathan <Nathan.Wray@...> > Subject: Creating a fileset from a list of filenames > To: user@... > Date: Tuesday, November 3, 2009, 7:16 AM > Hi All; > > > > I'm trying to identify modified java files in an SVN > working copy and > run checkstyle on these files. So far I've got a > property with a list > of everything modified like: > > > > /path/file1;/path/file2;/path/file3 > > > > It seems like I need something the opposite of pathconvert > to turn this > property into a FileSet. > If you needed the new fileset for a task that had been updated to use resource collections, you could use the paths you have directly in a <files> collection. However, since <checkstyle> doesn't seem to support the broader resource collection interface, it will be a bit more complicated. See below: > Any suggestions? The relevant part of my build file > follows: > > > > <exec executable="svn" > outputproperty="svn.status.out"> > > <arg value="status" /> > > <arg value="${basedir}/.." /> > > <arg value="--xml" /> > > </exec> > > > > <xmlproperty prefix="svnstat" collapseattributes="true" > delimiter=";"> > > <propertyset> > > <propertyref name="svn.status.out"/> > > </propertyset> > > </xmlproperty> > > > > <!-- > > Now svnstat.status.target.entry.path contains all of the > modified files > > and folders as a semicolon separated list > > This needs to be filtered to just .java files > > --> > > <echo message="unfiltered list of modified files: > ${svnstat.status.target.entry.path}"/> > > > > <!-- > > This fails, the list is not a pathid > > --> > > <checkstyle config="./Checkstyle.xml"> > > <fileset pathid="svnstat.status.target.entry.path"/> > > </checkstyle> > > This is untested, but: <pathconvert property="includespattern" pathsep=","> <path path="${svnstat.status.target.entry.path}" /> <globmapper from="${basedir}/*" to="*" handledirsep="true" /> </pathconvert> And then your fileset would be: <fileset dir="${basedir}" includes="${includespattern}"> <filename name="**/*.java" /> </fileset> HTH, Matt > > > > > > Thank you > > Nathan > > > > > > > The contents of this e-mail are intended for the named > addressee only. It contains information that may be > confidential. Unless you are the named addressee or an > authorized designee, you may not copy or use it, or disclose > it to anyone else. If you received it in error please notify > us immediately and then destroy it. > > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
Re: Creating a fileset from a list of filenamesOn Nov 5, 2009, at 11:07 AM, Wray, Nathan wrote: > Matt, David; > > Using pathconvert/fileset worked 90% of the time. For some reason > it failed under cygwin and instead of seeing the one changed file > it would seek all the files from the base directory (I'd assume a > globmapper failure, but I never found the exact issue). This is almost certainly due to the differences between path separators... the svn commands you use to generate the list are windows-based. -Matt > > I was surprised to find that the project already had ant-contrib > installed, so I was able to use <for> after all: > > <for list="${svnstat.status.target.entry.path}" param="modifiedFile"> > <sequential> > <if> > <matches pattern="^.*?\.java$" string="@{modifiedFile}" /> > <then> > <checkstyle > config="${basedir}/Checkstyle.xml" > failOnViolation="true" > maxErrors="25" > maxWarnings="25" > file="@{modifiedFile}" >> > </checkstyle> > </then> > <!-- this "else" is debugging info > <else> > <echo message="Skipping file, not java: @{modifiedFile}" /> > </else> > --> > </if> > </sequential> > </for> > > One downside of processing each file individually is that the > target fails after the first failed file; in a perfect world I'll > figure out how to report all of the failures in every file, and > then have the outer task fail. > > Thanks for your help! > Nathan > > -----Original Message----- > From: Matt Benson [mailto:gudnabrsam@...] > Sent: Tuesday, November 03, 2009 8:59 AM > To: Ant Users List > Subject: Re: Creating a fileset from a list of filenames > > > > --- On Tue, 11/3/09, Wray, Nathan <Nathan.Wray@...> wrote: > >> From: Wray, Nathan <Nathan.Wray@...> >> Subject: Creating a fileset from a list of filenames >> To: user@... >> Date: Tuesday, November 3, 2009, 7:16 AM >> Hi All; >> >> >> >> I'm trying to identify modified java files in an SVN >> working copy and >> run checkstyle on these files. So far I've got a >> property with a list >> of everything modified like: >> >> >> >> /path/file1;/path/file2;/path/file3 >> >> >> >> It seems like I need something the opposite of pathconvert >> to turn this >> property into a FileSet. >> > > If you needed the new fileset for a task that had been updated to > use resource collections, you could use the paths you have directly > in a <files> collection. However, since <checkstyle> doesn't seem > to support the broader resource collection interface, it will be a > bit more complicated. See below: > > >> Any suggestions? The relevant part of my build file >> follows: >> >> >> >> <exec executable="svn" >> outputproperty="svn.status.out"> >> >> <arg value="status" /> >> >> <arg value="${basedir}/.." /> >> >> <arg value="--xml" /> >> >> </exec> >> >> >> >> <xmlproperty prefix="svnstat" collapseattributes="true" >> delimiter=";"> >> >> <propertyset> >> >> <propertyref name="svn.status.out"/> >> >> </propertyset> >> >> </xmlproperty> >> >> >> >> <!-- >> >> Now svnstat.status.target.entry.path contains all of the >> modified files >> >> and folders as a semicolon separated list >> >> This needs to be filtered to just .java files >> >> --> >> >> <echo message="unfiltered list of modified files: >> ${svnstat.status.target.entry.path}"/> >> >> >> >> <!-- >> >> This fails, the list is not a pathid >> >> --> >> >> <checkstyle config="./Checkstyle.xml"> >> >> <fileset pathid="svnstat.status.target.entry.path"/> >> >> </checkstyle> >> >> > > This is untested, but: > > <pathconvert property="includespattern" pathsep=","> > <path path="${svnstat.status.target.entry.path}" /> > <globmapper from="${basedir}/*" to="*" handledirsep="true" /> > </pathconvert> > > And then your fileset would be: > > <fileset dir="${basedir}" includes="${includespattern}"> > <filename name="**/*.java" /> > </fileset> > > HTH, > Matt >> >> >> >> >> >> Thank you >> >> Nathan >> >> >> >> >> >> >> The contents of this e-mail are intended for the named >> addressee only. It contains information that may be >> confidential. Unless you are the named addressee or an >> authorized designee, you may not copy or use it, or disclose >> it to anyone else. If you received it in error please notify >> us immediately and then destroy it. >> >> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
|
|
RE: Creating a fileset from a list of filenamesIt's not very typical to see an app aware of its environment when you're
running ant under cygwin. The list of files dumped from the xmlproperty for instance is identical. -----Original Message----- From: Matt Benson [mailto:gudnabrsam@...] Sent: Thursday, November 05, 2009 12:24 PM To: Ant Users List Subject: Re: Creating a fileset from a list of filenames On Nov 5, 2009, at 11:07 AM, Wray, Nathan wrote: > Matt, David; > > Using pathconvert/fileset worked 90% of the time. For some reason > it failed under cygwin and instead of seeing the one changed file > it would seek all the files from the base directory (I'd assume a > globmapper failure, but I never found the exact issue). This is almost certainly due to the differences between path separators... the svn commands you use to generate the list are windows-based. -Matt > > I was surprised to find that the project already had ant-contrib > installed, so I was able to use <for> after all: > > <for list="${svnstat.status.target.entry.path}" param="modifiedFile"> > <sequential> > <if> > <matches pattern="^.*?\.java$" string="@{modifiedFile}" /> > <then> > <checkstyle > config="${basedir}/Checkstyle.xml" > failOnViolation="true" > maxErrors="25" > maxWarnings="25" > file="@{modifiedFile}" >> > </checkstyle> > </then> > <!-- this "else" is debugging info > <else> > <echo message="Skipping file, not java: @{modifiedFile}" /> > </else> > --> > </if> > </sequential> > </for> > > One downside of processing each file individually is that the > target fails after the first failed file; in a perfect world I'll > figure out how to report all of the failures in every file, and > then have the outer task fail. > > Thanks for your help! > Nathan > > -----Original Message----- > From: Matt Benson [mailto:gudnabrsam@...] > Sent: Tuesday, November 03, 2009 8:59 AM > To: Ant Users List > Subject: Re: Creating a fileset from a list of filenames > > > > --- On Tue, 11/3/09, Wray, Nathan <Nathan.Wray@...> wrote: > >> From: Wray, Nathan <Nathan.Wray@...> >> Subject: Creating a fileset from a list of filenames >> To: user@... >> Date: Tuesday, November 3, 2009, 7:16 AM >> Hi All; >> >> >> >> I'm trying to identify modified java files in an SVN >> working copy and >> run checkstyle on these files. So far I've got a >> property with a list >> of everything modified like: >> >> >> >> /path/file1;/path/file2;/path/file3 >> >> >> >> It seems like I need something the opposite of pathconvert >> to turn this >> property into a FileSet. >> > > If you needed the new fileset for a task that had been updated to > use resource collections, you could use the paths you have directly > in a <files> collection. However, since <checkstyle> doesn't seem > to support the broader resource collection interface, it will be a > bit more complicated. See below: > > >> Any suggestions? The relevant part of my build file >> follows: >> >> >> >> <exec executable="svn" >> outputproperty="svn.status.out"> >> >> <arg value="status" /> >> >> <arg value="${basedir}/.." /> >> >> <arg value="--xml" /> >> >> </exec> >> >> >> >> <xmlproperty prefix="svnstat" collapseattributes="true" >> delimiter=";"> >> >> <propertyset> >> >> <propertyref name="svn.status.out"/> >> >> </propertyset> >> >> </xmlproperty> >> >> >> >> <!-- >> >> Now svnstat.status.target.entry.path contains all of the >> modified files >> >> and folders as a semicolon separated list >> >> This needs to be filtered to just .java files >> >> --> >> >> <echo message="unfiltered list of modified files: >> ${svnstat.status.target.entry.path}"/> >> >> >> >> <!-- >> >> This fails, the list is not a pathid >> >> --> >> >> <checkstyle config="./Checkstyle.xml"> >> >> <fileset pathid="svnstat.status.target.entry.path"/> >> >> </checkstyle> >> >> > > This is untested, but: > > <pathconvert property="includespattern" pathsep=","> > <path path="${svnstat.status.target.entry.path}" /> > <globmapper from="${basedir}/*" to="*" handledirsep="true" /> > </pathconvert> > > And then your fileset would be: > > <fileset dir="${basedir}" includes="${includespattern}"> > <filename name="**/*.java" /> > </fileset> > > HTH, > Matt >> >> >> >> >> >> Thank you >> >> Nathan >> >> >> >> >> >> >> The contents of this e-mail are intended for the named >> addressee only. It contains information that may be >> confidential. Unless you are the named addressee or an >> authorized designee, you may not copy or use it, or disclose >> it to anyone else. If you received it in error please notify >> us immediately and then destroy it. >> >> > > > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > > > --------------------------------------------------------------------- > To unsubscribe, e-mail: user-unsubscribe@... > For additional commands, e-mail: user-help@... > --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscribe@... For additional commands, e-mail: user-help@... |
| Free embeddable forum powered by Nabble | Forum Help |