Stub generation failure for HelloSpock in maven build

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

Stub generation failure for HelloSpock in maven build

Sam Brannen

I'm trying out Spock in a maven project which mixes Java and Groovy
source code. To do so, I've configured my maven POM as suggested on
the Getting Started page. In addition to the "testCompile" goal,
however, I've also added the following goals: generateStubs, compile,
generateTestStubs. These extra goals are necessary for the Java/Groovy
combination to work.

When I run "mvn clean test", the stub generation for HelloSpock fails
with compilation failures for the generated HelloSpocky.java file,
since the following generated method is obviously not valid Java:

    public java.lang.Object can you figure out what I'm up to?() {
        throw new InternalError("Stubbed method");
    }

Anyone got an idea of how to get this to work?

Thanks,

Sam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Stub generation failure for HelloSpock in maven build

Peter Niederwieser
Administrator

Hi Sam,

unfortunately, it seems that neither GMaven nor groovyc are currently  
capable of generating stubs for Spock specifications. I think the best  
solution would be to improve GMaven and groovyc in some way. I'll need  
to discuss this on the Groovy list. Meanwhile, here are some ideas to  
work around the problem:
- First of all, do you really have Java test classes referencing  
Groovy test classes? Otherwise you won't need generateTestStubs, and  
your problem should be solved.
- You could move Spock specifications to a Maven module that doesn't  
require generateTestStubs.
- It's likely that I could tweak Spock to work around the problem.  
I'll investigate this over the weekend.

By the way, aren't you the guy who will do the OSGi talk at eJUG  
Austria next month? If yes, I'm looking forward to meet you there!  
(I'll be doing the other talk, together with Kristian Marinkovic).

Cheers,
Peter


On 06.08.2009, at 23:14, Sam Brannen wrote:

>
> I'm trying out Spock in a maven project which mixes Java and Groovy
> source code. To do so, I've configured my maven POM as suggested on
> the Getting Started page. In addition to the "testCompile" goal,
> however, I've also added the following goals: generateStubs, compile,
> generateTestStubs. These extra goals are necessary for the Java/Groovy
> combination to work.
>
> When I run "mvn clean test", the stub generation for HelloSpock fails
> with compilation failures for the generated HelloSpocky.java file,
> since the following generated method is obviously not valid Java:
>
>    public java.lang.Object can you figure out what I'm up to?() {
>        throw new InternalError("Stubbed method");
>    }
>
> Anyone got an idea of how to get this to work?
>
> Thanks,
>
> Sam
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Stub generation failure for HelloSpock in maven build

Sam Brannen

Hi Peter,

> unfortunately, it seems that neither GMaven nor groovyc are currently  
> capable of generating stubs for Spock specifications.

Based on the generated stub, I figured that might be the case. Though
it may be a more general issue in that they simply don't support
generation of stubs for method names which contain spaces.

> I think the best  
> solution would be to improve GMaven and groovyc in some way. I'll need  
> to discuss this on the Groovy list.

OK. Let me know how that goes.

> - First of all, do you really have Java test classes referencing  
> Groovy test classes? Otherwise you won't need generateTestStubs, and  
> your problem should be solved.

For this simple example, you're correct: I don't need the
generateTestStubs goal. So that's a sure quick fix, but there could
certainly be cases for which one would need that goal.

> - You could move Spock specifications to a Maven module that doesn't  
> require generateTestStubs.

That's technically plausible, but it's not what I wanted to do. :-p

So I'll stick with omitting the generateTestStubs goal for now.

> By the way, aren't you the guy who will do the OSGi talk at eJUG  
> Austria next month? If yes, I'm looking forward to meet you there!  
> (I'll be doing the other talk, together with Kristian Marinkovic).

Yes, indeed. I am "that guy". ;)

Looking forward to meeting you in Linz, and thanks for the support!

 - Sam
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: Stub generation failure for HelloSpock in maven build

Peter Niederwieser
Administrator

I have now fixed this problem for Groovy's stub generation, and have
submitted an issue for GMaven (which does its own stub generation):
http://jira.codehaus.org/browse/GMAVEN-48

Cheers,
Peter

On Aug 12, 11:38 pm, Sam Brannen <[hidden email]> wrote:
> > I think the best  
> > solution would be to improve GMaven and groovyc in some way. I'll need  
> > to discuss this on the Groovy list.
>
> OK. Let me know how that goes.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Spock Framework" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups.google.de/group/spockframework?hl=en
-~----------~----~----~----~------~----~------~--~---