Tutorial :Java Maven enforcer rule error



Question:

Hi all I'm new to apache maven. I imported a project into netbeans everything seems well but i get this error when trying to build it:

[WARNING] Rule 2: org.apache.maven.plugins.enforcer.RequireProperty failed with message: Property "loadVersion" is required for this build.

I think this means that the version of one of the dependencies in the pom.xml file are wrong but not sure. Any help is appreciated.


More detail from the question poster:

I'm working on a small part of a project and the part I'm working on has a pom.xml file. This file doesn't have any enforcer rules. However the top level (or highest level pom.xml file) does have an enforcer rule with the required version:

<plugin>  <groupId>org.apache.maven.plugins</groupId>  <artifactId>maven-enforcer-plugin</artifactId>  <version>1.0-beta-1</version>  </plugin>  

Shouldn't this be enough?


More details from the OP:

It seems I could have just commented this line out in the top level pom file:

<requireProperty>    <property>loadVersion</property>  </requireProperty>  

But then I would get other errors. I then read the project sites thoroughly and found out that the project's code can and only should be built with their provided build scripts. When building with their scripts the build is successful. This is good and bad it because now I have to edit code in the IDE and then build it in the terminal, but at least it's a solution.


Solution:1

Your project is using the Maven Enforcer Plugin which is somewhere configured (in a parent POM, in an active profile) to "enforce the existence and values of properties" using the requireProperty rule, in your case a loadVersion property.

Declaring such a custom property with Maven can be done in a pom.xml directly under the project element or in a profile or in a profile in the settings.xml by adding the following:

<properties>    <loadVersion>someValue</loadVersion>  </properties>  

And this property can then be referenced by ${loadVersion}. I have of course no idea of the value that should be set.

See also


Solution:2

I'm going to guess that your pom.xml uses the enforcer plugin and that you have not defined the loadVersion property as per the rule constraints.


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »