X-Git-Url: http://jaekl.net/gitweb/?p=cfb.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Fcfb%2FCFB.java;h=7dca443fa6b62aa65428b997bb9f4ad4b65a0871;hp=b5071d0cb18fd4efc77d4f2f6f300c8306c3325f;hb=295e3db9a37a2863cb8bc3659c375d99e40e0fc1;hpb=1577da4d5488b4f6f093ef0657c04415326b9bd3 diff --git a/prod/net/jaekl/cfb/CFB.java b/prod/net/jaekl/cfb/CFB.java index b5071d0..7dca443 100644 --- a/prod/net/jaekl/cfb/CFB.java +++ b/prod/net/jaekl/cfb/CFB.java @@ -29,6 +29,7 @@ public class CFB { // Command-line parameters String m_dbName; // db name File m_fbp; // FindBugsProject file + File m_fbDir; // Directory where FindBugs is installed String m_host; // db host int m_port; // db port String m_user; // db user @@ -41,7 +42,8 @@ public class CFB { m_bundle = CfbBundle.getInst(m_locale); m_dbName = "CFB"; - m_fbp = null; + m_fbp = null; + m_fbDir = null; m_host = "localhost"; m_port = 5432; m_pass = ""; @@ -102,7 +104,29 @@ public class CFB { return m_bundle.get(key); } + String getenv(String varName) { + // This is a separate function so that we can override it at unit test time + return System.getenv(varName); + } + + String getProperty(String propName) { + // This is a separate function so that we can override it at unit test time + return System.getProperty(propName); + } + + void initArgs() { + String findBugsDir = getenv("FINDBUGS_HOME"); + if (null != findBugsDir) { + m_fbDir = new File(findBugsDir); + } + findBugsDir = getProperty("findbugs.home"); + if (null != findBugsDir) { + m_fbDir = new File(findBugsDir); + } + } + void doMain(PrintWriter pw, String[] args) throws SQLException, IOException { + initArgs(); // read environment and system properties if ( ! parseArgs(pw, args) ) { return; } @@ -118,10 +142,13 @@ public class CFB { return; } - File findBugsDir = new File("."); + File findBugsDir = (null != m_fbDir) ? m_fbDir : new File("."); File workDir = new File("."); Analyzer analyzer = new Analyzer(findBugsDir); - Analysis analysis = analyzer.analyze(workDir, m_fbp); + Analysis analysis = analyzer.analyze(pw, workDir, m_fbp); + if (null != analysis) { + // TODO + } } public static void main(String[] args) { @@ -129,6 +156,7 @@ public class CFB { try (PrintWriter pw = new PrintWriter(System.out)){ cfb.doMain(pw, args); + pw.flush(); } catch (SQLException | IOException exc) { exc.printStackTrace(); }