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

Multi-module fixed #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
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 @@ -24,6 +24,9 @@
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


/**
* @author edward
Expand Down Expand Up @@ -71,15 +74,30 @@ private Map<String, MutationReport> readReports() {
Map<String, MutationReport> reports = new HashMap<String, MutationReport>();

try {
FilePath[] files = new FilePath(owner_.getRootDir()).list("mutation-report*/mutations.xml");
FilePath[] files = new FilePath(owner_.getRootDir()).list("mutation-report-*/mutations.xml");

if (files.length < 1) {
logger.log(Level.WARNING, "Could not find mutation-report*/mutations.xml in " + owner_.getRootDir());
logger.log(Level.WARNING, "Could not find mutation-report-*/mutations.xml in " + owner_.getRootDir());
}

for (int i = 0; i < files.length; i++) {
logger.log(Level.WARNING, "Creating report for file: " + files[i].getRemote());
reports.put(String.valueOf(i), MutationReport.create(files[i].read()));

final String pattern = ".*mutation-report-([^/]*).*";
Pattern r = Pattern.compile(pattern);

String name = "";

Matcher m = r.matcher(files[i].getRemote());
if (m.find())
{
name = m.group(1);
}
else
{
name = String.valueOf(i);
}
reports.put(name, MutationReport.create(files[i].read()));
}
} catch (IOException e) {
e.printStackTrace();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListen

ParseReportCallable fileCallable = new ParseReportCallable(mutationStatsFile_);
FilePath[] reports = moduleRoot.act(fileCallable);
publishReports(reports, new FilePath(build.getRootDir()));
publishReports(reports, new FilePath(build.getRootDir()), build.getModuleRoot().getRemote());

//publish latest reports
PitBuildAction action = new PitBuildAction(build);
Expand All @@ -74,12 +74,14 @@ public Action getProjectAction(AbstractProject<?, ?> project) {
return new PitProjectAction(project);
}

void publishReports(FilePath[] reports, FilePath buildTarget) {
void publishReports(FilePath[] reports, FilePath buildTarget, final String base) {
for (int i = 0; i < reports.length; i++) {
FilePath report = reports[i];
listener_.getLogger().println("Publishing mutation report: " + report.getRemote());

final FilePath targetPath = new FilePath(buildTarget, "mutation-report" + (i == 0 ? "" : i));

final String moduleName = report.getRemote().replace(base, "").split("/")[1];

final FilePath targetPath = new FilePath(buildTarget, "mutation-report-" + moduleName);
try {
reports[i].getParent().copyRecursiveTo(targetPath);
} catch (IOException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public boolean isSourceLevel() {

public String getSourceFileContent() {
try {
return new TextFile(new File(getOwner().getRootDir(), "mutation-report/" + package_ + File.separator + fileName_)).read();
return new TextFile(new File(getOwner().getRootDir(), "mutation-report-" + getParent().getParent().getName() + "/" + package_ + File.separator + fileName_)).read();
}
catch (IOException exception) {
return "Could not read source file: " + getOwner().getRootDir().getPath()
Expand Down