setting classpath attribute in <groovy> ant task

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

setting classpath attribute in <groovy> ant task

Jason Weden
--I can run this successfully:

groovy -cp build/tests/installer/ build/tests/installer/com/motorola/installer/ms/TestUtils.groovy

--In the same directory is a build.xml that has:

target name="test" description="Installer Unit Tests">
                <groovy src="build/tests/installer/com/motorola/installer/ms/TestUtils.groovy"
                classpath="build/tests/installer"/>
 </target>

--But running this ant task in this directory here gives me:

BUILD FAILED
/opt/jweden-ma34jasper-perforce-cms-main/apps/installer/build.xml:47: groovy.lang.GroovyRuntimeException: Failed to create Script instance for class: class com.motorola.installer.ms.TestUtils. Reason: org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed, script1189719852216.groovy: 119: unable to resolve class com.motorola.installerLibrary.Utils
 @ line 119, column 15.
1 error

--Did I use the classpath attribute incorrectly in the <groovy> ant task?  Thanks.
Reply | Threaded
Open this post in threaded view
|

Re: setting classpath attribute in <groovy> ant task

Jason Weden
--Ok, I corrected my ant task according to what I found at:  http://docs.codehaus.org/display/GROOVY/The+groovy+Ant+Task

 <groovy src="build/tests/installer/com/motorola/installer/ms/UtilsTest.groovy">
                        <classpath>
                                <pathelement location = "build/tests/installer"/>
                        </classpath>
     </groovy>

--Now I have a problem with not finding main (when running from ant) which doesn't make sense because this UtilsTest.groovy runs from the command line just fine and groovy should know that this is a test case and therefore doesn't need a main, right? (p.508 GINA):

BUILD FAILED
/opt/jweden-ma34jasper-perforce-cms-main/apps/installer/build.xml:45: groovy.lang.MissingMethodException: No signature of method: com.motorola.installer.ms.UtilsTest.main() is applicable for argument types: ([Ljava.lang.String;) values: {[]}

Reply | Threaded
Open this post in threaded view
|

Re: setting classpath attribute in <groovy> ant task

Guillaume Laforge
Administrator
So the classpath is not taken into account?

On 9/14/07, Jason Weden <[hidden email]> wrote:

>
> --Ok, I corrected my ant task according to what I found at:
> http://docs.codehaus.org/display/GROOVY/The+groovy+Ant+Task
>
>  <groovy
> src="build/tests/installer/com/motorola/installer/ms/UtilsTest.groovy">
>                         <classpath>
>                                 <pathelement location =
> "build/tests/installer"/>
>                         </classpath>
>      </groovy>
>
> --Now I have a problem with not finding main (when running from ant) which
> doesn't make sense because this UtilsTest.groovy runs from the command line
> just fine and groovy should know that this is a test case and therefore
> doesn't need a main, right? (p.508 GINA):
>
> BUILD FAILED
> /opt/jweden-ma34jasper-perforce-cms-main/apps/installer/build.xml:45:
> groovy.lang.MissingMethodException: No signature of method:
> com.motorola.installer.ms.UtilsTest.main() is applicable for argument types:
> ([Ljava.lang.String;) values: {[]}
>
>
> --
> View this message in context: http://www.nabble.com/setting-classpath-attribute-in-%3Cgroovy%3E-ant-task-tf4438583.html#a12680310
> Sent from the groovy - user mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe from this list please visit:
>
>     http://xircles.codehaus.org/manage_email
>
>


--
Guillaume Laforge
Groovy Project Manager
http://glaforge.free.fr/blog/groovy

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: setting classpath attribute in <groovy> ant task

Jason Weden

<quote author="glaforge">
So the classpath is not taken into account?

--I don't think it is related to classpath.  It seems that if the referenced script in my ant cofig is a groovy program with a main, it works fine.  If it is a GroovyTestCase class, it cannot be run and generates an error.
Reply | Threaded
Open this post in threaded view
|

Re: setting classpath attribute in <groovy> ant task

Alex Shneyderman
I think groovy task expects a script. GroovyTestCase
extends TestCase of junit so your groovy file is unlikely
to be a script. Try to add something like this to the
end of your groovy file - just to test the "theory":

//import junit.textui.TestRunner

new TestRunner(System.out).doRun(new YourTestCase())
this will turn your test case into a script.

As it is I think groovy task is not suitable to run the tests.
There should probably be another task specifically for
this purpose. Another alternative is to compile your test
and then run it with junit task.

HTH,
Alex.

On 9/16/07, Jason Weden <[hidden email]> wrote:

>
>
>
> So the classpath is not taken into account?
>
> --I don't think it is related to classpath.  It seems that if the referenced
> script in my ant cofig is a groovy program with a main, it works fine.  If
> it is a GroovyTestCase class, it cannot be run and generates an error.
> --
> View this message in context: http://www.nabble.com/setting-classpath-attribute-in-%3Cgroovy%3E-ant-task-tf4438583.html#a12725614
> Sent from the groovy - user mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

Reply | Threaded
Open this post in threaded view
|

Re: setting classpath attribute in <groovy> ant task

Jason Weden
I think groovy task expects a script. GroovyTestCase
extends TestCase of junit so your groovy file is unlikely
to be a script.
--I suspected the same but couldn't find any documentation to this effect.

Try to add something like this to the
end of your groovy file - just to test the "theory":

//import junit.textui.TestRunner

new TestRunner(System.out).doRun(new YourTestCase())
this will turn your test case into a script.
-- With this I can run the script, so this test proves the theory.

As it is I think groovy task is not suitable to run the tests.
There should probably be another task specifically for
this purpose. Another alternative is to compile your test
and then run it with junit task.
-- I will try this route then as I want to stay with something standard.  Thanks for the time here.