You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by 1800 tbsfunny <18...@gmail.com> on 2006/06/08 18:54:04 UTC

Methods inside Java ant task

Hi Ant gurus,

I am trying to write an Ant task that looks something like that -

<target name="startcss" description="starting CSS" depends="setup">
        <java classname="util.runtime.TestSingleton.initialize()"  fork="no"
failonerror="no">
            <classpath refid="testrunning.classpath"/>
        </java>
    </target>


This fails on me because we cannot run methods directly. Any suggesstions?

Re: Re: Methods inside Java ant task

Posted by Antoine Levy-Lambert <an...@gmx.de>.
> -------- Original-Nachricht --------
> Datum: Thu, 8 Jun 2006 13:14:21 -0400
> Von: 1800 tbsfunny <18...@gmail.com>
> An: Ant Users List <us...@ant.apache.org>
> Betreff: Re: Methods inside Java ant task
> 
> Thanks Antonie.
> 
> I created a wrapper class.
> 
> public class TestSingletonInitializer
> {
>     public static void main(String[] args)
>     {
>         TestSingleton.initialize();
>     }
> }
> 
> This still doesnt run very well. But when I use my initialize method
> inside
> of the junit tests. ex.
> 
> <junit>
> TestSingleton.initialize()
> ..
> run tests
> ..
> TestSingleton.shutdown()
> </junit>
> 
> It works fine. Any clues why the initialize method runs succesffully
> inside
> the junit task but not a seperate java task?
> 
I do not have any clue. It depends upon the code of TestSingleton.
Are you getting a build exception ? If yes, run ant -debug to get a stack trace, and mail the stack trace and the build file.

Regards,

Antoine

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Methods inside Java ant task

Posted by 1800 tbsfunny <18...@gmail.com>.
Thanks Antonie.

I created a wrapper class.

public class TestSingletonInitializer
{
    public static void main(String[] args)
    {
        TestSingleton.initialize();
    }
}

This still doesnt run very well. But when I use my initialize method inside
of the junit tests. ex.

<junit>
TestSingleton.initialize()
..
run tests
..
TestSingleton.shutdown()
</junit>

It works fine. Any clues why the initialize method runs succesffully inside
the junit taask but not a seperate java task?




On 6/8/06, Antoine Levy-Lambert <an...@gmx.de> wrote:
>
> Hello,
>
> you need to write a main method which calls the method you want to run.
> May be add a main method to util.runtime.TestSingleton.
>
> The only method which can be invoked by <java/> is static void main
> (String [] args).
>
> Regards,
>
> Antoine
> > -------- Original-Nachricht --------
> > Datum: Thu, 8 Jun 2006 12:54:04 -0400
> > Von: 1800 tbsfunny <18...@gmail.com>
> > An: user@ant.apache.org
> > Betreff: Methods inside Java ant task
> >
> > Hi Ant gurus,
> >
> > I am trying to write an Ant task that looks something like that -
> >
> > <target name="startcss" description="starting CSS" depends="setup">
> >         <java classname="util.runtime.TestSingleton.initialize()"
> > fork="no"
> > failonerror="no">
> >             <classpath refid="testrunning.classpath"/>
> >         </java>
> >     </target>
> >
> > This fails on me because we cannot run methods directly. Any
> suggesstions?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org
>
>

Re: Methods inside Java ant task

Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello,

you need to write a main method which calls the method you want to run.
May be add a main method to util.runtime.TestSingleton.

The only method which can be invoked by <java/> is static void main (String [] args).

Regards,

Antoine
> -------- Original-Nachricht --------
> Datum: Thu, 8 Jun 2006 12:54:04 -0400
> Von: 1800 tbsfunny <18...@gmail.com>
> An: user@ant.apache.org
> Betreff: Methods inside Java ant task
> 
> Hi Ant gurus,
> 
> I am trying to write an Ant task that looks something like that -
> 
> <target name="startcss" description="starting CSS" depends="setup">
>         <java classname="util.runtime.TestSingleton.initialize()"  
> fork="no"
> failonerror="no">
>             <classpath refid="testrunning.classpath"/>
>         </java>
>     </target>
> 
> This fails on me because we cannot run methods directly. Any suggesstions?

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Putting -verbose option 'on' and 'off' during ANT build

Posted by Ben Stringer <be...@burbong.com>.
On Mon, 2006-06-19 at 22:53 -0700, madhuvanti joshi wrote:
> Hi,
> 
> I am running an ANT script with -verbose option. It
> gives me additional information in log file. I need to
> put it 'OFF' while the script is running and then
> again make it 'ON' as I want to make sure certain
> information is not logged. 
> Is there any way to do this in ANT scripting? Like, in
> batch file we can say '@echo on' or 'echo off'.

Yes - use the <record> task. You can start it (action=start) when your
build starts, then stop it at the part you want the verbose logging, and
immediately start it again with loglevel=verbose. Then stop it, and
restart it with loglevel set below verbose (you may need to experiment
with this to see what level is appropriate).

> 
> Thanks in Advance.

Welcome.

Cheers, Ben

> 
> -Madhu.
> 
> __________________________________________________
> Do You Yahoo!?
> Tired of spam?  Yahoo! Mail has the best spam protection around 
> http://mail.yahoo.com 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
> For additional commands, e-mail: user-help@ant.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


ANT script fails to run when path contains '!'

Posted by madhuvanti joshi <j_...@yahoo.com>.
Hi All,

I have a batch file through which I am calling ANT
script. Before calling ANT script, I am setting
CLASSPATH through batch file to the path containing
ANT libraries and product.

Although CLASSPATH has been set properly when I have a
'!' in the path ( e.g. C:\Program
Files\Some!Path\AntMainDir), ANT script fails with
return code 3 (on windows - path not found) with build
exception "Can't load default task list". (It does not
find
org/apache/tools/ant/taskdefs/defaults.properties)

I want to know why it is not finding the path when it
contains '!'? (If I remove'!' from Some!Path then
everything works fine.)

Thanks in Advance.

-Madhu. 



__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Re: Putting -verbose option 'on' and 'off' during ANT build

Posted by Antoine Levy-Lambert <an...@gmx.de>.
Hello Madhu,

look at the record task.

Antoine
-------- Original-Nachricht --------
Datum: Mon, 19 Jun 2006 22:53:09 -0700 (PDT)
Von: madhuvanti joshi <j_...@yahoo.com>
An: Ant Users List <us...@ant.apache.org>
Betreff: Putting -verbose option \'on\' and \'off\' during ANT build

> Hi,
> 
> I am running an ANT script with -verbose option. It
> gives me additional information in log file. I need to
> put it 'OFF' while the script is running and then
> again make it 'ON' as I want to make sure certain
> information is not logged. 
> Is there any way to do this in ANT scripting? Like, in
> batch file we can say '@echo on' or 'echo off'.
> 
> Thanks in Advance.
> 
> -Madhu.
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


Putting -verbose option 'on' and 'off' during ANT build

Posted by madhuvanti joshi <j_...@yahoo.com>.
Hi,

I am running an ANT script with -verbose option. It
gives me additional information in log file. I need to
put it 'OFF' while the script is running and then
again make it 'ON' as I want to make sure certain
information is not logged. 
Is there any way to do this in ANT scripting? Like, in
batch file we can say '@echo on' or 'echo off'.

Thanks in Advance.

-Madhu.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org


RE: Methods inside Java ant task

Posted by Asaf Mesika <as...@gmail.com>.
How about passing a param to the task you're writing, to choose the
procedure you'd like to run and then run it via RMI?


> -----Original Message-----
> From: 1800 tbsfunny [mailto:1800tbsfunny@gmail.com]
> Sent: Thursday, June 08, 2006 6:54 PM
> To: user@ant.apache.org
> Subject: Methods inside Java ant task
> 
> Hi Ant gurus,
> 
> I am trying to write an Ant task that looks something like that -
> 
> <target name="startcss" description="starting CSS" depends="setup">
>         <java classname="util.runtime.TestSingleton.initialize()"
> fork="no"
> failonerror="no">
>             <classpath refid="testrunning.classpath"/>
>         </java>
>     </target>
> 
> 
> This fails on me because we cannot run methods directly. Any suggesstions?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@ant.apache.org
For additional commands, e-mail: user-help@ant.apache.org