2013-05-02 27 views
0

我试图用gmaven-plugin编译一个类com.kc.Validatorsrc/test/groovy/com/kc/Validator.groovy然后用脚本运行脚本类。 mvn compile后的.class文件是*目标/测试类/ COM/KC但脚本执行失败:gmaven:执行找不到编译后的类

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

你试过在<configuration>里面使用<scriptpath>

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

请参阅Using Groovy Classes

+0

有没有办法将类路径设置为包含所有项目运行时或测试依赖项? – 2013-05-06 19:45:57

+0

您是否面临在pom中添加其中的每个人为''的问题? – dmahapatro 2013-05-06 19:59:49

+0

他们已经在pom的依赖。你的意思是这个执行的依赖关系吗?没有一些方法可以避免重复项目依赖关系的大部分子集吗? TestNG插件不需要单独的依赖关系列表。 – 2013-05-06 20:09:48