Search in sources :

Example 1 with GenerateXML

use of hudson.plugins.violations.generate.GenerateXML 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;
}
Also used : GenerateXML(hudson.plugins.violations.generate.GenerateXML) FullBuildModel(hudson.plugins.violations.model.FullBuildModel) File(java.io.File) IOException2(hudson.util.IOException2)

Aggregations

GenerateXML (hudson.plugins.violations.generate.GenerateXML)1 FullBuildModel (hudson.plugins.violations.model.FullBuildModel)1 IOException2 (hudson.util.IOException2)1 File (java.io.File)1