Maven依赖插件抛出错误,即使我添加flag imageunusedDeclaredDependecyecy
我正在尝试构建我的代码,并且会遇到此错误:
[WARNING] Unused declared dependencies found:
[WARNING] com:test-client:jar:v1.0-SNAPSHOT:compile
这是我的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>
我试图将测试客户添加到FLAG忽略的trag-nunsedDeclaredDippedecy中(请参阅注释的部分),但仍会遇到错误。
我试图将FailOnwarning Flag设置为False,但也会得到同样的警告。
当我添加本节时,它可以正常工作。
<usedDependencies>
<usedDependency>com:test-client</usedDependency>
</usedDependencies>
但是,为什么没有采取其他两个旗帜呢?
请注意,我正在一个多模块项目中工作,这是父型POM的孩子。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
failonwarning
使Maven构建失败如果发出警告,则不会删除或阻止警告。参见关于Exluseions的配置,请参见
提供了类似的例子;
因此,您的语法应该是正确的。
您是否依赖最新版本的插件?如果没有,请尝试将版本编号更新为最新的版本,您可以访问: https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-depperency-plugin
忽略了declaredDepentencies
在插件版本2.10
和忽略nontestscopedDepentencies
以来,因为3.3.0
。还要根据 https://maven.apache.org/plugins/maven-depparency-plugin/examples/filtering-the-deplyency-tree.html
failOnWarning
makes the maven build fail if a warning was generated, it doesn't remove or prevent the warnings. See https://maven.apache.org/plugins/maven-dependency-plugin/examples/failing-the-build-on-dependency-analysis-warnings.htmlRegarding the configuration of exlusions, see https://maven.apache.org/plugins/maven-dependency-plugin/examples/exclude-dependencies-from-dependency-analysis.html
That gives an example like so;
So your syntax should be correct.
Do you depend on the latest version of the plugin? If not, try to update the version number to the most recent one you have access to: https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-dependency-plugin
ignoredUnusedDeclaredDependencies
was added in the plugin version2.10
andignoredNonTestScopedDependencies
since3.3.0
.Also check if your wildcard filter syntax is correct according to https://maven.apache.org/plugins/maven-dependency-plugin/examples/filtering-the-dependency-tree.html
我想出了什么问题!我的设置被父母POM所覆盖,为什么呢?因为在父pom中,配置是在执行下编写的,但是在我的pom中,当我在执行下移动插件中的配置时,配置在执行外部执行(直接在插件下),我的设置被考虑在考虑
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