Hi all, I've just completed the implementation of the stuff we discussed yesterday.
Right now I'm out of office and I don't have CVS access due to proxy restrictions, so attached to this email you will find the modified files. I'll send you a patch tomorrow. The modified files are: NAnt.Core/Project.cs line 81 added WildTarget const line 132 added _currentTarget field lines 410 - 416 added CurrentTarget property lines 784 - 796 replaced do-while statement lines 1415 - 1419 added wild targets handling NAnt.Core/Functions/NAntFunctions.cs lines 83 - 98 added GetCurrentTarget functioin These modifications allow you to specify a wild target that is executed when the user specifies a target that does not exist in the current build file. Here's an example: <project name="myProject" default="build"> <target name="build"> <echo message="This is the build target."/> </target> <target name="*"> <echo message="This is the ${target::get-current-target()} target."/> </target> </project> if you type nant hello from the command, you get the message "This is the hello target". Furthermore, using the master-gateway-slave build file pattern is much easier (see my previous emails). Here below is another example. Let's start with the usual project: /myProject + default.build + /src + default.build + /Subproject + default.build + HelloWorld.cs the master build file (/myProject/default.build) looks like this: <?xml version="1.0"?> <project name="myProject" default="build"> <target name="build" description="Builds the current configuration"> <nant buildfile="src/default.build" target="${target::get-current-target()}"/> </target> <target name="test" description="Tests the current configuration"> <nant buildfile="src/default.build" target="${target::get-current-target()}"/> </target> <target name="clean" description="Deletes the current configuration"> <nant buildfile="src/default.build" target="${target::get-current-target()}"/> </target> </project> ... and the gateway build file (/myProject/src/default.build) like this: <?xml version="1.0"?> <project name="myProject" default="*"> <target name="*" description="Builds recursively all subprojects"> <foreach item="Folder" property="foldername"> <in> <items> <includes name="*"/> <excludes name="CVS"/> </items> </in> <do> <nant buildfile="${foldername}/default.build" target="${project.config} ${target::get-current-target()}"/> </do> </foreach> </target> </project> I don't report the slave build file (/myProject/src/Subproject/default.build) since it is like any other build file written till now. Wild targets allow you to write more compact build files and provide a standard way to handle unexpected targets. What do you think about that? j3d. ---------------------------------------- Giuseppe Greco ::agamura:: phone: +41 (0)91 604 67 65 mobile: +41 (0)76 390 60 32 email: [EMAIL PROTECTED] web: www.agamura.com ----------------------------------------
patch.tar.gz
Description: GNU Zip compressed data