[ 
https://jira.codehaus.org/browse/MENFORCER-174?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=349023#comment-349023
 ] 

James Nord commented on MENFORCER-174:
--------------------------------------

We use something very similar - but as per comment from Jorg jusr allowing or 
disallowing (especially for site is not really good enough).

we allow the users to choose from 2 URLs for deployment (nexus with staging 
support, and nexus without).  For the Site we need to make sure that it is 
specified in every single pom to be correct (and that it matches a specific 
string.)

Would be nice if this could cover these use cases.

e.g. (would need to take configuration for a list of allowed sites/distribution 
parts. (an empty list could be defined as none allowed.)

        /**
         * Checks the Site distribution URL and the project URL have been set 
correctly.
         * 
         * @param project the project we are checking.
         * @param log the log for debug etc.
         * @throws EnforcerRuleException
         */
        private void checkURL(MavenProject project, Log log) throws 
EnforcerRuleException {
                final String siteURL;
                if (project.getDistributionManagement() != null && 
project.getDistributionManagement().getSite() != null) {
                        siteURL = 
project.getDistributionManagement().getSite().getUrl();
                }
                else {
                        siteURL = null;
                }

                // TODO this URLs should probably be configurable.
                final String expectedSiteURL = 
"scp://mydocserver/mountpoint/maven_sites/${project.groupId}/${project.artifactId}/${project.version}";
                final String resolvedSiteURL = resolveString(expectedSiteURL, 
project);

                if (siteURL == null) {
                        throw new EnforcerRuleException("The project has not 
defined the distributionManagement->site->url.  Please define it to the correct 
string.");
                }
                if (resolvedSiteURL.equals(siteURL)) {
                        //ok! siteURL uses scp
                } else {
                        log.warn("Site URL is [" + url + "]");
                        throw new EnforcerRuleException("Project must use the 
site publication url " + expectedSiteURL + ".");
                }
        }

Using something like the above and allowing maybe a regexp of allowed paths you 
could call the rule restrictDistributionManagement and still have it not allow 
any overrides?

> Add a Rule for distributionManagement
> -------------------------------------
>
>                 Key: MENFORCER-174
>                 URL: https://jira.codehaus.org/browse/MENFORCER-174
>             Project: Maven Enforcer Plugin
>          Issue Type: New Feature
>          Components: Documentation, Standard Rules
>            Reporter: Karl-Heinz Marbaise
>            Assignee: Karl-Heinz Marbaise
>            Priority: Minor
>             Fix For: 1.4
>
>
> It would be a good idea having a rule which controls the 
> distributionManagement part in the pom file. 
> For example:
> # Does not allow any distributionManagement in a pom or it's parents
> # Does not allow distributionManagement in the whole reactor of a build but 
> allows it within the parent of the reactor (company pom).



--
This message was sent by Atlassian JIRA
(v6.1.6#6162)

Reply via email to