2

I have src in Java, and tests in Groovy (easyb stories). I run my groovy/easyb stories via maven plugin.

Now I want to write some helpers in groovy to use them in my groovy tests. Where should I put them in my project and what should I configure in addition?

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
yashaka
  • 826
  • 1
  • 9
  • 20
  • In the `src/test/groovy` folder somewhere? I assume I'm missing something... What problem are you having? – tim_yates Feb 08 '14 at 09:20
  • I have java code in src/ and groovy coded tests in test/stories/ Previously I used in groovy tests only java code... Now I want to write some helpers in groovy... And Don't know what the best place to put them... And how to tell maven to compile this groovy helper code before groovy tests... so groovy tests can use it... – yashaka Feb 08 '14 at 09:49
  • I want to use this groovy helpers only in groovy code... They are considered to be "functional", i.e. taking other functions as parameters... – yashaka Feb 08 '14 at 09:58
  • Is your project setup following the maven structure? In that case, where source goes is already pre-determined. Or are you working out of just a 'src' folder for source? – mikemil Feb 08 '14 at 20:59
  • yes, the project setup is following the maven structure... I assume that need to put groovy code somewhere to src/groovy. So just need to configure maven to compile these groovy code before running groovy tests... I found an article - http://groovy.codehaus.org/Groovy-Eclipse+compiler+plugin+for+Maven. Hope to find the answer there. – yashaka Feb 09 '14 at 00:19

1 Answers1

3

So, the answer is pretty simple... And lives at http://groovy.codehaus.org/Groovy-Eclipse+compiler+plugin+for+Maven

In short:

  1. Configure compiler in pom:

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.1</version>
            <configuration>
                <compilerId>groovy-eclipse-compiler</compilerId>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-compiler</artifactId>
                    <version>2.8.0-01</version>
                </dependency>
                <dependency>
                    <groupId>org.codehaus.groovy</groupId>
                    <artifactId>groovy-eclipse-batch</artifactId>
                    <version>2.1.8-01</version>
                </dependency>
            </dependencies>
        </plugin>
    
  2. Just put groovy files under src/main/groovy

That's it.

yashaka
  • 826
  • 1
  • 9
  • 20