gmaven:execute can't find compiled class

1.1k views Asked by At

I'm attempting to use the gmaven-plugin to compile a class com.kc.Validator in src/test/groovy/com/kc/Validator.groovy and then run a script using the class. After mvn compile the .class file is in *target/test-classes/com/kc but the script execution fails:

Failed to execute goal org.codehaus.gmaven:gmaven-plugin:1.5:execute (validate-configuration) on project solver2: startup failed, script1367530828433.groovy: 1: unable to resolve class com.kc.Validator

The relevant section of pom.xml is:

<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.5</version>
<executions>
  <execution>
    <id>compile-groovy</id>
    <goals>
      <goal>compile</goal>
      <goal>testCompile</goal>
    </goals>
  </execution>
  <execution>
    <id>validate</id>
        <phase>test</phase>
        <goals>
      <goal>execute</goal>
        </goals>
        <configuration>
      <source>
    (new com.kc.Validator()).validate()
      </source>
        </configuration>
  </execution>
</executions>
  </plugin>
1

There are 1 answers

7
dmahapatro On

Have you tried using the <scriptpath> inside <configuration>?

<configuration>
  <scriptpath>
    <element>${pom.basedir}/src/test/groovy/com/kc</element>
  </scriptpath>
  <source>......</souce>
</configuration>

Refer Using Groovy Classes.