X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2Fanalyze%2FAnalyzer.java;h=d1aa115e9d6ab3418c1f20979ad3fa446d7737b8;hp=9a8d7a64c4ea6f7a4069dfb3b396e1ddd65f382f;hb=2769cf82ccae57ee3716aecc9bd694be1f115d92;hpb=5bc9bbe3fd54b9fc7aa3b92d2d37e95c41b9645a diff --git a/prod/net/jaekl/cfb/analyze/Analyzer.java b/prod/net/jaekl/cfb/analyze/Analyzer.java index 9a8d7a6..d1aa115 100644 --- a/prod/net/jaekl/cfb/analyze/Analyzer.java +++ b/prod/net/jaekl/cfb/analyze/Analyzer.java @@ -6,24 +6,28 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; import java.text.MessageFormat; +import java.util.Date; import java.util.Locale; import java.util.Locale.Category; -import org.xml.sax.SAXException; - import net.jaekl.cfb.CfbBundle; import net.jaekl.cfb.util.Command; import net.jaekl.qd.xml.XmlParseException; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + public class Analyzer { - File m_findbugsDir; + MessageMap m_msgMap; - public Analyzer(File findbugsDir) { - m_findbugsDir = findbugsDir; + public Analyzer(MessageMap msgMap) { + m_msgMap = msgMap; } - public Analysis analyze(PrintWriter pw, File workDir, File fbp) throws IOException, XmlParseException { - Analysis result = new Analysis(); + public Analysis analyze(PrintWriter pw, File workDir, File fbp, String projName, String buildNumber) + throws IOException, XmlParseException, SAXException + { + Analysis result = new Analysis(projName, buildNumber); File fbOutput = outputWorkFile(workDir, fbp); @@ -31,6 +35,8 @@ public class Analyzer { pw.println(cmdLine); pw.flush(); Command.Result fbResult = new Command().exec(cmdLine); + pw.println("==> " + fbResult.getRetCode()); + pw.flush(); if (0 != fbResult.getRetCode()) { // Our attempt to execute FindBugs failed. // Report the error and return null. @@ -44,8 +50,9 @@ public class Analyzer { return null; } - result = parseFbOutput(fbOutput); - result.dump(pw); + result.setEnd(new Date()); + result.parse(new InputSource(fbOutput.getAbsolutePath())); + // result.dump(pw); return result; } @@ -61,7 +68,7 @@ public class Analyzer { StringBuilder sb = new StringBuilder(); - sb.append(m_findbugsDir.getAbsolutePath()) + sb.append(m_msgMap.getFindBugsDir().getAbsolutePath()) .append(File.separator) .append("bin") .append(File.separator) @@ -94,17 +101,4 @@ public class Analyzer { return new File(workPath + File.separator + projName + ".xml"); } - - // Parse the output.xml that resulted from a FindBugs run, - // and store its findings into an Analysis object. - Analysis parseFbOutput(File fbOutput) throws XmlParseException - { - Analysis result = new Analysis(); - try { - result.parse(fbOutput); - } catch (IOException | SAXException exc) { - throw new XmlParseException(exc); - } - return result; - } }