Im using java and maven and I want to always get the last version of selenium-java. Is there any way to do that?
If I use this dependency I have a warning message
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>LATEST</version> </dependency>
In general you don’t want to do that. If there is a breaking change or a bug in the new version you’ll be stuck determining where the issue is.
Maven has two ways to address this. The first is:
this will display the libraries you are currently using and if there is a new version of them. For example, in an older project that I haven’t touched in a while I get things like:
[INFO] The following dependencies in Dependencies have newer versions: [INFO] com.fasterxml.jackson.core:jackson-databind ......... 2.9.10 -> 2.13.3 [INFO] com.google.code.gson:gson ............................. 2.8.6 -> 2.9.0 [INFO] com.jayway.jsonpath:json-path ......................... 2.5.0 -> 2.7.0 [INFO] commons-io:commons-io ................................ 2.8.0 -> 2.11.0
This is showing me where I need to take a look at updating. Nothing is automatically updated – this is a report that you need to generate by hand.
The second way may be closer to what you want. Maven can take a range of versions that you are willing to use. As a very general statement most libraries remain compatible if you don’t jump outside of at least the major version. That isn’t always true but you can decide that for your self. In your case you could change your dependency to:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>[4.3,5.0)</version> </dependency>
This tells Maven to use at least version 4.3.0 but not version 5.0 and above. If 4.3.1 comes out it will automatically use this. It will not though use anything 5.0 and above.
If you really think you need to keep upgrading forever, you’d change this to:
<dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>[4.3,)</version> </dependency>
which just says version 4.3.0 and above. If a version 5.0 comes out it will use this. There is zero guarantee that version 5.0 is compatible – maven will blindly start using it.
Answered By – stdunbar