~~ Licensed to the Apache Software Foundation (ASF) under one ~~ or more contributor license agreements. See the NOTICE file ~~ distributed with this work for additional information ~~ regarding copyright ownership. The ASF licenses this file ~~ to you under the Apache License, Version 2.0 (the ~~ "License"); you may not use this file except in compliance ~~ with the License. You may obtain a copy of the License at ~~ ~~ http://www.apache.org/licenses/LICENSE-2.0 ~~ ~~ Unless required by applicable law or agreed to in writing, ~~ software distributed under the License is distributed on an ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ~~ KIND, either express or implied. See the License for the ~~ specific language governing permissions and limitations ~~ under the License. ------ Ban DistributionManagement ------ Karl-Heinz Marbaise ------ June 2014 ------ Ban Distribution Management This rule can be used to force the absence of distributionManagement in your pom files. The following parameters are supported by this rule: * message - an optional message to the user if the rule fails. * allowRepository - You can allow repository entry (default: false). * allowSnapshotRepository - you can allow snapshotRepository entry (default: false). * allowSite - You can allow site entry (default: false). * ignoreParent - You can control if the parent will be checked or not (default: true) (deprecated don't use it anymore). [] Sample Plugin Configuration: +------+ [...] org.apache.maven.plugins maven-enforcer-plugin ${project.version} no-distribution-management-at-all enforce [...] +-------+ * Best Practice Usually you should define the <> only in a limited number of cases. If you are in a corporate environment it makes usually only sense to define the <> in the corporate pom and forbid the usage in any other pom's. Sometimes it makes sense to allow for example the site repository definition in your other pom's which can be defined by using the <> rule. For this use case the following has to be defined in your corporate pom file: +------+ [...] org.apache.maven.plugins maven-enforcer-plugin ${project.version} no-distribution-management-at-all enforce true [...] +------+ * The Project Types If we take a closer look to the possible project structures you will find the following cases where the green arrow will show our current position. * The Project without Parent. We have no parent and no modules at all. This could be the situation where we are creating a corporate pom file or another simple Maven project. So the definition of maven-enforcer-plugin is within this pom file. [images/root.png] Root Project. In consequence it does not really make sense to check if the pom contains distributionManagement entries or not. * Project with Parent. We have a project with a parent. The parent is likely a kind of a corporate pom file which contains the definition of maven-enforcer-plugin. So in this case it makes sense to check if distributionManagement entries are made or not. <>: At the moment it is not possible to check if the parent does not contain the definition of maven-enforcer-plugin which would change the situation. [images/root-with-parent.png] Root project. * Project with Parent and Modules. This situation is more or less the same as the one before. So banDistributionManagement rule will check the distributionManagement entries. [images/root-with-parent-and-modules.png] Root project with parent and modules. * Root Project With Modules. If we don't have a parent this means the definition of maven-enforcer-plugin is likely done in the current pom file which means it does not make really sense to check the distributionManagement. [images/root-with-modules.png] Root with Modules. * Module of a Multi Module Build In this case we have the scenario that the module m1 has a parent <> which could contain the definition of the maven-enforcer-plugin or the <> of which in consequence means to check the distributionManagement entries. [images/module.png] Root with Modules. []