I was having this same problem! Thanks for the script.

+1 for a <ant> task

brant
...



From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Subject: [nant-dev] New to the list
Date: Fri, 19 Mar 2004 08:57:55 -0500





Hi everyone!  I joined this list because there are some differences between
Nant and Ant which have been causing me trouble.  I wanted to post my
solutions in the hopes that they may be useful.  If it's stuff that's
already been thought of, just tell me to shut up :)

The first problem I ran up against was running Ant from Nant.  On the
Windows platform, Ant is run through a batch file which does not
communicate the program exit code.  So the Nant build always believes that
the Ant build succeeded.  To get around this, I actually call the Java
class file like so:

        <exec
            program="${java.home}/bin/java.exe"
            workingdir="${mbpa.home}"
            commandline="-classpath ${ant.cp}
org.apache.tools.ant.launch.Launcher build"
            failonerror="true"
            />

This is obviously not a problem, however getting the classpath correct is a
pain because you have to add all the jars in the ant/lib directory since
Nant doesn't have any clue what a Java classpath is.  To achieve this, I
wrote a little script:

        <script language="C#">
            <code><![CDATA[
                public static void ScriptMain( Project project ) {
                    string ald = project.Properties["ant.home"] + "/lib";
                    string jh = project.Properties["java.home"];
                    string cp = jh + "/lib/tools.jar";
                    DirectoryInfo di = new DirectoryInfo(ald);
                    FileInfo[] files = di.GetFiles("*.jar");
                    foreach (FileInfo fi in files)
                        cp += ";" + ald + "/" + fi.Name;
                    project.Properties["ant.cp"] = cp;
                }
            ]]></code>
        </script>


_________________________________________________________________
Add photos to your e-mail with MSN Premium. Get 2 months FREE* http://join.msn.com/?pgmarket=en-ca&page=byoa/prem&xAPID=1994&DI=1034&SU=http://hotmail.com/enca&HL=Market_MSNIS_Taglines




-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
nant-developers mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/nant-developers

Reply via email to