Class JacocoReportOperation
Execution modes:
- Run tests + generate reports: Default. Uses
fromProject(BaseProject)ortestOperation(TestOperation)to run tests with the JaCoCo agent, then generates reports from the resulting execution data. - Reports from existing execution data: Call
execFiles(File...)with pre-generated*.execfiles. Tests are not executed. - Merge + run tests: Call both
execFiles(File...)andtestOperation(TestOperation). New execution data is generated and merged with the provided files before reporting.
Note: the live internal lists returned by classFiles(), execFiles(),
sourceFiles(), etc. are mutable by design to support the fluent builder pattern.
Modifying them may cause unexpected behavior.
- Since:
- 1.0
- Author:
- Erik C. Thauvin
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns the locations of Java class files.classFiles(File... classFiles) Sets the locations of Java class files.classFiles(String... classFiles) Sets the locations of Java class files.classFiles(Path... classFiles) Sets the locations of Java class files.final JacocoReportOperationclassFiles(Collection<File> classFiles) Sets the locations of Java class files.final JacocoReportOperationclassFilesPaths(Collection<Path> classFiles) Sets the locations of Java class files.final JacocoReportOperationclassFilesStrings(Collection<String> classFiles) Sets the locations of Java class files.csv()Returns the CSV report location.Sets the location of the CSV report.Sets the location of the CSV report.Sets the location of the CSV report.destFile()Returns the file to write execution data to.Sets the file to write execution data to.Sets the file to write execution data to.Sets the file to write execution data to.Disables generation of the CSV report.Disables generation of the HTML report.Disables generation of the XML report.Enables generation of all report formats (CSV, HTML, and XML).Enables generation of the CSV report.Enables generation of the HTML report.Enables generation of the XML report.encoding()Returns the source file encoding, ornullif not set (platform default will be used).Sets the source file encoding.excludes()Returns the class name patterns to exclude from coverage analysis.Sets class name patterns to exclude from the coverage analysis.final JacocoReportOperationexcludes(Collection<String> patterns) Sets class name patterns to exclude from the coverage analysis.Returns the locations of the JaCoCo *.exec files to read.Sets the locations of the JaCoCo *.exec files to read.Sets the locations of the JaCoCo *.exec files to read.Sets the locations of the JaCoCo *.exec files to read.final JacocoReportOperationexecFiles(Collection<File> execFiles) Sets the locations of the JaCoCo *.exec files to read.final JacocoReportOperationexecFilesPaths(Collection<Path> execFiles) Sets the locations of the JaCoCo *.exec files to read.final JacocoReportOperationexecFilesStrings(Collection<String> execFiles) Sets the locations of the JaCoCo *.exec files to read.voidexecute()Performs the operation execution that can be wrapped by the#executeOncecall.fromProject(BaseProject project) Configure the operation from aBaseProject.html()Returns the HTML report output directory.Sets the directory for the HTML report output.Sets the directory for the HTML report output.Sets the directory for the HTML report output.includes()Returns the class name patterns to include in coverage analysis.Sets class name patterns to include in the coverage analysis.final JacocoReportOperationincludes(Collection<String> patterns) Sets class name patterns to include in the coverage analysis.booleanReturns whether CSV report generation is disabled.booleanReturns whether HTML report generation is disabled.booleanisQuiet()Return the status of the quiet flag.booleanReturns whether XML report generation is disabled.name()Returns the name used for the report.Sets the name used for the report.quiet(boolean quiet) Suppresses all output.Returns the locations of the source files.sourceFiles(File... sourceFiles) Sets the locations of the source files.sourceFiles(String... sourceFiles) Sets the locations of the source files.sourceFiles(Path... sourceFiles) Sets the locations of the source files.final JacocoReportOperationsourceFiles(Collection<File> sourceFiles) Sets the locations of the source files.final JacocoReportOperationsourceFilesPaths(Collection<Path> sourceFiles) Sets the locations of the source files.final JacocoReportOperationsourceFilesStrings(Collection<String> sourceFiles) Sets the locations of the source files.inttabWidth()Returns the tab stop width for the source pages.tabWidth(int tabWidth) Sets the tab stop width for the source pages.testOperation(TestOperation<?, ?> testOperation) Sets the test operation.Returns the test tool options.testToolOptions(String... options) Sets the test tool options.final JacocoReportOperationtestToolOptions(Collection<String> options) Sets the test tool options.xml()Returns the XML report location.Sets the location of the XML report.Sets the location of the XML report.Sets the location of the XML report.Methods inherited from class rife.bld.operations.AbstractOperation
executeOnce, executeOnce, silent, silent, verbose, verbose
-
Field Details
-
CLASS_FILES
- See Also:
-
EXEC_FILES
- See Also:
-
SOURCE_FILES
- See Also:
-
-
Constructor Details
-
JacocoReportOperation
public JacocoReportOperation()
-
-
Method Details
-
execute
Performs the operation execution that can be wrapped by the#executeOncecall.- Specified by:
executein classAbstractOperation<JacocoReportOperation>- Throws:
NullPointerException- if the project isnullException
-
classFiles
Sets the locations of Java class files.- Parameters:
classFiles- the class files- Returns:
- this operation instance
- Throws:
NullPointerException- ifclassFilesisnullor containsnullelementsIllegalArgumentException- ifclassFilesis empty- See Also:
-
classFiles
Sets the locations of Java class files.- Parameters:
classFiles- the class files- Returns:
- this operation instance
- Throws:
NullPointerException- ifclassFilesisnullor containsnullelementsIllegalArgumentException- ifclassFilesis empty, or contains blank elements- See Also:
-
classFiles
Sets the locations of Java class files.- Parameters:
classFiles- the class files- Returns:
- this operation instance
- Throws:
NullPointerException- ifclassFilesisnullor containsnullelementsIllegalArgumentException- ifclassFilesis empty- See Also:
-
classFiles
Returns the locations of Java class files.The returned list is the live internal list and is mutable by design to support the fluent builder pattern.
- Returns:
- the class files
-
classFiles
Sets the locations of Java class files.- Parameters:
classFiles- the class files- Returns:
- this operation instance
- Throws:
NullPointerException- ifclassFilesisnullor containsnullelementsIllegalArgumentException- ifclassFilesis empty- See Also:
-
classFilesPaths
Sets the locations of Java class files.- Parameters:
classFiles- the class files- Returns:
- this operation instance
- Throws:
NullPointerException- ifclassFilesisnullor containsnullelementsIllegalArgumentException- ifclassFilesis empty- See Also:
-
classFilesStrings
Sets the locations of Java class files.- Parameters:
classFiles- the class files- Returns:
- this operation instance
- Throws:
NullPointerException- ifclassFilesisnullor containsnullelementsIllegalArgumentException- ifclassFilesis empty, or contains blank elements- See Also:
-
csv
Sets the location of the CSV report.- Parameters:
csv- the report location- Returns:
- this operation instance
- Throws:
NullPointerException- ifcsvisnull
-
csv
Sets the location of the CSV report.- Parameters:
csv- the report location- Returns:
- this operation instance
- Throws:
NullPointerException- ifcsvisnullIllegalArgumentException- ifcsvis blank
-
csv
Sets the location of the CSV report.- Parameters:
csv- the report location- Returns:
- this operation instance
- Throws:
NullPointerException- ifcsvisnull
-
csv
Returns the CSV report location.- Returns:
- the CSV report location
-
destFile
Sets the file to write execution data to.- Parameters:
destFile- the file- Returns:
- this operation instance
- Throws:
NullPointerException- ifdestFileisnull
-
destFile
Sets the file to write execution data to.- Parameters:
destFile- the file- Returns:
- this operation instance
- Throws:
NullPointerException- ifdestFileisnullIllegalArgumentException- ifdestFileis blank
-
destFile
Sets the file to write execution data to.- Parameters:
destFile- the file- Returns:
- this operation instance
- Throws:
NullPointerException- ifdestFileisnull
-
destFile
Returns the file to write execution data to.- Returns:
- the file to write execution data to
-
disableCsv
Disables generation of the CSV report.- Returns:
- this operation
- Since:
- 1.1
-
disableHtml
Disables generation of the HTML report.- Returns:
- this operation instance
- Since:
- 1.1
-
disableXml
Disables generation of the XML report.- Returns:
- this operation instance
- Since:
- 1.1
-
enableAllReports
Enables generation of all report formats (CSV, HTML, and XML).This is a convenience method equivalent to calling
enableCsv(),enableHtml(), andenableXml(). All reports are enabled by default.Example:
new JacocoReportOperation() .fromProject(project) .disableHtml() .disableCsv() .enableAllReports() // re-enables everything .execute();- Returns:
- this operation instance for method chaining
- Since:
- 1.1
- See Also:
-
enableCsv
Enables generation of the CSV report.Call this to re-enable CSV output after
disableCsv()was called. CSV generation is enabled by default.- Returns:
- this operation instance for method chaining
- Since:
- 1.1
- See Also:
-
enableHtml
Enables generation of the HTML report.Call this to re-enable HTML output after
disableHtml()was called. HTML generation is enabled by default. The HTML report includes source highlighting and is suitable for human review.- Returns:
- this operation instance for method chaining
- Since:
- 1.1
- See Also:
-
enableXml
Enables generation of the XML report.Call this to re-enable XML output after
disableXml()was called. XML generation is enabled by default. The XML report is machine-readable and commonly used by CI tools like SonarQube.- Returns:
- this operation instance for method chaining
- Since:
- 1.1
- See Also:
-
encoding
Sets the source file encoding. The platform encoding is used by default.- Parameters:
encoding- the encoding- Returns:
- this operation instance
- Throws:
NullPointerException- ifencodingisnullIllegalArgumentException- ifencodingis blank
-
encoding
Returns the source file encoding, ornullif not set (platform default will be used).- Returns:
- the source file encoding
-
excludes
Sets class name patterns to exclude from the coverage analysis.Uses Ant-style path patterns matched against JVM internal class names with '/' separators. Exclude patterns take precedence over include patterns.
Pattern syntax:
*matches zero or more characters except '/'**matches zero or more directories?matches a single character
Common examples:
"**/*Test*"- exclude all test classes"**/generated/**"- exclude generated code"**/proto/**"- exclude protobuf classes"**/Dagger*"- exclude Dagger generated classes
- Parameters:
patterns- the Ant-style exclude patterns; must not be null or contain null/empty elements- Returns:
- this operation instance
- Throws:
NullPointerException- if patterns isnull, or containsnullelementsIllegalArgumentException- if patterns is empty, or contains empty strings- See Also:
-
excludes
Returns the class name patterns to exclude from coverage analysis.The returned list is the live internal list and is mutable by design to support the fluent builder pattern.
- Returns:
- the exclude patterns, empty if no classes are excluded
- See Also:
-
excludes
Sets class name patterns to exclude from the coverage analysis.Uses Ant-style path patterns matched against JVM internal class names with '/' separators. Exclude patterns take precedence over include patterns.
Pattern syntax:
*matches zero or more characters except '/'**matches zero or more directories?matches a single character
Common examples:
"**/*Test*"- exclude all test classes"**/generated/**"- exclude generated code"**/proto/**"- exclude protobuf classes"**/Dagger*"- exclude Dagger generated classes
- Parameters:
patterns- the Ant-style exclude patterns; must not be null, empty, or contain null/empty elements- Returns:
- this operation instance
- Throws:
NullPointerException- if patterns isnull, or containsnullelementsIllegalArgumentException- if patterns is empty, or contains blank elements- See Also:
-
execFiles
Sets the locations of the JaCoCo *.exec files to read.If exec files are provided and
testOperation(TestOperation)is not called, tests will not be executed. Reports are generated from the provided files only.If both exec files and a test operation are provided, tests run and the new execution data is merged with the provided files.
- Parameters:
execFiles- the exec files- Returns:
- this operation instance
- Throws:
NullPointerException- ifexecFilesisnullor containsnullelementsIllegalArgumentException- ifexecFilesis empty- See Also:
-
execFiles
Sets the locations of the JaCoCo *.exec files to read.If exec files are provided and
testOperation(TestOperation)is not called, tests will not be executed. Reports are generated from the provided files only.If both exec files and a test operation are provided, tests run and the new execution data is merged with the provided files.
- Parameters:
execFiles- the exec files- Returns:
- this operation instance
- Throws:
NullPointerException- ifexecFilesisnullor containsnullelementsIllegalArgumentException- ifexecFilesis empty, or contains blank elements- See Also:
-
execFiles
Sets the locations of the JaCoCo *.exec files to read.If exec files are provided and
testOperation(TestOperation)is not called, tests will not be executed. Reports are generated from the provided files only.If both exec files and a test operation are provided, tests run and the new execution data is merged with the provided files.
- Parameters:
execFiles- the exec files- Returns:
- this operation instance
- Throws:
NullPointerException- ifexecFilesisnullor containsnullelementsIllegalArgumentException- ifexecFilesis empty- See Also:
-
execFiles
Sets the locations of the JaCoCo *.exec files to read.If exec files are provided and
testOperation(TestOperation)is not called, tests will not be executed. Reports are generated from the provided files only.If both exec files and a test operation are provided, tests run and the new execution data is merged with the provided files.
- Parameters:
execFiles- the exec files- Returns:
- this operation instance
- Throws:
NullPointerException- ifexecFilesisnullor containsnullelementsIllegalArgumentException- ifexecFilesis empty- See Also:
-
execFiles
Returns the locations of the JaCoCo *.exec files to read.The returned list is the live internal list and is mutable by design to support the fluent builder pattern.
- Returns:
- the exec files
-
execFilesPaths
Sets the locations of the JaCoCo *.exec files to read.If exec files are provided and
testOperation(TestOperation)is not called, tests will not be executed. Reports are generated from the provided files only.If both exec files and a test operation are provided, tests run and the new execution data is merged with the provided files.
- Parameters:
execFiles- the exec files- Returns:
- this operation instance
- Throws:
NullPointerException- ifexecFilesisnullor containsnullelementsIllegalArgumentException- ifexecFilesis empty- See Also:
-
execFilesStrings
Sets the locations of the JaCoCo *.exec files to read.If exec files are provided and
testOperation(TestOperation)is not called, tests will not be executed. Reports are generated from the provided files only.If both exec files and a test operation are provided, tests run and the new execution data is merged with the provided files.
- Parameters:
execFiles- the exec files- Returns:
- this operation instance
- Throws:
NullPointerException- ifexecFilesisnullor containsnullelementsIllegalArgumentException- ifexecFilesis empty, or contains blank elements- See Also:
-
fromProject
Configure the operation from aBaseProject.- Parameters:
project- the project- Returns:
- this operation instance
- Throws:
NullPointerException- ifprojectisnull
-
html
Sets the directory for the HTML report output.- Parameters:
html- the HTML report directory- Returns:
- this operation instance
- Throws:
NullPointerException- ifhtmlisnull
-
html
Sets the directory for the HTML report output.- Parameters:
html- the HTML report directory- Returns:
- this operation instance
- Throws:
NullPointerException- ifhtmlisnullIllegalArgumentException- ifhtmlis blank
-
html
Sets the directory for the HTML report output.- Parameters:
html- the HTML report directory- Returns:
- this operation instance
- Throws:
NullPointerException- ifhtmlisnull
-
html
Returns the HTML report output directory.- Returns:
- the HTML report directory
-
includes
Sets class name patterns to include in the coverage analysis.Uses Ant-style path patterns matched against JVM internal class names with '/' separators. If no includes are specified, all classes are included by default unless excluded.
Pattern syntax:
*matches zero or more characters except '/'**matches zero or more directories?matches a single character
Examples:
"com/myapp/**"- all classes in com.myapp and subpackages"**/service/*"- all classes directly in any service package"com/myapp/MyClass"- single class com.myapp.MyClass
- Parameters:
patterns- the Ant-style include patterns; must not be null or contain null/empty elements- Returns:
- this operation instance
- Throws:
NullPointerException- if patterns isnull, or containsnullelementsIllegalArgumentException- if patterns is empty, or contains empty elements- See Also:
-
includes
Returns the class name patterns to include in coverage analysis.The returned list is the live internal list and is mutable by design to support the fluent builder pattern.
- Returns:
- the include patterns, empty if all classes are included
- See Also:
-
includes
Sets class name patterns to include in the coverage analysis.Uses Ant-style path patterns matched against JVM internal class names with '/' separators. If no includes are specified, all classes are included by default unless excluded.
Pattern syntax:
*matches zero or more characters except '/'**matches zero or more directories?matches a single character
Examples:
"com/myapp/**"- all classes in com.myapp and subpackages"**/service/*"- all classes directly in any service package"com/myapp/MyClass"- single class com.myapp.MyClass
- Parameters:
patterns- the Ant-style include patterns; must not be null, empty, or contain null/empty elements- Returns:
- this operation instance
- Throws:
NullPointerException- if patterns isnull, or containsnullelementsIllegalArgumentException- if patterns is empty, or contains blank elements- See Also:
-
isCsvDisabled
public boolean isCsvDisabled()Returns whether CSV report generation is disabled.- Returns:
trueif the CSV report is disabled- Since:
- 1.1
-
isHtmlDisabled
public boolean isHtmlDisabled()Returns whether HTML report generation is disabled.- Returns:
trueif the HTML report is disabled- Since:
- 1.1
-
isQuiet
public boolean isQuiet()Return the status of the quiet flag.- Returns:
trueif enabled,falseotherwise
-
isXmlDisabled
public boolean isXmlDisabled()Returns whether XML report generation is disabled.- Returns:
trueif the XML report is disabled- Since:
- 1.1
-
name
Sets the name used for the report.- Parameters:
name- the name- Returns:
- this operation instance
- Throws:
NullPointerException- ifnameisnullIllegalArgumentException- ifnameis blank
-
name
Returns the name used for the report.- Returns:
- the report name.
-
quiet
Suppresses all output.- Parameters:
quiet-trueorfalse- Returns:
- this operation instance
-
sourceFiles
Sets the locations of the source files. (e.g.,src/main/java)- Parameters:
sourceFiles- the source files- Returns:
- this operation instance
- Throws:
NullPointerException- ifsourceFilesisnullor containsnullelementsIllegalArgumentException- ifsourceFilesis empty- See Also:
-
sourceFiles
Sets the locations of the source files. (e.g.,src/main/java)- Parameters:
sourceFiles- the source files- Returns:
- this operation instance
- Throws:
NullPointerException- ifsourceFilesisnullor containsnullelementsIllegalArgumentException- ifsourceFilesis empty, or contains blank elements- See Also:
-
sourceFiles
Sets the locations of the source files. (e.g.,src/main/java)- Parameters:
sourceFiles- the source files- Returns:
- this operation instance
- Throws:
NullPointerException- ifsourceFilesisnullor containsnullelementsIllegalArgumentException- ifsourceFilesis empty- See Also:
-
sourceFiles
Sets the locations of the source files. (e.g.,src/main/java)- Parameters:
sourceFiles- the source files- Returns:
- this operation instance
- Throws:
NullPointerException- ifsourceFilesisnullor containsnullelementsIllegalArgumentException- ifsourceFilesis empty- See Also:
-
sourceFiles
Returns the locations of the source files.The returned list is the live internal list and is mutable by design to support the fluent builder pattern.
- Returns:
- the source files
-
sourceFilesPaths
Sets the locations of the source files. (e.g.,src/main/java)- Parameters:
sourceFiles- the source files- Returns:
- this operation instance
- Throws:
NullPointerException- ifsourceFilesisnullor containsnullelementsIllegalArgumentException- ifsourceFilesis empty- See Also:
-
sourceFilesStrings
Sets the locations of the source files. (e.g.,src/main/java)- Parameters:
sourceFiles- the source files- Returns:
- this operation instance
- Throws:
NullPointerException- ifsourceFilesisnullor containsnullelementsIllegalArgumentException- ifsourceFilesis empty, or contains blank elements- See Also:
-
tabWidth
Sets the tab stop width for the source pages. Default is4.- Parameters:
tabWidth- the tab width- Returns:
- this operation instance
- Throws:
IllegalArgumentException- iftabWidthis not positive
-
tabWidth
public int tabWidth()Returns the tab stop width for the source pages.- Returns:
- the tab stop width
-
testOperation
Sets the test operation.If set, tests are always executed even when
execFiles(File...)is also called. The JaCoCo agent is attached to this operation and the resulting execution data is merged with any provided exec files.If not set and no exec files are provided,
fromProject(BaseProject)will create a default test operation from the project.- Parameters:
testOperation- the test operation; must not be null- Returns:
- this operation instance
- Throws:
NullPointerException- iftestOperationisnull- See Also:
-
testToolOptions
Returns the test tool options.The returned list is the live internal list and is mutable by design to support the fluent builder pattern.
- Returns:
- the test tool options
-
testToolOptions
Sets the test tool options.- Parameters:
options- the options to set- Returns:
- this operation instance
- Throws:
NullPointerException- ifoptionsisnullor containsnullelementsIllegalArgumentException- ifoptionsis empty, or contains blank elements- See Also:
-
testToolOptions
Sets the test tool options.- Parameters:
options- the options to set- Returns:
- this operation instance
- Throws:
NullPointerException- ifoptionsisnullor containsnullelementsIllegalArgumentException- ifoptionsis empty, or contains blank elements- See Also:
-
xml
Sets the location of the XML report.- Parameters:
xml- the report location- Returns:
- this operation instance
- Throws:
NullPointerException- ifxmlisnull
-
xml
Sets the location of the XML report.- Parameters:
xml- the report location- Returns:
- this operation instance
- Throws:
NullPointerException- ifxmlisnullIllegalArgumentException- ifxmlis blank
-
xml
Sets the location of the XML report.- Parameters:
xml- the report location- Returns:
- this operation instance
- Throws:
NullPointerException- ifxmlisnull
-
xml
Returns the XML report location.- Returns:
- the XML report location
-