diff --git a/pom.xml b/pom.xml index 8cb9658..35d0cd8 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ diff-coverage-maven-plugin ${project.groupId}:${project.artifactId} maven-plugin - 0.3.1 + 0.3.2.2 Diff coverage maven plugin builds code coverage report of new and modified code based on a provided diff @@ -55,13 +55,19 @@ UTF-8 + official + HEAD + + 3.9.4 + 3.9.0 + 1.4.32 true - official 4.13.2 - 3.8.6 - HEAD + 0.8.10 + 0.9.5 + 0.3.2 @@ -82,7 +88,7 @@ org.apache.maven.plugin-tools maven-plugin-annotations - 3.6.4 + ${maven.plugin.tools.version} provided @@ -107,17 +113,17 @@ com.github.form-com.diff-coverage-gradle jacoco-filtering-extension - 0.9.5 + ${delt.coverage.core.version} org.jacoco org.jacoco.core - 0.8.8 + ${jacoco.version} org.jacoco org.jacoco.report - 0.8.8 + ${jacoco.version} org.eclipse.jgit @@ -125,6 +131,12 @@ 6.2.0.202206071550-r + + org.codehaus.plexus + plexus-utils + 3.5.1 + + junit junit @@ -159,13 +171,13 @@ org.apache.maven.plugins maven-plugin-plugin - 3.6.4 + ${maven.plugin.tools.version} org.jacoco jacoco-maven-plugin - 0.8.8 + ${jacoco.version} pre-unit-test @@ -257,7 +269,7 @@ com.github.surpsg diff-coverage-maven-plugin - 0.3.0 + ${diff.coverage.plugin.version} ${project.build.directory}/fullCoverage.exec @@ -346,4 +358,4 @@ - + \ No newline at end of file diff --git a/src/it/exclude-classes/pom.xml b/src/it/exclude-classes/pom.xml index 3e68991..c2f4a1f 100644 --- a/src/it/exclude-classes/pom.xml +++ b/src/it/exclude-classes/pom.xml @@ -38,7 +38,6 @@ com.github.surpsg diff-coverage-maven-plugin - 0.3.0 diffFile.patch diff --git a/src/it/excluded-all-classes/pom.xml b/src/it/excluded-all-classes/pom.xml index e52b3ab..a7a33ba 100644 --- a/src/it/excluded-all-classes/pom.xml +++ b/src/it/excluded-all-classes/pom.xml @@ -38,7 +38,6 @@ com.github.surpsg diff-coverage-maven-plugin - 0.3.0 diffFile.patch diff --git a/src/it/include-classes/pom.xml b/src/it/include-classes/pom.xml index f863659..95f74d1 100644 --- a/src/it/include-classes/pom.xml +++ b/src/it/include-classes/pom.xml @@ -38,7 +38,6 @@ com.github.surpsg diff-coverage-maven-plugin - 0.3.0 diffFile.patch diff --git a/src/it/include-exclude-classes/pom.xml b/src/it/include-exclude-classes/pom.xml index bea4447..a77c0fb 100644 --- a/src/it/include-exclude-classes/pom.xml +++ b/src/it/include-exclude-classes/pom.xml @@ -38,7 +38,6 @@ com.github.surpsg diff-coverage-maven-plugin - 0.3.0 diffFile.patch diff --git a/src/it/multi-module-reports-exclusions-check/report/pom.xml b/src/it/multi-module-reports-exclusions-check/report/pom.xml index 9cafba2..0d287df 100644 --- a/src/it/multi-module-reports-exclusions-check/report/pom.xml +++ b/src/it/multi-module-reports-exclusions-check/report/pom.xml @@ -53,6 +53,30 @@ + + maven-resources-plugin + 3.0.2 + + + copy-resource-one + package + + copy-resources + + + target + + + ../moduleA/target + + + ../moduleB/target + + + + + + diff --git a/src/it/multi-module-reports-exclusions-check/verify.bsh b/src/it/multi-module-reports-exclusions-check/verify.bsh index 474ef43..ca3fd21 100644 --- a/src/it/multi-module-reports-exclusions-check/verify.bsh +++ b/src/it/multi-module-reports-exclusions-check/verify.bsh @@ -17,9 +17,9 @@ if ( !csvReportFile.exists() || !csvReportFile.isFile() ) { throw new RuntimeException( "CSV report file wasn't found: " + csvReportFile.getAbsolutePath() ); } -String expectedInstructionsErrMsg = "[INFO] New violation: Rule violated for bundle multi-module-reports-exclusions-check: instructions covered ratio is 0.5, but expected minimum is 0.6"; -String expectedLinesErrMsg = "[INFO] New violation: Rule violated for bundle multi-module-reports-exclusions-check: lines covered ratio is 0.5, but expected minimum is 0.7"; -String unexpectedBranchesErrMsg = "[INFO] New violation: Rule violated for bundle multi-module-reports-exclusions-check: branches covered ratio"; +String expectedInstructionsErrMsg = "[INFO] New violation: Rule violated for bundle report: instructions covered ratio is 0.5, but expected minimum is 0.6"; +String expectedLinesErrMsg = "[INFO] New violation: Rule violated for bundle report: lines covered ratio is 0.5, but expected minimum is 0.7"; +String unexpectedBranchesErrMsg = "[INFO] New violation: Rule violated for bundle report: branches covered ratio"; String buildLog = FileUtils.fileRead( new File( basedir, "build.log" ) ); if ( !buildLog.contains( expectedInstructionsErrMsg ) ) { diff --git a/src/it/multi-module-reports-generation-check/report/diffFile.patch b/src/it/multi-module-reports-generation-check/moduleA/diffFile.patch similarity index 99% rename from src/it/multi-module-reports-generation-check/report/diffFile.patch rename to src/it/multi-module-reports-generation-check/moduleA/diffFile.patch index f44a2cb..933e258 100644 --- a/src/it/multi-module-reports-generation-check/report/diffFile.patch +++ b/src/it/multi-module-reports-generation-check/moduleA/diffFile.patch @@ -41,4 +41,4 @@ new file mode 100644 + } + System.out.println("return"); + } -+} ++} \ No newline at end of file diff --git a/src/it/multi-module-reports-generation-check/moduleA/pom.xml b/src/it/multi-module-reports-generation-check/moduleA/pom.xml index a590d04..461fda7 100644 --- a/src/it/multi-module-reports-generation-check/moduleA/pom.xml +++ b/src/it/multi-module-reports-generation-check/moduleA/pom.xml @@ -11,5 +11,30 @@ it-check-passes 1.0-SNAPSHOT + + + + + com.github.surpsg + diff-coverage-maven-plugin + + + diffFile.patch + + **/custom-jacoco-name.exec + + **/exclude/**/ExcludeMe.class + + + + + + diffCoverage + + + + + + diff --git a/src/it/multi-module-reports-generation-check/moduleB/diffFile.patch b/src/it/multi-module-reports-generation-check/moduleB/diffFile.patch new file mode 100644 index 0000000..933e258 --- /dev/null +++ b/src/it/multi-module-reports-generation-check/moduleB/diffFile.patch @@ -0,0 +1,44 @@ +Index: src/it/multi-module-reports-generation-check/moduleB/src/main/java/com/test/moduleB/ClassModuleB.java +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/it/multi-module-reports-generation-check/moduleB/src/main/java/com/test/moduleB/ClassModuleB.java b/src/it/multi-module-reports-generation-check/moduleB/src/main/java/com/test/moduleB/ClassModuleB.java +new file mode 100644 +--- /dev/null (date 1628714536415) ++++ b/src/it/multi-module-reports-generation-check/moduleB/src/main/java/com/test/moduleB/ClassModuleB.java (date 1628714536415) +@@ -0,0 +1,12 @@ ++package com.test.moduleB; ++ ++public class ClassModuleB { ++ public void sayHello(boolean a) { ++ if (a) { ++ System.out.println("if"); ++ } else { ++ System.out.println("else"); ++ } ++ System.out.println("return"); ++ } ++} +Index: src/it/multi-module-reports-generation-check/moduleA/src/main/java/com/test/moduleA/ClassModuleA.java +IDEA additional info: +Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP +<+>UTF-8 +=================================================================== +diff --git a/src/it/multi-module-reports-generation-check/moduleA/src/main/java/com/test/moduleA/ClassModuleA.java b/src/it/multi-module-reports-generation-check/moduleA/src/main/java/com/test/moduleA/ClassModuleA.java +new file mode 100644 +--- /dev/null (date 1628714375075) ++++ b/src/it/multi-module-reports-generation-check/moduleA/src/main/java/com/test/moduleA/ClassModuleA.java (date 1628714375075) +@@ -0,0 +1,12 @@ ++package com.test.moduleA; ++ ++public class ClassModuleA { ++ public void sayHello(boolean a) { ++ if (a) { ++ System.out.println("if"); ++ } else { ++ System.out.println("else"); ++ } ++ System.out.println("return"); ++ } ++} \ No newline at end of file diff --git a/src/it/multi-module-reports-generation-check/moduleB/pom.xml b/src/it/multi-module-reports-generation-check/moduleB/pom.xml index a9db0bf..f515704 100644 --- a/src/it/multi-module-reports-generation-check/moduleB/pom.xml +++ b/src/it/multi-module-reports-generation-check/moduleB/pom.xml @@ -11,4 +11,28 @@ it-check-passes 1.0-SNAPSHOT + + + + com.github.surpsg + diff-coverage-maven-plugin + + + diffFile.patch + + **/custom-jacoco-name.exec + + **/exclude/**/ExcludeMe.class + + + + + + diffCoverage + + + + + + diff --git a/src/it/multi-module-reports-generation-check/pom.xml b/src/it/multi-module-reports-generation-check/pom.xml index ec61614..660d472 100644 --- a/src/it/multi-module-reports-generation-check/pom.xml +++ b/src/it/multi-module-reports-generation-check/pom.xml @@ -25,7 +25,6 @@ moduleA moduleB - report diff --git a/src/it/multi-module-reports-generation-check/report/pom.xml b/src/it/multi-module-reports-generation-check/report/pom.xml deleted file mode 100644 index f6ef936..0000000 --- a/src/it/multi-module-reports-generation-check/report/pom.xml +++ /dev/null @@ -1,54 +0,0 @@ - - - - 4.0.0 - - it-check-passes-report - 1.0-SNAPSHOT - pom - - - jacoco - it-check-passes - 1.0-SNAPSHOT - - - - - jacoco - it-check-passes-moduleA - 1.0-SNAPSHOT - - - jacoco - it-check-passes-moduleB - 1.0-SNAPSHOT - - - - - - - com.github.surpsg - diff-coverage-maven-plugin - - - diffFile.patch - - **/custom-jacoco-name.exec - - **/exclude/**/ExcludeMe.class - - - - - - diffCoverage - - - - - - - diff --git a/src/it/multi-module-reports-generation-check/verify.bsh b/src/it/multi-module-reports-generation-check/verify.bsh index 94eeb26..843e7ad 100644 --- a/src/it/multi-module-reports-generation-check/verify.bsh +++ b/src/it/multi-module-reports-generation-check/verify.bsh @@ -1,18 +1,34 @@ import java.io.*; import org.codehaus.plexus.util.*; -File reportsDir = new File(basedir, "/report/target/site/diffCoverage"); -File htmlReportDir = new File( reportsDir, "/html" ); -if ( !htmlReportDir.exists() || !htmlReportDir.isDirectory() ) { - throw new RuntimeException( "Html report dir wasn't found: " + htmlReportDir.getAbsolutePath() ); +File moduleADir = new File(basedir, "/moduleA/target/site/diffCoverage"); +File htmlModuleADir = new File( moduleADir, "/html" ); +if ( !htmlModuleADir.exists() || !htmlModuleADir.isDirectory() ) { + throw new RuntimeException( "Html report dir wasn't found: " + htmlModuleADir.getAbsolutePath() ); } -File xmlReportFile = new File( reportsDir, "diff-coverage.xml" ); -if ( !xmlReportFile.exists() || !xmlReportFile.isFile() ) { - throw new RuntimeException( "Xml report file wasn't found: " + xmlReportFile.getAbsolutePath() ); +File xmlModuleAFile = new File( moduleADir, "diff-coverage.xml" ); +if ( !xmlModuleAFile.exists() || !xmlModuleAFile.isFile() ) { + throw new RuntimeException( "Xml report file wasn't found: " + xmlModuleAFile.getAbsolutePath() ); } -File csvReportFile = new File( reportsDir, "diff-coverage.csv" ); -if ( !csvReportFile.exists() || !csvReportFile.isFile() ) { - throw new RuntimeException( "CSV report file wasn't found: " + csvReportFile.getAbsolutePath() ); +File csvModuleAFile = new File( moduleADir, "diff-coverage.csv" ); +if ( !csvModuleAFile.exists() || !csvModuleAFile.isFile() ) { + throw new RuntimeException( "CSV report file wasn't found: " + csvModuleAFile.getAbsolutePath() ); } + +File moduleBDir = new File(basedir, "/moduleB/target/site/diffCoverage"); +File htmlModuleBDir = new File( moduleBDir, "/html" ); +if ( !htmlModuleBDir.exists() || !htmlModuleBDir.isDirectory() ) { + throw new RuntimeException( "Html report dir wasn't found: " + htmlModuleBDir.getAbsolutePath() ); +} + +File xmlModuleBFile = new File( moduleBDir, "diff-coverage.xml" ); +if ( !xmlModuleBFile.exists() || !xmlModuleBFile.isFile() ) { + throw new RuntimeException( "Xml report file wasn't found: " + xmlModuleBFile.getAbsolutePath() ); +} + +File csvModuleBFile = new File( moduleBDir, "diff-coverage.csv" ); +if ( !csvModuleBFile.exists() || !csvModuleBFile.isFile() ) { + throw new RuntimeException( "CSV report file wasn't found: " + csvModuleBFile.getAbsolutePath() ); +} \ No newline at end of file diff --git a/src/it/multi-project-check/B/diffFile.patch b/src/it/multi-project-check/B/diffFile.patch new file mode 100644 index 0000000..462ed84 --- /dev/null +++ b/src/it/multi-project-check/B/diffFile.patch @@ -0,0 +1,55 @@ +diff --git a/B/src/main/java/com/example/b/BApplication.java b/B/src/main/java/com/example/b/BApplication.java +index c82bb4d..20737f6 100644 +--- a/B/src/main/java/com/example/b/BApplication.java ++++ b/B/src/main/java/com/example/b/BApplication.java +@@ -17,4 +17,8 @@ public class BApplication { + return 1; + } + ++ public int test() { ++ return 2; ++ } ++ + } +diff --git a/B/src/test/java/com/example/b/BApplicationTests.java b/B/src/test/java/com/example/b/BApplicationTests.java +index 0ec3368..28ba389 100644 +--- a/B/src/test/java/com/example/b/BApplicationTests.java ++++ b/B/src/test/java/com/example/b/BApplicationTests.java +@@ -21,7 +21,7 @@ class BApplicationTests { + @Test + public void doesItWork() { + assertEquals(1, b.A()); +- System.out.println("HEREIAMONCEAGAIN\n\n\n\n\n\n\n\n\n\n\n"); ++ assertEquals(2, b.test()); + } + + } +diff --git a/pom.xml b/pom.xml +index 52c8385..8b1cad2 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -77,7 +77,7 @@ + + com.github.surpsg + diff-coverage-maven-plugin +- 0.3.2-SNAPSHOT ++ 0.3.1 + + + org.apache.maven.plugins +@@ -101,6 +101,7 @@ + + + ++ + + + org.jacoco +@@ -136,7 +137,6 @@ + + diffCoverage + +- github + + + diff --git a/src/it/multi-project-check/B/pom.xml b/src/it/multi-project-check/B/pom.xml new file mode 100644 index 0000000..a450998 --- /dev/null +++ b/src/it/multi-project-check/B/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + com.example + demo + 0.0.1-SNAPSHOT + + com.example + B + 0.0.1-SNAPSHOT + B + B + + 11 + + + + org.springframework.boot + spring-boot-starter + 2.7.0 + + + + org.springframework.boot + spring-boot-starter-test + 2.7.0 + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/it/multi-project-check/B/src/main/java/com/example/b/BApplication.java b/src/it/multi-project-check/B/src/main/java/com/example/b/BApplication.java new file mode 100644 index 0000000..20737f6 --- /dev/null +++ b/src/it/multi-project-check/B/src/main/java/com/example/b/BApplication.java @@ -0,0 +1,24 @@ +package com.example.b; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class BApplication { + + public static void main(String[] args) { + SpringApplication.run(BApplication.class, args); + } + + + + + public int A() { + return 1; + } + + public int test() { + return 2; + } + +} diff --git a/src/it/multi-project-check/B/src/test/java/com/example/b/BApplicationTests.java b/src/it/multi-project-check/B/src/test/java/com/example/b/BApplicationTests.java new file mode 100644 index 0000000..28ba389 --- /dev/null +++ b/src/it/multi-project-check/B/src/test/java/com/example/b/BApplicationTests.java @@ -0,0 +1,27 @@ +package com.example.b; + +import org.junit.jupiter.api.Test; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import sun.jvm.hotspot.utilities.Assert; + +import static org.junit.jupiter.api.Assertions.assertEquals; + + +@SpringBootTest +class BApplicationTests { + + @Autowired + private BApplication b; + + @Test + void contextLoads() { + } + + @Test + public void doesItWork() { + assertEquals(1, b.A()); + assertEquals(2, b.test()); + } + +} diff --git a/src/it/multi-project-check/C/diffFile.patch b/src/it/multi-project-check/C/diffFile.patch new file mode 100644 index 0000000..462ed84 --- /dev/null +++ b/src/it/multi-project-check/C/diffFile.patch @@ -0,0 +1,55 @@ +diff --git a/B/src/main/java/com/example/b/BApplication.java b/B/src/main/java/com/example/b/BApplication.java +index c82bb4d..20737f6 100644 +--- a/B/src/main/java/com/example/b/BApplication.java ++++ b/B/src/main/java/com/example/b/BApplication.java +@@ -17,4 +17,8 @@ public class BApplication { + return 1; + } + ++ public int test() { ++ return 2; ++ } ++ + } +diff --git a/B/src/test/java/com/example/b/BApplicationTests.java b/B/src/test/java/com/example/b/BApplicationTests.java +index 0ec3368..28ba389 100644 +--- a/B/src/test/java/com/example/b/BApplicationTests.java ++++ b/B/src/test/java/com/example/b/BApplicationTests.java +@@ -21,7 +21,7 @@ class BApplicationTests { + @Test + public void doesItWork() { + assertEquals(1, b.A()); +- System.out.println("HEREIAMONCEAGAIN\n\n\n\n\n\n\n\n\n\n\n"); ++ assertEquals(2, b.test()); + } + + } +diff --git a/pom.xml b/pom.xml +index 52c8385..8b1cad2 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -77,7 +77,7 @@ + + com.github.surpsg + diff-coverage-maven-plugin +- 0.3.2-SNAPSHOT ++ 0.3.1 + + + org.apache.maven.plugins +@@ -101,6 +101,7 @@ + + + ++ + + + org.jacoco +@@ -136,7 +137,6 @@ + + diffCoverage + +- github + + + diff --git a/src/it/multi-project-check/C/pom.xml b/src/it/multi-project-check/C/pom.xml new file mode 100644 index 0000000..1c2af64 --- /dev/null +++ b/src/it/multi-project-check/C/pom.xml @@ -0,0 +1,42 @@ + + + 4.0.0 + + com.example + demo + 0.0.1-SNAPSHOT + + com.example + C + 0.0.1-SNAPSHOT + C + C + + 11 + + + + org.springframework.boot + spring-boot-starter + 2.7.0 + + + + org.springframework.boot + spring-boot-starter-test + 2.7.0 + test + + + + + + + org.springframework.boot + spring-boot-maven-plugin + + + + + diff --git a/src/it/multi-project-check/C/src/main/java/com/example/c/CApplication.java b/src/it/multi-project-check/C/src/main/java/com/example/c/CApplication.java new file mode 100644 index 0000000..3dba258 --- /dev/null +++ b/src/it/multi-project-check/C/src/main/java/com/example/c/CApplication.java @@ -0,0 +1,13 @@ +package com.example.c; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class CApplication { + + public static void main(String[] args) { + SpringApplication.run(CApplication.class, args); + } + +} diff --git a/src/it/multi-project-check/C/src/test/java/com/example/c/CApplicationTests.java b/src/it/multi-project-check/C/src/test/java/com/example/c/CApplicationTests.java new file mode 100644 index 0000000..2a78498 --- /dev/null +++ b/src/it/multi-project-check/C/src/test/java/com/example/c/CApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.c; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class CApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/src/it/multi-project-check/diffFile.patch b/src/it/multi-project-check/diffFile.patch new file mode 100644 index 0000000..462ed84 --- /dev/null +++ b/src/it/multi-project-check/diffFile.patch @@ -0,0 +1,55 @@ +diff --git a/B/src/main/java/com/example/b/BApplication.java b/B/src/main/java/com/example/b/BApplication.java +index c82bb4d..20737f6 100644 +--- a/B/src/main/java/com/example/b/BApplication.java ++++ b/B/src/main/java/com/example/b/BApplication.java +@@ -17,4 +17,8 @@ public class BApplication { + return 1; + } + ++ public int test() { ++ return 2; ++ } ++ + } +diff --git a/B/src/test/java/com/example/b/BApplicationTests.java b/B/src/test/java/com/example/b/BApplicationTests.java +index 0ec3368..28ba389 100644 +--- a/B/src/test/java/com/example/b/BApplicationTests.java ++++ b/B/src/test/java/com/example/b/BApplicationTests.java +@@ -21,7 +21,7 @@ class BApplicationTests { + @Test + public void doesItWork() { + assertEquals(1, b.A()); +- System.out.println("HEREIAMONCEAGAIN\n\n\n\n\n\n\n\n\n\n\n"); ++ assertEquals(2, b.test()); + } + + } +diff --git a/pom.xml b/pom.xml +index 52c8385..8b1cad2 100644 +--- a/pom.xml ++++ b/pom.xml +@@ -77,7 +77,7 @@ + + com.github.surpsg + diff-coverage-maven-plugin +- 0.3.2-SNAPSHOT ++ 0.3.1 + + + org.apache.maven.plugins +@@ -101,6 +101,7 @@ + + + ++ + + + org.jacoco +@@ -136,7 +137,6 @@ + + diffCoverage + +- github + + + diff --git a/src/it/multi-project-check/pom.xml b/src/it/multi-project-check/pom.xml new file mode 100644 index 0000000..b2b1c86 --- /dev/null +++ b/src/it/multi-project-check/pom.xml @@ -0,0 +1,151 @@ + + + 4.0.0 + com.example + demo + 0.0.1-SNAPSHOT + demo + demo + + + B + C + + pom + + + 11 + 6 + 6 + 1.6 + + + + + + org.springframework.boot + spring-boot-starter + 2.7.0 + + + org.springframework.boot + spring-boot-starter + 2.7.0 + + + + + + + org.springframework.boot + spring-boot-starter + 2.7.0 + + + + org.springframework.boot + spring-boot-starter-test + 2.7.0 + test + + + + + + + + org.springframework.boot + spring-boot-starter-test + 2.7.0 + + + + org.springframework.boot + spring-boot-starter + 2.7.0 + + + org.codehaus.mojo + exec-maven-plugin + 1.5.0 + + + org.jacoco + jacoco-maven-plugin + 0.8.7 + + + com.github.surpsg + diff-coverage-maven-plugin + 0.3.0 + + + org.apache.maven.plugins + maven-surefire-plugin + 3.0.0-M4 + + 1.0C + true + @{jacocoArgLine} -Xmx2G --illegal-access=permit + 3 + + + WARN + + true + + logging.properties + + + + + + + + + + org.jacoco + jacoco-maven-plugin + + + prepare-agent + + prepare-agent + + + jacocoArgLine + + com.example.b.* + com.example.c.* + + + + + coverage-report + post-integration-test + + report + + + + + + com.github.surpsg + diff-coverage-maven-plugin + + + diffFile.patch + + + + + + diffCoverage + + + + + + + + diff --git a/src/it/multi-project-check/verify.bsh b/src/it/multi-project-check/verify.bsh new file mode 100644 index 0000000..ca886e4 --- /dev/null +++ b/src/it/multi-project-check/verify.bsh @@ -0,0 +1,15 @@ +import java.io.*; +import org.codehaus.plexus.util.*; + +String expectedInstructionsErrMsg = "[WARNING] Fail on violations: false. Found violations: 0."; + +String unexpectedErrMsg = "[INFO] New violation: Rule violated for bundle "; + +String buildLog = FileUtils.fileRead( new File( basedir, "build.log" ) ); +if ( !buildLog.contains( expectedInstructionsErrMsg ) ) { + throw new RuntimeException( "Expected message: " + expectedInstructionsErrMsg ); +} +if ( buildLog.contains( unexpectedErrMsg ) ) { + throw new RuntimeException( "UnExpected message: " + unexpectedErrMsg ); +} + diff --git a/src/main/kotlin/com/github/surpsg/DiffCoverageMojo.kt b/src/main/kotlin/com/github/surpsg/DiffCoverageMojo.kt index 396a7ec..b2d8fc5 100644 --- a/src/main/kotlin/com/github/surpsg/DiffCoverageMojo.kt +++ b/src/main/kotlin/com/github/surpsg/DiffCoverageMojo.kt @@ -20,6 +20,9 @@ class DiffCoverageMojo : AbstractMojo() { @Parameter(property = "reactorProjects", required = true, readonly = true) private lateinit var reactorProjects: MutableList + @Parameter(property = "project", required = true, readonly = true) + private lateinit var project: MavenProject + @Parameter(property = "jacoco.dataFile", defaultValue = "\${project.build.directory}/jacoco.exec") private lateinit var dataFile: File @@ -45,13 +48,25 @@ class DiffCoverageMojo : AbstractMojo() { private var violations = ViolationsConfiguration() private val rootProjectDir: File - get() = reactorProjects[0].basedir + get() = project.basedir override fun execute() { val diffCoverageConfig: DiffCoverageConfig = buildDiffCoverageConfig().apply { logPluginProperties(this) } + var found = false + for (f in diffCoverageConfig.execFiles) { + if (f.isFile) { + found = true + break + } + } + if (!found) { + log.info("No exec files found skipping") + return + } + ReportGenerator(rootProjectDir, diffCoverageConfig).apply { val reportDir = File(diffCoverageConfig.reportsConfig.baseReportDir) reportDir.mkdirs() @@ -150,7 +165,8 @@ class DiffCoverageMojo : AbstractMojo() { val includePattern: String = includes.joinToString(",") val excludePattern: String = excludes.joinToString(",") return if (excludePattern.isEmpty() && includePattern == ALL_FILES_PATTERN) { - reactorProjects.map { File(it.build.outputDirectory) }.toSet() + reactorProjects.map { File(it.build.outputDirectory) } + .filter { outputDirectory -> outputDirectory.path.contains(rootProjectDir.path)}.toSet() } else { collectFilteredFiles(includePattern, excludePattern) } @@ -159,7 +175,7 @@ class DiffCoverageMojo : AbstractMojo() { private fun collectFilteredFiles(includePattern: String, excludePattern: String?): Set { return reactorProjects.asSequence() .map { project -> File(project.build.outputDirectory) } - .filter { outputDirectory -> outputDirectory.exists() } + .filter { outputDirectory -> outputDirectory.exists() && outputDirectory.path.contains(rootProjectDir.path)} .flatMap { outputDirectory -> FileUtils.getFiles( outputDirectory,