Skip to content
BETAGuardrails are in beta. The library, the configuration format and the CLI command can still change.

Guardrails / maven

The POM parses

maven/pom-parses@v1

The root pom.xml is well formed XML, so the build it describes can be read at all.

Idmaven/pom-parses
Versionv1
Categorymaven
Default severityerror
Interpreterpython3
Timeout30 seconds
Violations tolerated0
Collectsmaven

Collectors

This guardrail gathers nothing itself. It depends on the collectors below, which the CLI runs once per build before any check, and reads what they found out of GUARDRAIL_FACTS. A collector that collects nothing skips this guardrail rather than failing it.

CollectorGathersInputs it is given
mavenThe Maven build in the project directory: the root pom.xml coordinates, its modules, its properties and every dependency it and its modules declare, with the versions its imported BOMs supply.projectDir

The inputs above are this guardrail's own, passed straight through. Configuring one in buildnote.json changes what is collected, and two guardrails configured the same way share the one collection.

Configuration

json
{
  "guardrails": {
      "failOn": "error",
      "comment": true,
      "checks": [
          {
              "use": "maven/pom-parses@v1",
              "severity": "error",
              "with": {
                  "projectDir": "."
              },
              "exemptions": []
          }
      ]
  }
}

Inputs

InputDescriptionDefaultEnvironment variable
projectDirDirectory holding the project, relative to the directory the CLI runs in..GUARDRAIL_INPUT_PROJECTDIR

How to fix

Fix the XML, and let Maven itself tell you where it gives up:

bash
mvn -q validate

Maven refuses to build a POM it cannot parse, and every tool that reads the build reads nothing: the coordinates, the properties, the modules and the dependency list all fall back to their defaults, so every other Maven guardrail passes over a project it never saw.

More in maven

  • maven/coordinates-declared. The root POM names the group, the artifact and the version it publishes, declaring them itself or inheriting the group and the version from a <parent>.
  • maven/dependencies-versioned. Every dependency the POM and its modules declare takes a version from the checkout, whether from the entry itself, from <dependencyManagement>, from an imported BOM or from a property. A parent POM published elsewhere is not read here, so a version only that parent manages reads as unresolved.
  • maven/no-snapshot-dependencies. No dependency the POM and its modules declare, and no BOM they import, is at a -SNAPSHOT version.

All 4 maven guardrails

Buildnote Limited
Registered in England and Wales, Reg: 16140412