Search code examples
mavengroovyeasyb

Where to put groovy code in project with java src and groovy tests in order to use them only in groovy tests?


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?


Solution

  • 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.