开发者

Java Maven enforcer rule error

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开发者_Go百科 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.


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

  • POM Reference
  • The complete reference for the POM structure
  • Settings Reference


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜