2016-09-08 10 views
2

Я использую плагин Bamboo, SonarQube и Maven для создания отчета Jacoco в SonarQube. Он генерирует файл jacoco.exec, но как отображать отчеты в SonarQube? После плагин я использую 'Нет JaCoCo анализ покрытия проекта может быть выполнен, так как нет файлов классов

<plugin> 
       <groupId>org.jacoco</groupId> 
       <artifactId>jacoco-maven-plugin</artifactId> 
       <version>0.7.7.201606060606</version> 
       <executions> 
        <execution> 
         <id>pre-unit-test</id> 
         <goals> 
          <goal>prepare-agent</goal> 
         </goals> 
         <configuration> 
          <!-- Sets the path to the file which contains the execution data. --> 
          <destFile>${project.build.directory}/jacoco.exec</destFile> 
          <!-- Sets the name of the property containing the settings for JaCoCo 
           runtime agent. --> 
          <propertyName>surefireArgLine</propertyName> 
         </configuration> 
        </execution> 
        <!-- Ensures that the code coverage report for unit tests is created 
         after unit tests have been run. --> 
        <execution> 
         <id>post-unit-test</id> 
         <phase>test</phase> 
         <goals> 
          <goal>report</goal> 
         </goals> 
         <configuration> 
          <!-- Sets the path to the file which contains the execution data. --> 
          <dataFile>${project.build.directory}/jacoco.exec</dataFile> 
          <!-- Sets the output directory for the code coverage report. --> 
          <outputDirectory>${project.reporting.outputDirectory}/jacoco-ut</outputDirectory> 
         </configuration> 
        </execution> 
       </executions> 
      </plugin> 
      <plugin> 
       <groupId>org.apache.maven.plugins</groupId> 
       <artifactId>maven-surefire-plugin</artifactId> 
       <version>2.15</version> 
       <configuration> 
        <!-- Sets the VM argument line used when unit tests are run. --> 
        <argLine>${surefireArgLine}</argLine> 
        <!-- Skips unit tests if the value of skip.unit.tests property is true --> 
        <skipTests>${skip.unit.tests}</skipTests> 
        <!-- Excludes integration tests when unit tests are run. --> 
        <excludes> 
         <exclude>**/IT*.java</exclude> 
        </excludes> 
       </configuration> 
      </plugin>' 

я получаю следующее исключение

build 08-Sep-2016 15:33:06 INFO: Sensor JaCoCoSensor 
build 08-Sep-2016 15:33:06 INFO: No JaCoCo analysis of project coverage can be done since there is no class files. 
build 08-Sep-2016 15:33:06 INFO: Sensor JaCoCoSensor (done) | time=72ms 
build 08-Sep-2016 15:33:06 INFO: Sensor JaCoCoOverallSensor 
build 08-Sep-2016 15:33:06 INFO: Analysing /opt/shared/atlassian/bamboo/xml-data/build-dir/EV-LEV362-JOB1/enterprise/projects/target/jacoco.exec 
build 08-Sep-2016 15:33:06 INFO: No JaCoCo analysis of project coverage can be done since there is no class files. 
build 08-Sep-2016 15:33:06 INFO: Sensor JaCoCoOverallSensor (done) | time=100ms 
build 08-Sep-2016 15:33:06 INFO: Sensor XmlFileSensor 
+0

Если вы встречаете этот ответ, и вы используя Gradle, а не Maven, перепрыгивайте сюда: http://docs.sonarqube.org/display/SCAN/Analyzing+with+SonarQube+Scanner+for+Gradle, это может упростить многое. – hangtwenty

ответ

8

сборки 08-Sep-2016 15:33:06 INFO: Нет JaCoCo анализ охвата проекта может быть сделано поскольку нет файлов классов.

Как говорится в журналах; проверить, если вы указали следующее:

sonar.java.binaries=classes directory, most likely target/classes 

работает лучше, если вы также можете указать (тогда не надо жаловаться на некоторые классы не найдены):

sonar.java.libraries=libraries directory, likely target/project/WEB-INF/lib