Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
cobertura maven插件找不到我的groovy源代码_Maven_Groovy_Cobertura - Fatal编程技术网

cobertura maven插件找不到我的groovy源代码

cobertura maven插件找不到我的groovy源代码,maven,groovy,cobertura,Maven,Groovy,Cobertura,我正在尝试使用ApacheAven为我的Java/Groovy项目生成代码覆盖率报告。随附pom文件: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.

我正在尝试使用ApacheAven为我的Java/Groovy项目生成代码覆盖率报告。随附pom文件:

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.hal_con</groupId>
  <artifactId>scheduler</artifactId>
  <version>0.0.1-SNAPSHOT</version>
  <dependencies>
    <!-- https://mvnrepository.com/artifact/org.codehaus.groovy/groovy-all -->
    <dependency>
      <groupId>org.codehaus.groovy</groupId>
      <artifactId>groovy-all</artifactId>
      <version>2.4.8</version>
    </dependency>

    <!-- https://mvnrepository.com/artifact/junit/junit -->
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>4.12</version>
    </dependency>
  </dependencies>

  <build>
    <plugins>
      <plugin>
        <groupId>org.codehaus.gmaven</groupId>
        <artifactId>gmaven-plugin</artifactId>
        <version>1.5</version>
        <configuration>
          <providerSelection>1.8</providerSelection>
        </configuration>
        <executions>
          <execution>
            <goals>
              <goal>compile</goal>
              <goal>testCompile</goal>
            </goals>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <reporting>
    <plugins>
      <plugin>
        <!-- https://mvnrepository.com/artifact/org.codehaus.mojo/cobertura-maven-plugin -->
        <groupId>org.codehaus.mojo</groupId>
        <artifactId>cobertura-maven-plugin</artifactId>
        <version>2.7</version>
      </plugin>
    </plugins>
  </reporting>
</project>

4.0.0
com.hal_con

  • 按照中的建议添加jxr maven插件:

  • 在这两种情况下,结果完全相同:

    找不到com/hal_con/scheduler/FileParser.groovy。您指定了源目录了吗


    我认为需要告诉maven cobertura插件在哪里可以找到我的groovy源代码,但我找不到一个例子。

    cobertura maven插件没有提供自定义源代码位置的方法。默认情况下,它会查看Maven标准文件夹,即
    src/main/java
    。因为Groovy类位于
    src/main/Groovy
    内部,所以找不到它们

    根据您的项目,有两种解决方案:

    • 在Mojo的帮助下,将这些源添加到项目中:

      
      org.codehaus.mojo
      马文的

      <build>
        <sourceDirectory>src/main/groovy</sourceDirectory>
        <!-- rest of build configuration -->
      </build>
      
      
      src/main/groovy
      
      如果项目是一个纯Groovy项目,没有任何源Java文件,那么这将非常方便


    对于这两个更改中的任何一个,运行
    mvncleansite
    将生成一个Cobertura报告,在该报告中可以正确地找到Groovy源代码。

    感谢您的回答。它在类似的情况下帮助了我,但在一个开源的Scala项目中我学会了。
    <build>
      <sourceDirectory>src/main/groovy</sourceDirectory>
      <!-- rest of build configuration -->
    </build>