X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2Fanalyze%2FAnalyzer.java;h=d1aa115e9d6ab3418c1f20979ad3fa446d7737b8;hp=5e72fe0499db0b7d2f50c3b67ec09f13eb8b7da8;hb=2769cf82ccae57ee3716aecc9bd694be1f115d92;hpb=88c635ae6a039a873cba2d794c55d726dcdc616d diff --git a/prod/net/jaekl/cfb/analyze/Analyzer.java b/prod/net/jaekl/cfb/analyze/Analyzer.java index 5e72fe0..d1aa115 100644 --- a/prod/net/jaekl/cfb/analyze/Analyzer.java +++ b/prod/net/jaekl/cfb/analyze/Analyzer.java @@ -6,25 +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.InputSource; -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); @@ -32,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. @@ -45,8 +50,9 @@ public class Analyzer { return null; } - result = parseFbOutput(new InputSource(fbOutput.getAbsolutePath())); - result.dump(pw); + result.setEnd(new Date()); + result.parse(new InputSource(fbOutput.getAbsolutePath())); + // result.dump(pw); return result; } @@ -62,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) @@ -95,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(InputSource fbOutput) throws XmlParseException - { - Analysis result = new Analysis(); - try { - result.parse(fbOutput); - } catch (IOException | SAXException exc) { - throw new XmlParseException(exc); - } - return result; - } }