Personally, I have done this with a Parent POM.  Every corporate project must 
directly, or indirectly, inherit a Corporate Parent POM.  This is generally 
useful because you can define common properties that Maven can leverage, even 
for local builds.  For example, one can declare properties for your JIRA host 
or Git host to avoid hard coding.  Most valuable is that POMs need to be 
explicit with plugin versions to ensure repeatable and reliable builds, and 
doing that for every project is very tedious, so a common Corporate Parent POM 
can define specific plugin versions and settings to minimize the burden for 
each project.

The alternate way is to use Profiles 
<http://maven.apache.org/guides/introduction/introduction-to-profiles.html>.  
You can configure settings on your CI/CD servers — see “global Maven-settings.”

Pro tip:  think about evolution!  Things will change; assuming that ONE set of 
standards will apply universally will usually lead to issues.  
(Incompatibilities will arise, and assuming that ALL projects can evolve 
instantly is unrealistic when you have more than a handful of projects.)  The 
nice thing about a Corporate Parent POM is that it can be versioned like any 
other Maven Artifact, so each Project can evolve at its own pace.  (If you are 
going with the Profile approach on your CI/CD server(s), you may need to 
leverage Project Metadata maintained at the CI/CD solution.)

Hope this helps,

Anthony


> On Mar 26, 2019, at 7:04 AM, Martin D'Aloia <[email protected]> wrote:
> 
> Hello,
> 
> Is it possible to enforce a set of rules defined outside the pom.xml being
> built (i.e. not defined in the current pom or in a parent pom)?
> 
> Ideally, I would like to define maven-enforcer-plugin rules in an external
> pom.xml and evaluate them over the pom.xml being build in order to not
> force to use a specific parent pom.
> 
> *CONTEXT:*
> I'm defining a CI/CD pipeline and I would like to enforce a set of rules
> over the pom.xml in order to be deployed to our internal repository (sort
> of validations performed to publish to Maven Central).
> 
> Thanks in advance for any suggestions!

Reply via email to