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

We Are Going To Discuss About Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin. So lets Start this Java Article.

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

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

    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.

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

    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.

Solution 1

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.

Original Author arash nadali Of This Content

Solution 2

You should solve the root cause of the issue, conflict between some of your dependecies, mvn/java version, there is a lot of possible reasons.

You might run mvn dependency:tree and check in the list if there is maybe 2 different versions or implementations of the same library from different package. Often you will have a parent pom or a dependency somewhere in the framework uncompatible with one that you added into your pom.

But often, despite this enforcer error your project could build and run perfectly so this is a workaround to build ignoring the error

To skip enforcer (not always working)

mvn clean install -Denforcer.skip=true

To continue the build if error

mvn clean install -Denforcer.fail=false

There is probably some ways to exclude a specific library from the enforcer rules too which is probably better that juste skipping everything.

Original Author amdev Of This Content

Solution 3

If you are using version 1.4.1 of maven-enforcer-plugin and it is resulting in this error then you need to use an older version of maven-enforcer-plugin. You can find the Maven dependency below :

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <version>1.3.1</version>
</plugin>

Other versions can be found from the link below.

https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-enforcer-plugin

Also, check your Maven version. If you are using maven 3.0.x then you need to use maven-enforcer-plugin 1.4.1.

Original Author Mayank Sharma Of This Content

Solution 4

It is possible that someone is enforcing a specific Maven version.

If you see the following message:

[WARNING] Rule 0:
org.apache.maven.plugins.enforcer.RequireMavenVersion failed with message:
Detected Maven Version: 3.5.4 is not in the allowed range [3.5.2,3.5.2].

Then change your maven installation to the something in the specified range.
In this example, only version 3.5.2 is allowed.

Original Author Miryam Chaabouni Of This Content

Conclusion

So This is all About This Tutorial. Hope This Tutorial Helped You. Thank You.

Also Read,

Siddharth

I am an Information Technology Engineer. I have Completed my MCA And I have 4 Year Plus Experience, I am a web developer with knowledge of multiple back-end platforms Like PHP, Node.js, Python and frontend JavaScript frameworks Like Angular, React, and Vue.

Leave a Comment