javamavenmaven-pluginmaven-dependency-pluginmaven-dependency

maven dependency plugin throwing error even if I add flag ignoreunuseddeclareddependecy


I am trying to build my code and I am getting this error:

[WARNING] Unused declared dependencies found:
[WARNING]    com:test-client:jar:v1.0-SNAPSHOT:compile

This is the configuration of the dependency plugin in my pom:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <executions>
                    <execution>
                        <id>analyze</id>
                        <goals>
                            <goal>analyze-only</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
<!--                    <usedDependencies>-->
<!--                        <usedDependency>com:test-client</usedDependency>-->
<!--                    </usedDependencies>-->
                    <failOnWarning>true</failOnWarning>
                    <ignoreNonCompile>true</ignoreNonCompile>
                    <ignoredUnusedDeclaredDependencies>
<!--                        <ignoredUnusedDeclaredDependency>*:test-client:*</ignoredUnusedDeclaredDependency>-->
                    </ignoredUnusedDeclaredDependencies>
                </configuration>
            </plugin>

I tried to add the test-client to the flag ignoredUnsedDeclaredDependecy (see the commented part) but still getting error.

I tried to set the failOnWarning flag to false but also I get same warning.

When I added this section it works.

<usedDependencies>
                        <usedDependency>com:test-client</usedDependency>
                    </usedDependencies> 

But why the 2 other flags are not being taken?

Note that I am working in a multi module project and this is a child pom of a parent pom.


Solution

  • I figured out what was the issue! my settings were override by the parent pom, why so? because in the parent pom the configuration is written under execution, however in my pom the configuration is outside execution (directly under plugin) when I moved the configuration in my plugin under the execution, my settings were taken into consideration