import net.jaekl.cfb.analyze.Delta;
import net.jaekl.cfb.analyze.HtmlReport;
import net.jaekl.cfb.analyze.MessageMap;
+import net.jaekl.cfb.analyze.Notifier;
import net.jaekl.cfb.db.CfbSchema;
import net.jaekl.cfb.db.TypeMismatchException;
import net.jaekl.cfb.db.driver.DbDriver;
CfbBundle m_bundle;
Locale m_locale;
+ Config m_config;
+
// Command-line parameters
+ File m_configFile;
String m_dbName; // db name
File m_fbp; // FindBugsProject file
File m_fbDir; // Directory where FindBugs is installed
m_schema = new CfbSchema(m_driver);
m_locale = locale;
m_bundle = CfbBundle.getInst(m_locale);
+ m_config = new Config();
+ m_configFile = new File("config.properties");
m_dbName = "CFB";
m_fbp = null;
m_fbDir = null;
Options createOptions() {
Options opt = new Options();
+ opt.addOption("c", "config", true, "Properties configuration file");
opt.addOption("d", "dbname", true, "DB name");
opt.addOption(null, "drop-tables", false, "Remove database schema (drop all data)");
opt.addOption("f", "fbp", true, "FindBugsProject file");
try {
CommandLine line = new GnuParser().parse(opt, args);
+ if (line.hasOption("c")) {
+ m_configFile = new File(line.getOptionValue("c"));
+ }
if (line.hasOption("d")) {
m_dbName = line.getOptionValue("d");
}
if (null != findBugsDir) {
m_fbDir = new File(findBugsDir);
}
- }
+ }
+
+ void readConfig() throws IOException {
+ if (null != m_configFile) {
+ m_config.readFile(m_configFile);
+ }
+ }
void doMain(PrintWriter pw, String[] args) throws SQLException, IOException, XmlParseException, SAXException, TypeMismatchException {
initArgs(); // read environment and system properties
if ( ! parseArgs(pw, args) ) {
return;
}
+ readConfig();
File findBugsDir = getFindBugsDir();
File workDir = new File(".");
Analysis prior = store.getPrior(analysis);
Delta delta = new Delta(prior, analysis);
- HtmlReport report = new HtmlReport(m_bundle, messageMap.getColl());
- report.write(m_output, delta);
+ HtmlReport report = new HtmlReport(m_bundle, messageMap.getColl(), delta);
+ report.write(m_output);
+
+ Notifier notifier = new Notifier(m_bundle, m_config);
+ notifier.sendEmailIfNeeded(pw, report);
}
catch (SQLException exc) {
reportUnableToConnect(pw, exc);