Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin

I got a maven spring project but when I try to run it, I can't... some idea about it...
The next is the Error Message:

BUILD FAILURE
------------------------------------------------------------------------
Total time: 4.532s
Finished at: Wed Jul 26 16:04:06 COT 2017
Final Memory: 17M/196M
------------------------------------------------------------------------
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.4.1:enforce
(enforce-versions) on project SIMI: Some Enforcer rules have failed. Look above for
specific messages explaining why the rule failed. -> [Help 1]

To see the full stack trace of the errors, re-run Maven with the -e switch.

Re-run Maven using the -X switch to enable full debug logging.

For more information about the errors and possible solutions, please read the following articles: [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

like image 503
Hsneider Salgado Neid Avatar asked Jul 26 '17 21:07

Hsneider Salgado Neid


People also ask

Why use maven enforcer plugin?

The Enforcer plugin provides goals to control certain environmental constraints such as Maven version, JDK version and OS family along with many more built-in rules and user created rules.

Which plugin goal can be used to cause a build failure if the project uses an old version of Maven or Java?

<artifactId>maven-enforcer-plugin</artifactId> <version>3.1. 0</version>

What is org Apache Maven plugins?

org.apache.maven.plugins » maven-javadoc-pluginApache. The Apache Maven Javadoc Plugin is a plugin that uses the javadoc tool for generating javadocs for the specified project. Last Release on Aug 13, 2022.

What is banned dependency in Maven?

This rule checks the dependencies and fails if any of the matching excludes are found. The following parameters are supported by this rule: searchTransitive - if transitive dependencies should be checked.


1 Answers

one thing that may cause this problem is that in your project in a POM file required java or maven version is set. you should find it... but how ? maybe you couldn't find any enforcer in your project like me ... (I had the same problem and I became confused because enforcer plugin was not defined in my projects POMs, so I couldn't find it).

enforcer plugin is in your "effective pom" and you should check it. Effective pom is a configuration file made from super pom + project pom. maven use this configuration file to execute the relevant goal. It helps developers to specify minimum configuration detail in his/her pom.xml. Although configurations can be overridden easily.

For showing your effective pom there are 2 ways: 1- use maven command, run this command :

 mvn help:effective-pom

2- use your IDE : in Maven window right click on your project node and select show effective POM(it depends on your IDE).

after you find what your forces are you can find it in your project and change it. for me, My effective POM had enforcer plugin which its requireMavenVersion rule for using Java was 1.8. so I changed my project JDK version to 1.8 and luckily the problem was solved.

I hope this answer could help you.

like image 185
arash nadali Avatar answered Sep 21 '22 12:09

arash nadali