Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jacoco multi module fixes #16252

Merged
merged 1 commit into from
Apr 6, 2021
Merged
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 @@ -80,7 +80,7 @@ public byte[] apply(String className, byte[] bytes) {
}
if (config.report) {
ReportInfo info = new ReportInfo();
info.savedData = dataFile;
info.dataFile = dataFile;

File targetdir = new File(
outputTargetBuildItem.getOutputDirectory().toAbsolutePath().toString() + File.separator
Expand All @@ -96,6 +96,7 @@ public byte[] apply(String className, byte[] bytes) {
if (BuildToolHelper.isMavenProject(targetdir.toPath())) {
LocalProject project = LocalProject.loadWorkspace(targetdir.toPath());
for (Map.Entry<AppArtifactKey, LocalProject> i : project.getWorkspace().getProjects().entrySet()) {
info.savedData.add(i.getValue().getOutputDir().resolve(config.dataFile).toAbsolutePath().toString());
sources.add(i.getValue().getSourcesSourcesDir().toFile().getAbsolutePath());
File classesDir = i.getValue().getClassesDir().toFile();
if (classesDir.isDirectory()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public void run() {
//the jacoco data is also generated by a shutdown hook
//we need to wait for the file. We wait at most 10s
long abortTime = System.currentTimeMillis() + 10000;
Path datafile = Paths.get(reportInfo.savedData);
Path datafile = Paths.get(reportInfo.dataFile);
while (System.currentTimeMillis() < abortTime) {
if (Files.exists(datafile)) {
break;
Expand All @@ -65,12 +65,20 @@ public void run() {
}
}
ExecFileLoader loader = new ExecFileLoader();
loader.load(datafile.toFile());
for (String i : reportInfo.savedData) {
File file = new File(i);
if (file.exists()) {
loader.load(file);
}
}
final CoverageBuilder builder = new CoverageBuilder();
final Analyzer analyzer = new Analyzer(
loader.getExecutionDataStore(), builder);
for (String i : reportInfo.classFiles) {
analyzer.analyzeAll(new File(i));
File file = new File(i);
if (file.exists()) {
analyzer.analyzeAll(file);
}
}

List<IReportVisitor> formatters = new ArrayList<>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package io.quarkus.jacoco.runtime;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class ReportInfo {

public String reportDir;
public String savedData;
public String dataFile;
public final List<String> savedData = new ArrayList<>();
public Set<String> sourceDirectories;
public Set<String> classFiles;
public String artifactId;
Expand Down