如何在POM中自动更新selenium版本? [英] How to automatically update selenium version in POM?

查看:632
本文介绍了如何在POM中自动更新selenium版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在POM文件中自动获取selenium-java版本更新到最新版本而无需手动更改?



我试过创建一个 selenium.version 变量可以获取新的selenium更新,但我的POM拒绝索引变量并显示为红色

 <依赖性> 
< groupId> org.seleniumhq.selenium< / groupId>
< artifactId> selenium-java< / artifactId>
< version> $ {selenium.version}< / version>
< / dependency>

任何解决方法?

解决方案

老实说,最好的方法是完全按照你的方式做,你的pom.xml中的属性定义 $ {selenium.version} ,像这样:

 < properties> 
< selenium.version> 3.8.1< /selenium.version>
< / properties>

maven的核心原则是可重现的构建。如果您没有为依赖项提供具体的版本号(即使是像selenium这样的测试依赖项),那么当您发布新版本的selenium时,您可能会在一天内突然失败(或出现其他一些不一致)。 p>

你最好将版本定义为3.8.1,如果将来你看到需要升级(版本3.9.x ...版本4.x .. 。),只需更改< property> 并重建。



如果多个项目使用selenium,您可以将父pom中的< property> ,它们都定义为父级。


Is there a way to automatically get selenium-java version to update to the latest, in the POM file without having to manually change it?

I tried creating a selenium.version variable that can fetch a new update of selenium but my POM refuses to index the variable and it displays in red

<dependency>
  <groupId>org.seleniumhq.selenium</groupId>
  <artifactId>selenium-java</artifactId>
  <version>${selenium.version}</version>
</dependency>

Any workaround?

解决方案

Honestly, the best way is to do exactly as you have done, with a property in your pom.xml defining ${selenium.version}, like this:

<properties>
    <selenium.version>3.8.1</selenium.version>
</properties>

A core principle of maven is reproducible builds. If you dont provide a concrete version number for your dependency (even a test dependency like selenium), then you risk the build of your project suddenly failing one day (or having some other inconsistency) when a new version of selenium is released.

You're better to define the version as 3.8.1, and if in future you see the need to upgrade (version 3.9.x... version 4.x...), just change the <property> and rebuild.

If multiple projects use selenium you can put the <property> in a parent pom which they all define as a parent.

这篇关于如何在POM中自动更新selenium版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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