У меня есть проект maven, и я хочу использовать jacoco
для покрытия кода. Вот соответствующий раздел моей помпы
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<executions>
<execution>
<id>pre-my-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-my-test</id>
<phase>post-my-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
Так что я могу нормально запускать свои тесты, а также отлично строить проект. Тогда я бегу
mvn clean verify org.jacoco:jacoco-maven-plugin:prepare-agent
Я продолжаю получать такие ошибки, как
ERROR] Failed to execute goal org.jacoco:jacoco-maven-plugin:0.7.5.201505241946:
report (post-my-test) on project my-project:
An error has occurred in JaCoCo Test report generation.
Error while creating report:
Error while analyzing class /path/tp/my/project/target/classes/META-INF/
bundled-dependencies/some-third-party-1-jar-with-dependencies.jar@org/slf4j/event/
EventConstants.class. Can't add different class with same name:
org/slf4j/event/EventConstants -> [Help 1]
some-third-party-1-jar-with-dependencies.jar
- это внешняя зависимость, которая у меня есть. Это банка uber / затемненная. Так что я подумал, что some-third-party-1-jar-with-dependencies.jar
также должен иметь org.slf4j
, отсюда и конфликт. Поэтому я внес изменения в пом как
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>0.7.5.201505241946</version>
<configuration>
<excludes>
<exclude>**/org/slf4j/event/EventConstants.*</exclude>
</excludes>
</configuration>
<executions>
<execution>
<id>pre-integration-test</id>
<phase>pre-integration-test</phase>
<goals>
<goal>prepare-agent</goal>
</goals>
<configuration>
<append>true</append>
<destFile>${project.build.directory}/jacoco-it.exec</destFile>
<propertyName>failsafeArgLine</propertyName>
</configuration>
</execution>
<execution>
<id>post-integration-test</id>
<phase>post-integration-test</phase>
<goals>
<goal>report</goal>
</goals>
<configuration>
<dataFile>${project.build.directory}/jacoco-it.exec</dataFile>
<outputDirectory>${project.reporting.outputDirectory}/jacoco-it</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
но я все равно получаю ту же ошибку. Как я могу убедиться, что jacoco игнорирует все повторяющиеся зависимости? Я тоже пробовал
<dependency>
<groupId>some.third.party</groupId>
<artifactId>some-third-party</artifactId>
<version>1</version>
<classifier>jar-with-dependencies</classifier>
<exclusions>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-log4j12</artifactId>
</exclusion>
<exclusion>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
</exclusion>
</exclusions>
</dependency>
но это не сработало. Возможны ли исключения из затененных / убер-банок?
Кроме того, почему жакоко заботится? Есть ли способ исправить или игнорировать эти ошибки? Как я могу решить эту проблему?
<sourcefiles> <zipfileset> <fileset dir="foo.jar"> <exclude name="org/jboss/osgi/framework/main/**/AbstractPackageAttribute*.*"/> </fileset> </zipfileset> </sourcefiles>
? - person AbtPst   schedule 04.05.2018**/event/EventConstants*
или аналогичный вариант. - person Dennis Hunziker   schedule 04.05.2018**/event/EventConstants*
, но это не сработало - person AbtPst   schedule 04.05.2018