gmaven:执行无法找到编译的类 [英] gmaven:execute can't find compiled class

查看:317
本文介绍了gmaven:执行无法找到编译的类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

 无法执行目标org.codehaus.gmaven:gmaven-plugin:1.5:对项目solver2执行(validate-configuration):启动失败,script1367530828433.groovy:1:无法解析class com.kc.Validator 

pom.xml的相关部分是:

 < plugin> 
< groupId> org.codehaus.gmaven< / groupId>
< artifactId> gmaven-plugin< / artifactId>
< version> 1.5< / version>
<执行次数>
<执行>
< id>编译常量< / id>
<目标>
< goal>编译< / goal>
< goal> testCompile< / goal>
< /目标>
< /执行>
<执行>
< id>验证< / id>
<阶段>测试< /阶段>
<目标>
< goal>执行< / goal>
< /目标>
<配置>
< source>
(new com.kc.Validator())。validate()
< / source>
< / configuration>
< /执行>
< /执行次数>
< / plugin>


解决方案

您是否尝试过使用 < code><配置>

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

请参阅使用Groovy类

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>

解决方案

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.

这篇关于gmaven:执行无法找到编译的类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆