codestyle/src/main/java/se/jguru/nazgul/tools/codestyle/enforcer/rules/CorrectPackagingRule.java
@Override
    @SuppressWarnings("unchecked")
    protected void performValidation(final MavenProject project, final EnforcerRuleHelper helper)
            throws RuleFailureException {

        // Find all java source files, and map their packages to their names.
        final List<String> compileSourceRoots = (List<String>) project.getCompileSourceRoots();
        if (compileSourceRoots.size() == 0) {
            return;
        }

        final SortedMap<String, SortedSet<String>> packageName2SourceFileNameMap
                = new TreeMap<String, SortedSet<String>>();

        for (String current : compileSourceRoots) {
            addPackages(new File(current), packageName2SourceFileNameMap);
        }

        // Retrieve the groupId of this project
        final String groupId = project.getGroupId();
        if (groupId == null || groupId.equals("")) {

            // Don't accept empty groupIds
            throw new RuleFailureException("Maven groupId cannot be null or empty.", project.getArtifact());

        } else {

            // Correct packaging everywhere?
            final SortedSet<String> incorrectPackages = new TreeSet<String>();
            for (Map.Entry<String, SortedSet<String>> currentPackage : packageName2SourceFileNameMap.entrySet()) {

                final String candidate = currentPackage.getKey();
                if (!candidate.startsWith(groupId)) {
                    incorrectPackages.add(candidate);
                }
            }

            if (incorrectPackages.size() > 0) {

                final SortedMap<String, SortedSet<String>> result = new TreeMap<String, SortedSet<String>>();
                for (String current : incorrectPackages) {
                    result.put(current, packageName2SourceFileNameMap.get(current));
                }

                throw new RuleFailureException("Incorrect packaging detected; required [" + groupId
                        + "] but found package to file names: " + result, project.getArtifact());
            }
        }
    }
@Override
    @SuppressWarnings("unchecked")
    protected void performValidation(final MavenProject project, final EnforcerRuleHelper helper)
            throws RuleFailureException {

        // Find all java source files, and map their packages to their names.
        final List<String> compileSourceRoots = (List<String>) project.getCompileSourceRoots();
        if (compileSourceRoots.size() == 0) {
            return;
        }

        final SortedMap<String, SortedSet<String>> packageName2SourceFileNameMap
                = new TreeMap<String, SortedSet<String>>();

        for (String current : compileSourceRoots) {
            addPackages(new File(current), packageName2SourceFileNameMap);
        }

        // Retrieve the groupId of this project
        final String groupId = project.getGroupId();
        if (groupId == null || groupId.equals("")) {

            // Don't accept empty groupIds
            throw new RuleFailureException("Maven groupId cannot be null or empty.", project.getArtifact());

        } else {

            // Correct packaging everywhere?
            final SortedSet<String> incorrectPackages = new TreeSet<String>();
            for (Map.Entry<String, SortedSet<String>> currentPackage : packageName2SourceFileNameMap.entrySet()) {

                final String candidate = currentPackage.getKey();
                if (!candidate.startsWith(groupId)) {
                    incorrectPackages.add(candidate);
                }
            }

            if (incorrectPackages.size() > 0) {

                final SortedMap<String, SortedSet<String>> result = new TreeMap<String, SortedSet<String>>();
                for (String current : incorrectPackages) {
                    result.put(current, packageName2SourceFileNameMap.get(current));
                }

                throw new RuleFailureException("Incorrect packaging detected; required [" + groupId
                        + "] but found package to file names: " + result, project.getArtifact());
            }
        }
    }
Delegate method, implemented by concrete subclasses.

@param project The active MavenProject.
@param helper  The EnforcerRuleHelper instance, from which the MavenProject has been retrieved.
@throws RuleFailureException If the enforcer rule was not satisfied.