How can I get the maven assembly to duplicate duplicate dependencies?

If I have two dependencies that are the same in the same pom, I want the build to fail. Currently, I can find this happening with the Dependency Maven plugin "anal-duplicate". However, there is no way to refuse a warning, like some others (plus, it prints at the information level, and not in a warning). Is there an alternative to expanding this?

+4
source share
1 answer

In general, when you want the build to fail for some reason, a good plugin will consider the Maven Enforcer Plugin . This plugin can be configured with a set of rules that, during verification, will not be able to complete the assembly.

In this case, it should be a rule that checks for dependencies duplicates, and there are built-in rule: <banDuplicatePomDependencyVersions>. So you could

<plugin>
  <artifactId>maven-enforcer-plugin</artifactId>
  <version>1.4.1</version>
  <executions>
    <execution>
      <id>enforce-no-duplicate-dependencies</id>
      <goals>
        <goal>enforce</goal>
      </goals>
      <configuration>
        <rules>
          <banDuplicatePomDependencyVersions/>
        </rules>
      </configuration>
    </execution>
  </executions>
</plugin>

Unfortunately, this rule is not documented (but it will be in the next version, see MENFORCER-259 ), but it has existed since version 1.3 of the plugin ( MENFORCER-152 ).

, , , 'dependencies.dependency.(groupId:artifactId:type:classifier)'; , POM, / .

+5

Source: https://habr.com/ru/post/1662343/


All Articles