diff options
author | Mirko Friedenhagen <mfriedenhagen@gmail.com> | 2013-12-22 13:25:00 -0800 |
---|---|---|
committer | Mirko Friedenhagen <mfriedenhagen@gmail.com> | 2013-12-22 13:25:00 -0800 |
commit | e8dc8725c4199dd2985d6ec4d602c2dc51f2e9ed (patch) | |
tree | 8e2bb551849e5e86e29d80bc683d917dcfed0c74 | |
parent | 8426630ead77abfa3c110581dea4d43dda331430 (diff) | |
parent | 78f2d42aa6b33a607e1d0f25391324cb9b06a5d5 (diff) | |
download | jacoco-e8dc8725c4199dd2985d6ec4d602c2dc51f2e9ed.tar.gz |
Merge pull request #171 from jacoco/issue-171
Align skip conditions and messages and give reasons
6 files changed, 25 insertions, 22 deletions
diff --git a/jacoco-maven-plugin.test/it/it-multi-module/verify.bsh b/jacoco-maven-plugin.test/it/it-multi-module/verify.bsh index 519b4860..b70e1910 100644 --- a/jacoco-maven-plugin.test/it/it-multi-module/verify.bsh +++ b/jacoco-maven-plugin.test/it/it-multi-module/verify.bsh @@ -13,7 +13,7 @@ import java.io.*; import org.codehaus.plexus.util.*; String buildLog = FileUtils.fileRead( new File( basedir, "build.log" ) ); -if ( buildLog.indexOf( "Skipping JaCoCo execution due to missing classes directory." ) < 0 ) { +if ( buildLog.indexOf( "Skipping JaCoCo execution due to missing classes directory:" ) < 0 ) { throw new RuntimeException( "Execution should be skipped when target/classes does not exist." ); } diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java index c99f7083..823f9fec 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java @@ -58,14 +58,9 @@ public abstract class AbstractJacocoMojo extends AbstractMojo { public final void execute() throws MojoExecutionException, MojoFailureException { - if ("pom".equals(project.getPackaging())) { - getLog().info( - "Skipping JaCoCo for project with packaging type 'pom'"); - skipMojo(); - return; - } if (skip) { - getLog().info("Skipping JaCoCo execution"); + getLog().info( + "Skipping JaCoCo execution because property jacoco.skip is set."); skipMojo(); return; } diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java index acbed957..979d7fa1 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java @@ -143,25 +143,23 @@ public abstract class AbstractReportMojo extends AbstractMavenReport { @Override public boolean canGenerateReport() { - if ("pom".equals(project.getPackaging())) { - getLog().info( - "Skipping JaCoCo for project with packaging type 'pom'"); - return false; - } if (skip) { - getLog().info("Skipping JaCoCo execution"); + getLog().info( + "Skipping JaCoCo execution because property jacoco.skip is set."); return false; } if (!getDataFile().exists()) { getLog().info( - "Skipping JaCoCo execution due to missing execution data file"); + "Skipping JaCoCo execution due to missing execution data file:" + + getDataFile()); return false; } final File classesDirectory = new File(getProject().getBuild() .getOutputDirectory()); if (!classesDirectory.exists()) { getLog().info( - "Skipping JaCoCo execution due to missing classes directory."); + "Skipping JaCoCo execution due to missing classes directory:" + + classesDirectory); return false; } return true; diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java index 882ab145..60f1761f 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java @@ -40,7 +40,7 @@ import org.jacoco.report.check.RulesChecker; */ public class CheckMojo extends AbstractJacocoMojo implements IViolationsOutput { - private static final String MSG_SKIPPING = "Skipping JaCoCo execution due to missing execution data file"; + private static final String MSG_SKIPPING = "Skipping JaCoCo execution due to missing execution data file:"; private static final String CHECK_SUCCESS = "All coverage checks have been met."; private static final String CHECK_FAILED = "Coverage checks have not been met. See log for details."; @@ -134,7 +134,14 @@ public class CheckMojo extends AbstractJacocoMojo implements IViolationsOutput { private boolean canCheckCoverage() { if (!dataFile.exists()) { - getLog().info(MSG_SKIPPING); + getLog().info(MSG_SKIPPING + dataFile); + return false; + } + final File classesDirectory = new File(getProject().getBuild().getOutputDirectory()); + if (!classesDirectory.exists()) { + getLog().info( + "Skipping JaCoCo execution due to missing classes directory:" + + classesDirectory); return false; } return true; diff --git a/jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java b/jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java index e6ed6c26..a9b0654a 100644 --- a/jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java +++ b/jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java @@ -51,10 +51,12 @@ public class InstrumentMojo extends AbstractJacocoMojo { final File originalClassesDir = new File(getProject().getBuild() .getDirectory(), "generated-classes/jacoco"); originalClassesDir.mkdirs(); - final File classesDir = new File(getProject().getBuild() - .getOutputDirectory()); - if (!classesDir.isDirectory()) { - getLog().info("skip non existing outputDirectory " + classesDir); + final File classesDir = new File( + getProject().getBuild().getOutputDirectory()); + if (!classesDir.exists()) { + getLog().info( + "Skipping JaCoCo execution due to missing classes directory:" + + classesDir); return; } diff --git a/org.jacoco.doc/docroot/doc/changes.html b/org.jacoco.doc/docroot/doc/changes.html index 296c916b..77642479 100644 --- a/org.jacoco.doc/docroot/doc/changes.html +++ b/org.jacoco.doc/docroot/doc/changes.html @@ -23,6 +23,7 @@ <h3>Fixed Bugs</h3> <ul> <li>Skip jacoco instrumentation for mvn modules with package type ear (GitHub <a href="https://github.com/jacoco/jacoco/issues/169">#169</a>).</li> + <li>Align skip conditions and messages and give reasons (GitHub <a href="https://github.com/jacoco/jacoco/issues/171">#171</a>).</li> <li>Restrict visibility of methods in abstract classes of jacoco-maven-plugin (GitHub <a href="https://github.com/jacoco/jacoco/issues/175">#175</a>).</li> </ul> |