Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,22 @@ public abstract class AbstractInstrumentationMojo extends AbstractMojo {
@Parameter(required = false)
private String excludeClassesRegularExpression;

/**
* Skips the tests and therefore the execution of this mojo.
*/
@Parameter(property = "skipTests", defaultValue = "${skipTests}")
private boolean skipTests;

protected boolean skipExecution() {
return skipTests;
}

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skipExecution()) {
getLog().info("Tests are skipped, skipping execution");
return;
}
final File classesDirectory = new File(this.classesPath);
final File backupClassesDirectory = new File(this.backupPath);
final File destinationDirectory = new File(this.instrumentationPath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;

/**
Expand All @@ -35,4 +36,15 @@
)
public class ITInstrumentationMojo extends AbstractInstrumentationMojo {

/**
* Skips integration the tests and therefore the execution of this mojo.
*/
@Parameter(defaultValue = "${skipIntegrationTests}", required = false)
private boolean skipIntegrationTests;

@Override
protected boolean skipExecution() {
return super.skipExecution() || skipIntegrationTests;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import org.apache.maven.plugins.annotations.LifecyclePhase;
import org.apache.maven.plugins.annotations.Mojo;
import org.apache.maven.plugins.annotations.Parameter;
import org.apache.maven.plugins.annotations.ResolutionScope;

/**
Expand All @@ -34,4 +35,15 @@
requiresDependencyResolution = ResolutionScope.COMPILE
)
public class UTInstrumentationMojo extends AbstractInstrumentationMojo {

/**
* Skips unit the tests and therefore the execution of this mojo.
*/
@Parameter(defaultValue = "${skipUnitTests}", required = false)
private boolean skipUnitTests;

@Override
protected boolean skipExecution() {
return super.skipExecution() || skipUnitTests;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public abstract class AbstractCleaningReportMojo extends AbstractReportMojo {
private String dataFilePath;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
protected void doExecute() throws MojoExecutionException, MojoFailureException {
final File dataFile = new File(dataFilePath() + AbstractInstrumentationMojo.DATA_FILE_NAME);
final File destinationDataFile = new File(coverageReportPath() + AbstractInstrumentationMojo.DATA_FILE_NAME);
final File sourcesDirectory = new File(sourcesPath());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import net.sourceforge.cobertura.reporting.Report;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.plugins.annotations.Parameter;
import com.qualinsight.mojo.cobertura.transformation.CoberturaToSonarQubeCoverageReportConversionProcessingException;
import com.qualinsight.mojo.cobertura.transformation.CoberturaToSonarQubeCoverageReportConverter;
Expand Down Expand Up @@ -66,6 +67,12 @@ public abstract class AbstractReportMojo extends AbstractMojo {
@Parameter(defaultValue = "false", required = false)
private boolean calculateMethodComplexity;

/**
* Skips the tests and therefore the execution of this mojo.
*/
@Parameter(property = "skipTests", defaultValue = "${skipTests}")
private boolean skipTests;

protected void prepareFileSystem(final File destinationDirectory) throws MojoExecutionException {
getLog().debug("Preparing Cobertura report generation directories");
if (!destinationDirectory.exists() && !destinationDirectory.mkdirs()) {
Expand Down Expand Up @@ -161,4 +168,18 @@ Arguments buildCoberturaReportArguments(final File sourcesDirectory, final File
.build();
}

protected boolean skipExecution() {
return skipTests;
}

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
if (skipExecution()) {
getLog().info("Tests are skipped, skipping execution");
return;
}
doExecute();
}

protected abstract void doExecute() throws MojoExecutionException, MojoFailureException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,17 @@ public class ITCoverageReportMojo extends AbstractCleaningReportMojo {
@Parameter(defaultValue = "${project.build.directory}/cobertura/it/", required = false)
private String coverageReportPath;

/**
* Skips integration the tests and therefore the execution of this mojo.
*/
@Parameter(defaultValue = "${skipIntegrationTests}", required = false)
private boolean skipIntegrationTests;

@Override
protected boolean skipExecution() {
return super.skipExecution() || skipIntegrationTests;
}

@Override
String coverageReportPath() {
return this.coverageReportPath;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class OverallCoverageReportMojo extends AbstractReportMojo {
private String overallCoverageReportPath;

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
public void doExecute() throws MojoExecutionException, MojoFailureException {
final File sourcesDirectory = new File(sourcesPath());
final File overallCoverageDirectory = new File(coverageReportPath());
final File utCoverageDataFile = new File(this.utCoverageDataFileLocation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,19 @@ public class UTCoverageReportMojo extends AbstractCleaningReportMojo {
@Parameter(defaultValue = "${project.build.directory}/cobertura/ut/", readonly = true)
private String coverageReportPath;

/**
* Skips unit the tests and therefore the execution of this mojo.
*/
@Parameter(defaultValue = "${skipUnitTests}", required = false)
private boolean skipUnitTests;

@Override
protected boolean skipExecution() {
return super.skipExecution() || skipUnitTests;
}

@Override
String coverageReportPath() {
return this.coverageReportPath;
}

}