codestyle/src/main/java/se/jguru/nazgul/tools/codestyle/enforcer/rules/AbstractEnforcerRule.java
@Override
    @SuppressWarnings("PMD.PreserveStackTrace")
    public final void execute(final EnforcerRuleHelper helper) throws EnforcerRuleException {

        final MavenProject project;
        try {
            project = (MavenProject) helper.evaluate("${project}");
        } catch (final ExpressionEvaluationException e) {

            // Whoops.
            final String msg = "Could not acquire MavenProject. (Expression lookup failure for: "
                    + e.getLocalizedMessage() + ")";
            throw new EnforcerRuleException(msg, e);
        }

        // Delegate.
        try {
            performValidation(project, helper);
        } catch (RuleFailureException e) {

            // Create a somewhat verbose failure message.
            String message =
                    "\n"
                            + "\n#"
                            + "\n# Structure rule failure:"
                            + "\n# " + getShortRuleDescription()
                            + "\n# "
                            + "\n# Message: " + e.getLocalizedMessage()
                            + "\n# " + "\n# Offending project [" + project.getGroupId() + ":"
                            + project.getArtifactId() + ":" + project.getVersion() + "]" + "\n#";

            final Artifact art = e.getOffendingArtifact();
            if (art != null) {

                message += "\n# Offending artifact [" + art.getGroupId() + ":" + art.getArtifactId()
                        + ":" + art.getVersion() + "]"
                        + "\n#";
            }
            message += "\n";

            // Re-throw for pretty print
            throw new EnforcerRuleException(message);
        }
    }
@Override
    @SuppressWarnings("PMD.PreserveStackTrace")
    public final void execute(final EnforcerRuleHelper helper) throws EnforcerRuleException {

        final MavenProject project;
        try {
            project = (MavenProject) helper.evaluate("${project}");
        } catch (final ExpressionEvaluationException e) {

            // Whoops.
            final String msg = "Could not acquire MavenProject. (Expression lookup failure for: "
                    + e.getLocalizedMessage() + ")";
            throw new EnforcerRuleException(msg, e);
        }

        // Delegate.
        try {
            performValidation(project, helper);
        } catch (RuleFailureException e) {

            // Create a somewhat verbose failure message.
            String message =
                    "\n"
                            + "\n#"
                            + "\n# Structure rule failure:"
                            + "\n# " + getShortRuleDescription()
                            + "\n# "
                            + "\n# Message: " + e.getLocalizedMessage()
                            + "\n# " + "\n# Offending project [" + project.getGroupId() + ":"
                            + project.getArtifactId() + ":" + project.getVersion() + "]" + "\n#";

            final Artifact art = e.getOffendingArtifact();
            if (art != null) {

                message += "\n# Offending artifact [" + art.getGroupId() + ":" + art.getArtifactId()
                        + ":" + art.getVersion() + "]"
                        + "\n#";
            }
            message += "\n";

            // Re-throw for pretty print
            throw new EnforcerRuleException(message);
        }
    }
This is the interface into the rule. This method should throw an exception
containing a reason message if the rule fails the check. The plugin will
then decide based on the fail flag if it should stop or just log the
message as a warning.

@param helper The helper provides access to the log, MavenSession and has
helpers to get common components. It is also able to lookup components
by class name.
@throws org.apache.maven.enforcer.rule.api.EnforcerRuleException the enforcer rule exception