gmaven:execute无法找到编译的类

时间:2013-05-02 22:12:52

标签: maven groovy gmaven

我正在尝试使用gmaven-plugin在 src / test / groovy / com / kc / Validator.groovy 中编译类com.kc.Validator,然后使用类。在mvn compile之后,.class文件位于* target / test-classes / com / kc中,但脚本执行失败:

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

pom.xml的相关部分是:

<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 个答案:

答案 0 :(得分:1)

您是否尝试过使用<scriptpath>内的<configuration>

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

参考Using Groovy Classes