Skip to content

#726 Report AsciiDoctor-reported build problems at end of the build

Changes:

  • As a next step in #726, problems reported by AsciiDoctor now no longer fail the build immediately, but are reported at the end of the build by our problem reporter.
  • Documentation/website-only builds still fail directly, as there is no problem reporter at the end. This is similar to how we report issues for our AsciiDoc Source Checker.
  • To get the AsciiDoctor problems, I register an extra custom log handler for AsciiDoctorJ:
    • It is an extra log handler, so the output is also still output to the console.
    • The extra log handler writes the log entries to a file, that the problem reporter picks up at the end of the build.
    • The log handler doesn't know about Maven, so we can't obtain the current Maven project being built, to figure out the file to which to write the log entries. The current working directory of Java is the root of the entire repo, so that doesn't help either. I tried to check Java properies, but it doesn't contain the information either. I therefore write the current project directory to a file at a fixed position in the repo, at the start of building each documentation project, and read that file in the log handler. Not super nice, but it seems to be the only way to get this to work.
    • Only one log handler instance is created for the entire Maven build. It is reused for the different documentation projects we build. We thus need to determine the file for each log entry, and do the trick to find the project directory, for every log entry. We can't do it in the constructor, because an instance is only created once, for the first documentation project where we use AsciiDoctor. Not as nice as I had hoped, but I don't see a way around it.
  • I've improved the problem reporter framework a bit, as I needed that here:
    • Generalized the problem reporter to have BuildProblems no longer be abstract, and collect global, project-associated and file-associated problems, all in one. This allows problem collectors to return different kinds of problems. The AsciiDoctor problems can either be project-associated or file-associated, depending on whether a file is part of the log entry.
    • File-associated problems now have optional line and column numbers, as line numbers are not always provided for AsciiDoctor problems, and column numbers are never provided.
    • I've added a test problem collector, that can be used to more easily test the generated problem report, as it generate all different kinds of problems.

Best to review per commit.

Addressses #726

Edited by Dennis Hendriks

Merge request reports

Loading