如果存储库中存在较新版本的依赖项,如何使Maven构建失败? [英] How to fail maven build if newer version of dependency exists in repository?

查看:74
本文介绍了如果存储库中存在较新版本的依赖项,如何使Maven构建失败?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,问题是我希望Maven在构建时检查依赖版本,并警告我是否有任何较新的依赖版本(实际上-如果我使用某些模块的过时版本,请通知我).我的Maven模块A具有以下依赖关系:

Well, the problem is that I want maven to check dependency version on build and warn me if there are any newer dependency versions (in fact - notify me if I use an outdated version of some module). My maven module A has the following dependency:

<dependency>
    <groupId>com.example.mycompany</groupId>
    <artifactId>commons</artifactId>
    <version>1.0.3</version>
</dependency>

com.example.mycompany:commons模块实际上已经可以具有1.0.4版本.有什么方法可以检查回购中依赖项的版本,如果已经有较新的版本,则构建失败.

And com.example.mycompany:commons module in fact can already have 1.0.4 version. Is there any way to check version of the dependency in repo and fail the build if newer version is already available.

我希望versions-maven-plugin可以做到.但是我找不到合适的配置.

I hope that versions-maven-plugin can make it. But I can not find appropriate configuration.

推荐答案

可以使用 maven-enforcer-plugin .您必须创建自己的自定义规则,因为没有标准规则似乎符合您的需求.

This problem can be solved with the maven-enforcer-plugin. You have to create your own custom rule, because non of the standard rules seem to match your needs.

您将要实施的规则的概念应该是强制依赖关系为最新.要实施检查,您可以从您提到的versions-maven-plugin中获得启发.

The notion of the rule you are going to implement should be enforce dependencies are up to date. To implement the check you could get some inspiration by the versions-maven-plugin you mention.

这篇关于如果存储库中存在较新版本的依赖项,如何使Maven构建失败?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆