aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMirko Friedenhagen <mfriedenhagen@gmail.com>2013-12-17 21:40:54 +0100
committerMirko Friedenhagen <mfriedenhagen@gmail.com>2013-12-17 21:40:54 +0100
commit40605f98c6ea94ba045f20ef450050a771d7d6b9 (patch)
tree314ad031402e6ce0dc7b431a13f236d98584ccf6
parent06eb9f37748037d850c53aad949cb9172756fac5 (diff)
downloadjacoco-40605f98c6ea94ba045f20ef450050a771d7d6b9.tar.gz
Align skip conditions and messages and give reasons.
-rw-r--r--jacoco-maven-plugin.test/it/it-multi-module/verify.bsh2
-rw-r--r--jacoco-maven-plugin/src/org/jacoco/maven/AbstractJacocoMojo.java9
-rw-r--r--jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java15
-rw-r--r--jacoco-maven-plugin/src/org/jacoco/maven/CheckMojo.java11
-rw-r--r--jacoco-maven-plugin/src/org/jacoco/maven/InstrumentMojo.java10
5 files changed, 26 insertions, 21 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 3713cd9c..df2db407 100644
--- a/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java
+++ b/jacoco-maven-plugin/src/org/jacoco/maven/AbstractReportMojo.java
@@ -144,21 +144,22 @@ 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");
+ getLog().info(
+ "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.");
+ 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/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;
}