/** {@inheritDoc} */
  @Override
  public BuildResult perform(final AbstractBuild<?, ?> build, final PluginLogger logger)
      throws InterruptedException, IOException {
    File logFile = build.getLogFile();

    Set<String> validParsers = Sets.newHashSet(getParserNames());
    ParserResult project;
    if (StringUtils.isNotBlank(getPattern())) {
      logger.log("Parsing warnings in files: " + getPattern());
      FilesParser parser =
          new FilesParser(
              logger,
              getPattern(),
              new FileWarningsParser(
                  validParsers, getDefaultEncoding(), getIncludePattern(), getExcludePattern()),
              isMavenBuild(build),
              isAntBuild(build));
      project = build.getWorkspace().act(parser);
    } else {
      project = new ParserResult(build.getWorkspace());
    }

    if (!ignoreConsole || StringUtils.isBlank(getPattern())) {
      logger.log("Parsing warnings in console log...");
      ParserRegistry registry =
          new ParserRegistry(
              ParserRegistry.getParsers(validParsers),
              getDefaultEncoding(),
              getIncludePattern(),
              getExcludePattern());
      Collection<FileAnnotation> warnings = registry.parse(logFile);
      if (!build.getWorkspace().isRemote()) {
        String workspace = build.getWorkspace().getRemote();
        ModuleDetector detector = new ModuleDetector(new File(workspace));
        for (FileAnnotation annotation : warnings) {
          String module = detector.guessModuleName(annotation.getFileName());
          annotation.setModuleName(module);
        }
      }

      project.addAnnotations(warnings);
    }
    project = build.getWorkspace().act(new AnnotationsClassifier(project, getDefaultEncoding()));
    for (FileAnnotation annotation : project.getAnnotations()) {
      annotation.setPathName(build.getWorkspace().getRemote());
    }

    WarningsResult result = new WarningsResult(build, getDefaultEncoding(), project);
    build.getActions().add(new WarningsResultAction(build, this, result));

    return result;
  }
  DependencyCheckResult(
      final Run<?, ?> build,
      final BuildHistory history,
      final ParserResult result,
      final String defaultEncoding,
      final boolean canSerialize) {
    super(build, history, result, defaultEncoding);

    if (canSerialize) {
      serializeAnnotations(result.getAnnotations());
    }
  }
示例#3
0
  WarningsResult(
      final AbstractBuild<?, ?> build,
      final BuildHistory history,
      final ParserResult result,
      final String defaultEncoding,
      final String group,
      final boolean canSerialize) {
    super(build, history, result, defaultEncoding);

    this.group = group;
    if (canSerialize) {
      serializeAnnotations(result.getAnnotations());
    }
  }