Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to avoid banned dependency error in maven?

Tags:

java

maven

I cannot build my project due to following error:

[WARNING] Rule 6: org.apache.maven.plugins.enforcer.EnforceBytecodeVersion failed with message:
Found Banned Dependency: de.lmu.ifi.dbs.utilities:common-extension-lib:jar:2.4.0
Found Banned Dependency: de.lmu.ifi.dbs.jfeaturelib:JFeatureLib:jar:1.6.1
Use 'mvn dependency:tree' to locate the source of the banned dependencies.
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ----------------
Failed to execute goal org.apache.maven.plugins:maven-enforcer-plugin:1.3.1:enforce (enforce-rules) on project : 
Some Enforcer rules have failed. Look above for specific messages explaining why the rule failed.

I tried to use mvn install -Denforcer.skip=true but it did not work as well

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

UPDATE:

I also tried to override the enforcer plugin as follows but still the error remains the same:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-enforcer-plugin</artifactId>
    <executions>
        <execution>
            <id>enforce-banned-dependencies</id>
            <goals>
                <goal>enforce</goal>
            </goals>
            <configuration>
                <rules>
                    <bannedDependencies>
                        <includes>
                            <include>de.lmu.ifi.dbs.utilities:common-extension-lib</include>
                            <include>de.lmu.ifi.dbs.jfeaturelib:JFeatureLib</include>
                        </includes>
                    </bannedDependencies>
                </rules>
                <enforceBytecodeVersion>
                    <maxJdkVersion>1.6</maxJdkVersion>
                    <excludes>
                        <exclude>de.lmu.ifi.dbs.jfeaturelib:JFeatureLib</exclude>
                        <exclude>de.lmu.ifi.dbs.utilities:common-extension-lib</exclude>
                    </excludes>
                </enforceBytecodeVersion>

            </configuration>
        </execution>
    </executions>
</plugin>
like image 410
luksmir Avatar asked Aug 21 '15 08:08

luksmir


People also ask

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.

How do you solve require upper bound dependencies error?

How to fix require upper bound dependencies error. If that artifact is already declared in pom. xml, update the version in the pom. xml to the newest version listed in the output from maven-enforcer-plugin.

How do I exclude a specific version of a dependency in Maven?

Multiple transitive dependencies can be excluded by using the <exclusion> tag for each of the dependency you want to exclude and placing all these exclusion tags inside the <exclusions> tag in pom. xml. You will need to mention the group id and artifact id of the dependency you wish to exclude in the exclusion tag.


1 Answers

You can modify the configuration of the enforcer plugin. For example:

<configuration>
   <rules>
      <enforceBytecodeVersion>
         <maxJdkVersion>1.5</maxJdkVersion>
            <excludes>
               <exclude>org.mindrot:jbcrypt</exclude>
            </excludes>
      </enforceBytecodeVersion>
   </rules>
   <fail>true</fail>
</configuration>

You could increase the max JDK version.

You could add an exclude for the jars.

You could set fail to false.

like image 96
Conor Roche Avatar answered Sep 22 '22 12:09

Conor Roche