private static Set<Artifact> getAllDependencies(EnforcerRuleHelper helper) throws EnforcerRuleException {
        try {
            MavenProject project = (MavenProject) helper.evaluate("${project}");
            MavenSession session = (MavenSession) helper.evaluate("${session}");
            DependencyGraphBuilder graphBuilder = helper.getComponent(DependencyGraphBuilder.class);
            ProjectBuildingRequest buildingRequest =
                    new DefaultProjectBuildingRequest(session.getProjectBuildingRequest());
            buildingRequest.setProject(project);
            DependencyNode root = graphBuilder.buildDependencyGraph(buildingRequest, null);
            return getAllRecursive(root);
        } catch (ExpressionEvaluationException | DependencyGraphBuilderException | ComponentLookupException e) {
            throw new EnforcerRuleException(e.getMessage(), e);
        }
    }
Enforces that all expected dependencies are present.
Fails by default for rules that do not match any dependencies.
Similar to the built-in 'bannedDependencies' rule in maven-enforcer-plugin.

@author bjorncs
vespa-enforcer-extensions/src/main/java/com/yahoo/vespa/maven/plugin/enforcer/EnforceDependencies.java