Skip to content

Commit 6ebdf13

Browse files
committed
ICU-23320 Add JaCoCo code coverage to Maven
1 parent 2c2e8ad commit 6ebdf13

File tree

1 file changed

+82
-2
lines changed

1 file changed

+82
-2
lines changed

pom.xml

Lines changed: 82 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
<exec-maven-plugin.version>3.6.3</exec-maven-plugin.version>
7474
<flatten-maven-plugin.version>1.7.3</flatten-maven-plugin.version>
7575
<google-java-style.version>1.32.0</google-java-style.version>
76+
<jacoco-maven-plugin.version>0.8.14</jacoco-maven-plugin.version>
7677
<maven-assembly-plugin.version>3.8.0</maven-assembly-plugin.version>
7778
<maven-clean-plugin.version>3.5.0</maven-clean-plugin.version>
7879
<maven-compiler-plugin.version>3.14.1</maven-compiler-plugin.version>
@@ -213,7 +214,7 @@
213214
but `site:stage` works.
214215
-->
215216
<id>unicode-org.github.io</id>
216-
<url>scp://https://unicode-org.github.io/</url>
217+
<url>https://unicode-org.github.io/</url>
217218
</site>
218219
<repository>
219220
<id>central</id>
@@ -579,7 +580,7 @@
579580
<configuration>
580581
<rulesets>
581582
<!-- Hand-picked rules -->
582-
<ruleset>tools/pmd/src/main/resources/icu4j/pmd-ruleset.xml</ruleset>
583+
<ruleset>icu4j/tools/pmd/src/main/resources/icu4j/pmd-ruleset.xml</ruleset>
583584
<!-- Uncomment the block below to enable all known checks.
584585
All of these rulesets can be specified in pmd-ruleset.xml instead.
585586
-->
@@ -621,6 +622,11 @@
621622
</java>
622623
</configuration>
623624
</plugin>
625+
<plugin>
626+
<groupId>org.jacoco</groupId>
627+
<artifactId>jacoco-maven-plugin</artifactId>
628+
<version>${jacoco-maven-plugin.version}</version>
629+
</plugin>
624630
</plugins>
625631
</pluginManagement>
626632

@@ -805,6 +811,80 @@
805811
</reporting>
806812
</profile>
807813

814+
<profile>
815+
<!--
816+
Generating a merged report, see https://www.eclemma.org/jacoco/trunk/doc/cli.html
817+
The result can be inspected starting from target/jacocoreport/html/index.html
818+
Execute these commands in cli, in the root of the ICU repo:
819+
820+
mvn clean install site site:stage -P coverage
821+
822+
rm -fr target/jacoco
823+
824+
mvn dependency:copy \
825+
-Dartifact=org.jacoco:jacoco:LATEST:zip \
826+
-DoutputDirectory=target/jacoco \
827+
-Dmdep.stripVersion=true \
828+
-q -ntp
829+
830+
unzip -q target/jacoco/jacoco.zip -d target/jacoco
831+
832+
java -jar target/jacoco/lib/jacococli.jar report \
833+
icu4j/main/core/target/jacoco.exec \
834+
icu4j/main/collate/target/jacoco.exec \
835+
icu4j/main/common_tests/target/jacoco.exec \
836+
icu4j/main/framework/target/jacoco.exec \
837+
icu4j/main/translit/target/jacoco.exec \
838+
icu4j/main/charset/target/jacoco.exec \
839+
\-\-classfiles icu4j/main/core/target/core-79.0.1-SNAPSHOT.jar \
840+
\-\-classfiles icu4j/main/collate/target/collate-79.0.1-SNAPSHOT.jar \
841+
\-\-classfiles icu4j/main/currdata/target/currdata-79.0.1-SNAPSHOT.jar \
842+
\-\-classfiles icu4j/main/langdata/target/langdata-79.0.1-SNAPSHOT.jar \
843+
\-\-classfiles icu4j/main/regiondata/target/regiondata-79.0.1-SNAPSHOT.jar \
844+
\-\-classfiles icu4j/main/translit/target/translit-79.0.1-SNAPSHOT.jar \
845+
\-\-classfiles icu4j/main/charset/target/icu4j-charset-79.0.1-SNAPSHOT.jar \
846+
\-\-sourcefiles icu4j/main/core/src/main/java \
847+
\-\-sourcefiles icu4j/main/collate/src/main/java \
848+
\-\-sourcefiles icu4j/main/currdata/src/main/java \
849+
\-\-sourcefiles icu4j/main/langdata/src/main/java \
850+
\-\-sourcefiles icu4j/main/regiondata/src/main/java \
851+
\-\-sourcefiles icu4j/main/translit/src/main/java \
852+
\-\-sourcefiles icu4j/main/charset/src/main/java \
853+
\-\-encoding utf-8 \
854+
\-\-csv target/jacocoreport/jacoco.csv \
855+
\-\-xml target/jacocoreport/jacoco.xml \
856+
\-\-html target/jacocoreport/html
857+
-->
858+
<id>coverage</id>
859+
<build>
860+
<plugins>
861+
<plugin>
862+
<groupId>org.jacoco</groupId>
863+
<artifactId>jacoco-maven-plugin</artifactId>
864+
<executions>
865+
<execution>
866+
<goals>
867+
<goal>prepare-agent</goal>
868+
</goals>
869+
</execution>
870+
<execution>
871+
<id>report</id>
872+
<phase>verify</phase>
873+
<goals>
874+
<goal>report-aggregate</goal>
875+
</goals>
876+
<configuration>
877+
<dataFileIncludes>
878+
<dataFileInclude>**/jacoco.exec</dataFileInclude>
879+
</dataFileIncludes>
880+
</configuration>
881+
</execution>
882+
</executions>
883+
</plugin>
884+
</plugins>
885+
</build>
886+
</profile>
887+
808888
</profiles>
809889

810890
</project>

0 commit comments

Comments
 (0)