Glide
Glide

Reputation: 21275

How to show which parent pom contains a plugin?

If my pom is a child a hierarchy of other poms, is there a way to show exactly which parent pom contains the definition of a plugin?

Upvotes: 2

Views: 342

Answers (1)

A_Di-Matteo
A_Di-Matteo

Reputation: 27862

Short answer is most probably: No.

According to the way Maven builds its model before executing a certain build, the Maven Builder Model:

  • In phase 1 the hierarchy of poms is resolved
  • In phase 2 model normalization and plugins configurations are further resolved
  • But only at the end of phase 2 the effective model validation is performed, which is done on the final effective pom.xml file, as a result of merges, overriding, profiling, injections (of properties) and so on.

To have a look at the full pom, the effective-pom goal of the maven-help-plugin is definitely the right tool. It will show (or write to a given file) the final effective pom a build is gonna use.

The full definition of a plugin (its executions, its global configuration and so on) can only be created once we have the effective pom, because:

  • the pluginManagement section in any point in the hierarchy can influence a certain plugin
  • The plugin section in any point in the hierarchy can also influnce it
  • profiles declared in any point in the hierarchy can also influence it
  • properties, if used as placeholders, can also play an important role

Having a look at the official Maven POM reference, we can see many entry point to influence a certain plugin definition, which will only be effective to our build once merged through the whole pom hierarchy. A definition per se would not help much since it can then be overriden/influenced further on on the hierarchy chain.


Think about the inherited element of a plugin:

true or false, whether or not this plugin configuration should apply to POMs which inherit from this one. Default value is true.

Or merging of plugin configuration sections:

The default behavior is to merge the content of the configuration element according to element name. If the child POM has a particular element, that value becomes the effective value. if the child POM does not have an element, but the parent does, the parent value becomes the effective value.
You can control how child POMs inherit configuration from parent POMs by adding attributes to the children of the configuration element. The attributes are combine.children and combine.self. Use these attributes in a child POM to control how Maven combines plugin configuration from the parent with the explicit configuration in the child.

Or further down per execution of a plugin:

inherited: Like the inherited element above, setting this false will supress Maven from passing this execution onto its children. This element is only meaningful to parent POMs.

The overall management can then be influenced by pluginManagement:

Plugin Management contains plugin elements in much the same way, except that rather than configuring plugin information for this particular project build, it is intended to configure project builds that inherit from this one. However, this only configures plugins that are actually referenced within the plugins element in the children. The children have every right to override pluginManagement definitions.

As such, the plugin definition at a certain point of the pom hierarchy may not be meaningful to the final effective build.

Upvotes: 3

Related Questions