aspose file tools*
The moose likes Groovy and the fly likes Questions abt Groovy environment Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Questions abt Groovy environment" Watch "Questions abt Groovy environment" New topic
Author

Questions abt Groovy environment

Ajay Jeswani
Greenhorn

Joined: Feb 17, 2008
Posts: 5
Hi Dierk !!

Congratulations on the book.

Can you please share some info abt some of questions related to Groovy

1) Can we pass Groovy map, list and other collections objects from let say groovy interactive shell to some java api as input ?
2) Any IDE or any tools which can help in giving all the compile time error ?
I am not sure GMaven checks all the compile time error. Example of what I mean to say - if we have this line in Groovy Class 'Classs.forName(com.xyz.dept.project.something)' it should shout for spelling mistake in Classs ? How to take care of those ? Otherwise those showup as runtime error. GMaven compiles it fine, no compile time errors.
3) Can we make instance of Groovy class in java directly ? instead of using GroovyClassLoader and GroovyObject ? Also, does GroovyObject provide method invoking with args[] ?
4) Is Gunit in Eclipse smooth ?

Thanks,
Ajay

[ October 21, 2008: Message edited by: Ajay Jeswani ]
[ October 21, 2008: Message edited by: Ajay Jeswani ]
Dierk König
author
Ranch Hand

Joined: Nov 01, 2006
Posts: 43
Originally posted by Ajay Jeswani:

Congratulations on the book.

Thanks a lot

1) Can we pass Groovy map, list and other collections objects from let say groovy interactive shell to some java api as input ?

Sure! That is what Groovy is all about!
2) Any IDE or any tools which can help in giving all the compile time error ?

Most complete IDE support is currently in IntelliJ IDEA followed by Netbeans and Eclipse.

I am not sure GMaven checks all the compile time error. Example of what I mean to say - if we have this line in Groovy Class 'Classs.forName(com.xyz.dept.project.something)' it should shout for spelling mistake in Classs ? How to take care of those ? Otherwise those showup as runtime error. GMaven compiles it fine, no compile time errors.

Well, from a Groovy perspective, your code is perfectly fine and there is no reason to throw an error at compile time. From the compiler perspective, 'Classs' may be just any reference (not necessarily a Class as you are entitled to capitalize any reference if you whish). The Groovy compiler cannot tell whether this reference will be available at runtime.
If you are in a _Class_ (as opposed to a _Script_) then IDE will give you an indication that the 'Classs' reference is not known at compile time (e.g. underline in IntelliJ).

3) Can we make instance of Groovy class in java directly ? instead of using GroovyClassLoader and GroovyObject ? Also, does GroovyObject provide method invoking with args[] ?

In case your Groovy Class is precompiled (which happens automatically inside the IDEs), then all you have to do in your Groovy code is "new MyGroovyClass()". In other words, there is no difference between Classes written in Groovy and Classes written in Java.

4) Is Gunit in Eclipse smooth ?

I don't have the slightest idea what GUnit is ;-)


keep groovin'
Dierk
Ajay Jeswani
Greenhorn

Joined: Feb 17, 2008
Posts: 5
Thank you very much Dierk.

By GUnit, I was refering to Groovy unit test for groovy like Junit for Java. I have faced issues running GUnit in eclipse many times it says 'Test Class Not Found'. Just wanted to know whats the best way to test Groovy Script and Class.
[ October 21, 2008: Message edited by: Ajay Jeswani ]
Dierk König
author
Ranch Hand

Joined: Nov 01, 2006
Posts: 43
JUnit is included in Groovy.

Lets say you have a file MyTest.groovy with content



Then you can simply run that test from the commandline:

or alternatively compile that class with groovyc or your IDE support and call the test exactly the same way as if it was written in Java (in IntelliJ IDEA, I simply right-click and select "Run Test" to start the internal JUnit support).

cheers
Dierk
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Questions abt Groovy environment