How to get de latest selenium version from maven [duplicate] - java

This question already has answers here:
How do I tell Maven to use the latest version of a dependency?
(12 answers)
Closed 7 months ago.
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:
mvn versions:display-dependency-updates
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.

Plugin Metaversion Resolution
Incase you are using Maven 2.x, it can pick the latest version available where the latest version could either be a release or a snapshot. Internally, Maven 2.x used the special version markers RELEASE and LATEST to support automatic plugin version resolution.
As an example:
Using RELEASE:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>RELEASE</version>
</dependency>
Using LATEST:
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>LATEST</version>
</dependency>
However, Maven 3.x no longer supports usage of these metaversions in the POM. As a result, users will need to replace occurrences of these metaversions with a concrete version.
References
You can find a couple of relevant detailed discussion in:
How to automatically update selenium version in POM?

Related

JavaFX classes cannot be resolved when migrating projects from JDK 8 to 11 in eclipse (actually STS) w. Maven

I have a larger Java project separated into different maven modules, based on Spring Boot and JavaFX that compiled fine on Java 8. I thought it is about time to make the switch to a newer version and decided for version 11. As it turns out I found a number of web pages and movies, but most of them explain how to setup a new project or they must miss something, because if I applied the proposed changes it didn't work. Hence I turned many different screws and made eventually good progress, but I don't know what was actually necessary to got so far and what is not needed. Anyway, the compiler found most of the JavaFX classes, but some cannot be resolved: HTMLEditor, TableHeaderRow, TableViewSkin, WebView and a few more.
I assume the root cause are missing dependencies in the parent-pom?! I do have
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-fxml</artifactId>
<version>11</version>
</dependency>
<dependency>
<groupId>org.openjfx</groupId>
<artifactId>javafx-controls</artifactId>
<version>11</version>
</dependency>
What dependencies are missing and where can I find which dependency maps which JavaFX class?
I have not created any module-info.java so far - because I couldn't find out how to to do this if the project already exists and I saw that some where adding parameters when starting a JavFX application. If this is needed as well I would be grateful for any advice.

Does Mojo's AspectJ Maven Plugin work with jdk 9+?

I have a project that uses Mojo's AspectJ Maven Plugin. It works fine with jdk 8. When I try to switch to jdk14, the build fails with the following error:
[ERROR] Failed to execute goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile (default) on project AspectJDemo: Execution default of goal org.codehaus.mojo:aspectj-maven-plugin:1.11:compile failed: Plugin org.codehaus.mojo:aspectj-maven-plugin:1.11 or one of its dependencies could not be resolved: Could not find artifact com.sun:tools:jar:13.0.2 at specified path /usr/local/Cellar/openjdk/13.0.2+8_2/libexec/openjdk.jdk/Contents/Home/../lib/tools.jar -> [Help 1]
Mojo's website confirms that this file is a required dependency. However, according to this tools.jar has been removed since jdk 9. I have tried to provide a hardcoded path to this jar file in my dependencies like this:
<dependency>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>1.8</version>
<scope>system</scope>
<systemPath>/path/to/tools.jar</systemPath>
</dependency>
But then the build completely fails as if it stops recognizing Java entirely. I get numerous errors such as:
[ERROR] can't find critical required type java.lang.Object
<unknown source file>:<no line information>
Does this mean Mojo's AspectJ Maven Plugin does not support jdk9+? Any idea on how I could resolve this is appreciated.
Update 2021-10-26: Because someone asked in a comment, a short overview of the status quo:
I as a co-maintainer of AspectJ proper am also maintaining the AspectJ.dev AspectJ Maven Plugin, because Nick's version is no longer maintained. The current version dev.aspectj:aspectj-maven-plugin:1.13.1 supports Java 17 and by default uses AspectJ 1.9.8.RC1 which also fully supports Java 17. It has more features than the other upstream and forked variants and is the variant I recommend. It can also parse version numbers greater than 17, i.e. in the future you can simply upgrade the AspectJ plugin dependency and increase the Java compliance level without having to upgrade the plugin version as such, unless you need new plugin features.
Lately there also was some activity at Mojohaus, mostly because I asked them if they could declare their plugin as deprecated, as there was no release in 3.5 years and support questions and PRs were being ignored for a long time. When they noticed that I published my own version, because as an AspectJ contributor I was concerned that Maven users had been left alone for such a long time, they merged in some (not all) of my changes and released version 1.14.0 which supports Java 16, but not Java 17.
Having said that, I recommend this plugin:
<dependency>
<groupId>dev.aspectj</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.13.1</version>
</dependency>
Previous version of this answer (now obsolete): The plugin has not been maintained since Java 8, but there is a fork with a pull request to be accepted up-stream. Because Mojohaus has no active maintainer for the plugin and the fork's developer has not been granted access rights to take over and push out an upstream release yet, for now just use this fork:
<dependency>
<groupId>com.nickwongdev</groupId>
<artifactId>aspectj-maven-plugin</artifactId>
<version>1.12.6</version>
</dependency>
I have used it for a long time, it is reliable and works at least up to Java 13. Even the latest version of IntelliJ IDEA automatically recognises it as an alternative to the Mojohaus version because this process has taken so long already.
P.S.: There is not need to provide hard-coded paths, just use the alternative plugin. :-)

javax.jnlp as maven dependency

Using JNLP (javax.jnlp) in one java project, I reaized that it is not part of the normal JDK.
As it is a Maven project I would like to add it as a dependency to my POM.
The one dependency I found working is:
<dependency>
<groupId>javax.jnlp</groupId>
<artifactId>jnlp-api</artifactId>
<version>8.0</version>
<scope>system</scope>
<systemPath>${java.home}/lib/javaws.jar</systemPath>
</dependency>
But depending on a system path looks bad to me - really bad.
system is marked as deprecated here: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
Is there no other way?
Getting it from repositories as an reasonable up to date version (java 8)?
Or what would be the clean way?

SolrJ version mismatch while merging 2 projects

I have 2 java projects which developed using Solrj.
Project 1 -> using solrj 4.10.1
Project 2 -> using solrj 5.2.1
Now, I am trying to merge both the projects to single project.
I tried including both version of jars in maven, still same issue.
If I try including only major version, I'm getting some of the classes(4.10.1) are deprecated and some interfaces are unavailable in it.
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>4.10.1</version>
<type>jar</type>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>5.2.1</version>
</dependency>
In simple:Few Packages of same project uses different jars.
example:
Package1/Module1 uses : Solrj Jar version 4.10.1
Package2 uses : Solrj Jar version 5.2.1
Is there any way to merge this projects in best way, without change old project ? I am totally stuck here.
If both projects are under the same Maven project (pom.xml), you need to update (or downgrade) one of the implementation. Both need to use the same SolrJ version. It shouldn't be too hard to update. You can find some details in Solr Wiki.

JSP support in Jetty 9.3

I'm trying to upgrade embedded Jetty to the latest version (9.3.2.v20150730 as of now) from an older release (9.3.0.M1).
I'm using JSP and current maven dependency is as follows:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-jsp</artifactId>
<version>9.3.0.M1</version>
</dependency>
However I can't find a new version for this dependency in maven central.
Looks like they have not released new jetty-jsp artifacts after 9.3.0.M1 for Jetty 9.3. New versions for all other jetty-related artifacts are available.
What is the alternative I should use for JSP support with latest Jetty version?
I got the answer from jett-users mailing list. Updated dependency is:
<dependency>
<groupId>org.eclipse.jetty</groupId>
<artifactId>apache-jsp</artifactId>
<version>${jetty.version}</version>
</dependency>
Also, from jetty-announce list:
The 9.2 release has switched to using the Apache version of Jasper for
JSP and JSTL. Early releases of Jetty used these implementations,
but switched to Glassfish when it became the reference implementation.
However the Apache version is now more rigorously maintained and hence
we have switched back. Currently we are using a slightly modified
version of 8.0.3, however our modifications have been contributed
back to apache and have been accepted for their 8.0.9 release, so we
will soon switch to using a standard jar from Apache.
Apparently they have switched back to standard jar from Apache.

Categories