M2E: Version is duplicate of parent version - Why is this a warning?
Asked Answered
I

3

50

I have several Maven projects that each have some common functionality or at least common configuration/dependencies. I extracted this in to a common pom.xml, and then modularlized several facets, for example persistence, Spring related dependencies, and so on - all in their own modules which inherit from this parent POM.

Right now, "Common" is version 1.0.0 and I have "ProjectA" that I wish to inherit from it. I receive the warning:

Version is duplicate of parent version

I don't fully understand why this is a warning. I thought I had the option of omitting the version from my project POM in order to inherit the version. (I do this for common modules - for example, common-spring adds additional common dependencies for Spring apps, and in fact, ProjectA actually inherits from common-spring.)

Isn't it just that - an option? If I change my ProjectA version to 1.0.1 or 2.0.0 all is well.

Introject answered 24/11, 2011 at 22:56 Comment(4)
For what it is worth, I am careful to only inherit from POMs and I depend on JARs. I declare a common.version property that is used in dependencyManagement, so that ProjectA can inherit from common-spring (which inherits from common) and depend on common-io (which also inherits from common) and they are all the same version.Introject
Is this particular warning issued by m2eclipse or Maven itself? (You can check on the command-line with mvn verify—probably—if Maven emits something like this or not.) Other than this it would be really helpful if you could post the pom.xml files in question. It is hard to visualize what's going on in your setup.Bidet
That's fair. I will do this on Wednesday because I am on vacation (no such thing as a vacation from SO though!). I am pretty sure it is a m2e warning.Introject
@Doug This now appears to be fixed, see my answer below.Tractarianism
W
59

It´s just m2e trying to be clever because the version element (like group id) sometimes can be redundant and be can be inherited from the parent POM, so it would be safe to remove this element from your child POM.

But sometimes this is not a redundant information, like when the parent and the child project have different life cycles, and m2e should allow this warning to be disabled. Unfortunately there is no way to do this yet: http://dev.eclipse.org/mhonarc/lists/m2e-users/msg01961.html

UPDATE: As Duncan says bellow, in newer versions you can disable this warning.

Woven answered 16/12, 2011 at 18:40 Comment(0)
T
62

Newer versions of m2e (since 1.1) now allow you to disable this warning.

Preferences > Maven > Warnings > Disable "Version is duplicate of parent version" warning

Original bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=356796

Tractarianism answered 3/10, 2012 at 14:49 Comment(2)
+1 you can tick it on in the preferences, but you'll need to do Project > Maven > Update Project ... in order for them to go awaySheba
@Sheba In the latest versions of Eclipse, as soon as you change Maven's Errors/Warnings settings in the preferences and click "Apply", a popup window will appear offering you to update projects now.Could
W
59

It´s just m2e trying to be clever because the version element (like group id) sometimes can be redundant and be can be inherited from the parent POM, so it would be safe to remove this element from your child POM.

But sometimes this is not a redundant information, like when the parent and the child project have different life cycles, and m2e should allow this warning to be disabled. Unfortunately there is no way to do this yet: http://dev.eclipse.org/mhonarc/lists/m2e-users/msg01961.html

UPDATE: As Duncan says bellow, in newer versions you can disable this warning.

Woven answered 16/12, 2011 at 18:40 Comment(0)
E
2

If it really annoys you, use a property to supress the warning with some cunning sleight of hand:

<version>${api.version}</version>
<properties>
    <api.version>0.0.1-SNAPSHOT</api.version>
</properties>

but all you'll really be doing is moving the warning to the console output:

[WARNING] Some problems were encountered while building the effective model for [project]
[WARNING] 'version' contains an expression but should be a constant.
Expletive answered 9/5, 2012 at 14:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.