Skip to content

Commit

Permalink
Merge pull request #18 from chirag-ji/develop
Browse files Browse the repository at this point in the history
Version 1.1.0
  • Loading branch information
chirag-ji authored Jun 6, 2023
2 parents 9274698 + a6859a7 commit 5a90d93
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ jacotura {
// if wanting to beautify the output cobertura report
beautify = true
// if wants to see only file name in `filename` property of `class` tag in cobertura report. default is `false`
usePlainFileNames = true
// Only output coverage for selected file names. Do not set if needed for all files
includedFileNames = ['A.java', 'B.java']
}
Expand Down
2 changes: 1 addition & 1 deletion jacotura-gradle-plugin/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ plugins {
}

group "io.github.chiragji"
version '1.0.3'
version '1.1.0'
description "Gradle plugin to convert JaCoCo coverage reports to Cobertura coverage reports"

def projectName = 'Gradle Jacotura plugin'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ public class JacoturaConfig {
private Set<String> srcDirs;
private Set<String> includeFileNames;
private boolean beautify;
private boolean usePlainFileName;

public void setJacoturaReport(@NonNull String jacoturaFilePath) {
this.jacoturaFile = new File(jacoturaFilePath);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,4 +55,5 @@ public abstract class JacoturaConstants {
public static final String KEY_SRC_DIRS = "jacotura.source.dirs";
public static final String KEY_INCLUDED_FILE_NAMES = "jacotura.files.includedNames";
public static final String KEY_BEAUTIFY = "jacotura.cobertura.beautify";
public static final String KEY_USE_PLAIN_FILE_NAME = "jacotura.cobertura.file.name.usePlain";
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ private void buildCoverage(JacocoReport jacocoReport, CoberturaReport coberturaR
}
CoberturaClass cCls = cPkg.createNewClass();
cCls.setName(getCoberturaFriendlyName(jCls.getName()));
cCls.setFileName(jCls.getSourceFileName());
cCls.setFileName(getClassName(jPkg, jCls));
computeRates(cCls, jCls);
List<JacocoLine> lines = getSourceFileLines(jPkg, jCls.getSourceFileName());
jCls.getMethods().parallelStream().forEach(jMth -> {
Expand All @@ -118,6 +118,14 @@ private void buildCoverage(JacocoReport jacocoReport, CoberturaReport coberturaR
});
}

private String getClassName(JacocoPackage pkg, JacocoClass cls) {
if (jacoturaConfig.isUsePlainFileName()) {
return cls.getSourceFileName();
} else {
return String.format("%s/%s", pkg.getName(), cls.getSourceFileName());
}
}

private void buildLineCoverage(@NonNull CoberturaLine cLine, @NonNull JacocoLine jLine) {
int nr = jLine.getLineNumber();
int mb = jLine.getMissedBranches();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ public class JacoturaExtensions {
@Input
private boolean beautify;

@Input
private boolean usePlainFileNames;

public void properties(Action<? super JacoturaProperties> action) {
propertiesAction.add(action);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ private void extractExtensionVariables(Map<String, Object> properties) {
if (extensions.isBeautify()) {
properties.put(JacoturaConstants.KEY_BEAUTIFY, true);
}
if (extensions.isUsePlainFileNames()) {
properties.put(JacoturaConstants.KEY_USE_PLAIN_FILE_NAME, true);
}
}

private void evaluateActionBroadcast(ActionBroadcast<? super JacoturaProperties> prosBroadcast, Map<String, Object> props) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ private JacoturaConfig buildJacoturaConfig() {
config.setSrcDirs(getArrayProperty(JacoturaConstants.KEY_SRC_DIRS));
config.setIncludeFileNames(getArrayProperty(JacoturaConstants.KEY_INCLUDED_FILE_NAMES));
config.setBeautify(Boolean.parseBoolean(tmpProps.get(JacoturaConstants.KEY_BEAUTIFY)));
config.setUsePlainFileName(Boolean.parseBoolean(tmpProps.get(JacoturaConstants.KEY_USE_PLAIN_FILE_NAME)));
return config;
}

Expand Down

0 comments on commit 5a90d93

Please sign in to comment.