Groovy, Maven, and GSpec Trouble


It’s not going too well tonight. I’m enjoying a 12oz. bottle of Labatt Blue and not enjoying my struggle to integrate GSpec with JUnit. The problem is my much bragged about Groovy Maven2 integration. I haven’t done anything with it in some time so I forget how things kinda work. Plus most of my prototyping was done on my other computer (which is 5 miles away) so I’m at a loss. Here’s what happened so far. I threw together a unit test to excercise a potential JUnitGSpecSuiteBuilder. The concept is simple enough. Create a builder that will interpret a GSpec file and provide access to the closures within. Well let me be more specific. GSpec works using a Groovy builder. The builder incorporates a collaborator object and provides a sort of DSL for the syntax of GSpec. (Forgive me if I soud a little stoopid but Mr. Labatts is talking to me.) I won’t go into too much detail (while I’m drinking) but in short I want to collect the closures that makeup the setup, teardown (teardown is actually called inConclusion), and specify closures and hand them off to JUnit in the form of a TestSuite. Sounds simple enough until I try to get my dumb environment together. I work between home and the office so there’s a lot of copying and code shuffling involved. (One of my buddies tipped me to Bazaar which I’ll start using shortly.) My IDE, and Maven setup at home isn’t nearly as elaborate as what I use in the office. So now I got these issues with Maven not finding Groovy-1.0 pom files. I side step that problem with a manual download then I have other issues when I try to compile and run everything with Maven. For some reason the tests compile cycle (which runs after the rinse cycle) doesn’t see the production classes. I’m just all frustrated and my ulcers are acting up. Here’s my dumb pom.xml. (Crap! I gotta install the danged Copy As HTML plugin…) I’ll see if someone else happens to be reading my site @ 11pm EST and cares enough to bail me out. (Chances are very slim!)

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.craig.gspec</groupId>
    <artifactId>gspec</artifactId>
    <packaging>jar</packaging>
    <version>1.0-SNAPSHOT</version>
    <name>gspec</name>
    <url>http://maven.apache.org</url>
    <dependencies>
        <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
        <dependency>
            <groupId>commons-cli</groupId>
            <artifactId>commons-cli</artifactId>
            <version>1.0</version>
        </dependency>
        <dependency>
            <groupId>groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>1.0</version>
        </dependency>
    </dependencies>
    <build>
        <sourceDirectory>src/main/groovy</sourceDirectory>
        <testSourceDirectory>src/test/groovy</testSourceDirectory>
        <plugins>
            <plugin>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerId>groovyc</compilerId>
                </configuration>
                <dependencies>
                    <dependency>
                        <groupId>org.codehaus.plexus</groupId>
                        <artifactId>plexus-compiler-groovyc</artifactId>
                        <version>1.5.1</version>
                    </dependency>
                </dependencies>
                <extensions>true</extensions>
            </plugin>
        </plugins>
    </build>
</project>

I’m going to take a break and watch a Blockbuster or something. Holla…

2 thoughts on “Groovy, Maven, and GSpec Trouble

  1. Man, see? That’s what I mean about Maven. Do real work for some weeks and you can’t remember a thing about how it works.

    That aside, it looks to me like a classpath problem. Can you assert that the class files generated by groovyc land on a path that is included for the test compilation?

  2. Yeah, the class files from groovyc all go out to the target/classes folder while the test classes are located in target/test-classes. It’s gotta be a runtime classpath inconsistency in the plexus-compiler-groovyc-wrapper-thingamajig. Maybe it’s requiring a POM entry that should normally be assumed? I agree that Maven2 can be funny to work with and I have some serious issues with it’s interface. I still respect it as a powerful tool, it’s just something I haven’t finished beating into my skull yet. That said I am considering picking up another build system like AppFuse. I’m also respecting what John Wilson has been doing with GAnt. I’m not sure how much of a build system is built around it but if it’s close enough to M2 with out-of-the-box functionality I may make a leap of faith.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s