use of hudson.util.IOException2 in project violations-plugin by jenkinsci.
the class ParseXML method parse.
/**
* Parse an xml file using a parser object.
* @param xmlFile the file to parse.
* @param xmlParser the parser object.
* @throws IOException if there is a problem.
*/
public static void parse(File xmlFile, AbstractParser xmlParser) throws IOException {
InputStream in = null;
boolean seenException = false;
try {
in = new FileInputStream(xmlFile);
XmlPullParserFactory factory = XmlPullParserFactory.newInstance();
factory.setNamespaceAware(true);
XmlPullParser parser = factory.newPullParser();
parser.setInput(new XmlReader(in));
xmlParser.setParser(parser);
xmlParser.execute();
} catch (IOException ex) {
seenException = true;
throw ex;
} catch (Exception ex) {
seenException = true;
throw new IOException2(ex);
} finally {
CloseUtil.close(in, seenException);
}
}
use of hudson.util.IOException2 in project violations-plugin by jenkinsci.
the class ViolationsCollector method invoke.
/**
* Create a report.
*
* @param workspace
* the current workspace.
* @param channel
* the virtual channel.
* @return the report.
* @throws IOException
* if there is a problem.
*/
@Override
public ViolationsReport invoke(File workspace, VirtualChannel channel) throws IOException {
this.workspace = workspace;
// the given workspace
if (!StringUtil.isBlank(config.getFauxProjectPath())) {
this.workspace = new File(config.getFauxProjectPath());
LOG.fine("Using faux workspace " + this.workspace);
}
String[] sourcePaths = null;
if (mavenProject) {
sourcePaths = new String[] { workspace.toString() + "/src/main/java" };
} else {
// get the source path directories (if any)
sourcePaths = findAbsoluteDirs(workspace, config.getSourcePathPattern());
}
for (String sp : sourcePaths) {
LOG.fine("Using extra sourcePath " + sp);
}
// Create the report
ViolationsReport report = new ViolationsReport();
report.setConfig(config);
// Build up the model
this.model = new FullBuildModel();
for (String type : config.getTypeConfigs().keySet()) {
TypeConfig c = config.getTypeConfigs().get(type);
TypeDescriptor typeDescriptor = TypeDescriptor.TYPES.get(type);
if (typeDescriptor == null) {
continue;
}
if (mavenProject && (typeDescriptor.getMavenTargets() != null)) {
doType(c, typeDescriptor, sourcePaths, report);
continue;
}
if (empty(c.getPattern())) {
continue;
}
doType(c, typeDescriptor, sourcePaths, report);
}
model.cleanup();
// ----
try {
new GenerateXML(targetDir, model, config).execute();
} catch (InterruptedException ex) {
throw new IOException2(ex);
}
// ----
for (String type : model.getTypeMap().keySet()) {
report.getViolations().put(type, model.getCountNumber(type));
doSeverities(report, type);
}
return report;
}
Aggregations