Maven 2 & 3

Validate that a plugin is not configured twice in the pom

Details

  • Type: Improvement Improvement
  • Status: Closed Closed
  • Priority: Trivial Trivial
  • Resolution: Fixed
  • Affects Version/s: 2.0
  • Fix Version/s: 3.0-beta-1
  • Component/s: Plugins and Lifecycle
  • Labels:
    None
  • Complexity:
    Intermediate
  • Number of attachments :
    0

Description

Check that there're no two <plugin> elements of the same plugin

Issue Links

Activity

Hide
Kenney Westerhof added a comment -

What's the problem with multiple <plugin> sections for the same plugin? Right now it acts as a grouping for generic configuration.

I think it should be allowed. Take the antrun plugin for instance; you might want to run it twice using 2 different <dependencies>
defined as extensions for the plugin. They may be conflicting and need a fresh plugin realm. Or say the javadoc plugin,
once defined to generate normal html (using the standard doclet), and once using a custom doclet to generate XML, for instance.
Or an APT plugin that uses different processors, or....

If the plugins aren't stored in a Set, but in a List, there's no problem.

Show
Kenney Westerhof added a comment - What's the problem with multiple <plugin> sections for the same plugin? Right now it acts as a grouping for generic configuration. I think it should be allowed. Take the antrun plugin for instance; you might want to run it twice using 2 different <dependencies> defined as extensions for the plugin. They may be conflicting and need a fresh plugin realm. Or say the javadoc plugin, once defined to generate normal html (using the standard doclet), and once using a custom doclet to generate XML, for instance. Or an APT plugin that uses different processors, or.... If the plugins aren't stored in a Set, but in a List, there's no problem.
Hide
Carlos Sanchez added a comment -

Right now the problem is that all but one is completely ignored with no warning or error

Show
Carlos Sanchez added a comment - Right now the problem is that all but one is completely ignored with no warning or error
Hide
Duncan McNaught added a comment -

I agree with Kenney - with the exec-maven-plugin I would like to be able to specify different actions on mvn install or mvn deploy.
Can you confirm it this issue is going to allow multiple plugin sections for the same plugin, or is it going to validate this isn't possible.

Show
Duncan McNaught added a comment - I agree with Kenney - with the exec-maven-plugin I would like to be able to specify different actions on mvn install or mvn deploy. Can you confirm it this issue is going to allow multiple plugin sections for the same plugin, or is it going to validate this isn't possible.
Hide
Andreas Krüger added a comment -

I burned quite a bit of time this afternoon. I happened to have the same plugin in the same POM. For two completely different reasons. And was wondering why the first one kept being ignored. Tried all kinds of tweaks...

Please! As long as Maven can't handle this, don't silently ignore, but it should bomb out and give a decent error message!

(Handling this gracefully would be even better, of course.)

(Seen with Maven 2.0.6.)

Show
Andreas Krüger added a comment - I burned quite a bit of time this afternoon. I happened to have the same plugin in the same POM. For two completely different reasons. And was wondering why the first one kept being ignored. Tried all kinds of tweaks... Please! As long as Maven can't handle this, don't silently ignore, but it should bomb out and give a decent error message! (Handling this gracefully would be even better, of course.) (Seen with Maven 2.0.6.)
Hide
Benjamin Bentmann added a comment -

Added model validation warning in r928426.

Show
Benjamin Bentmann added a comment - Added model validation warning in r928426.
Hide
Paul Benedict added a comment -

How does the warning help? The above comments say duplication is a possible valid case. I think it should be an error but only if there are not duplicate executions.

Show
Paul Benedict added a comment - How does the warning help? The above comments say duplication is a possible valid case. I think it should be an error but only if there are not duplicate executions.
Hide
Benjamin Bentmann added a comment -

How does the warning help?

[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
Show
Benjamin Bentmann added a comment -
How does the warning help?
[WARNING] It is highly recommended to fix these problems because they threaten the stability of your build.
[WARNING]
[WARNING] For this reason, future Maven versions might no longer support building such malformed projects.
Hide
Paul Benedict added a comment -

If you don't mind me asking, what are your thoughts regarding those that support duplicate configurations? If it is a true problem, I say ban it outright.

Show
Paul Benedict added a comment - If you don't mind me asking, what are your thoughts regarding those that support duplicate configurations? If it is a true problem, I say ban it outright.

People

Vote (14)
Watch (9)

Dates

  • Created:
    Updated:
    Resolved: