Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

use different java versions for different maven plugins

I have a pom including some plugins. The project's sources are java 17 and as such, the maven build is run with a jdk17+. Now, one of the plugins bound to the site lifecycle, let's say plugin P1, is older and it doesn't work with java versions newer than 9 ( because of some deprecated API that is no longer present in the jdk)

My question is: is it possible to somehow configure in the pom that some plugins should be run with a different java version?

My intention is to run the plugin as it is, not wanting to re-write it or modify it in any way. I know about maven toolchains, but I don't see how this applies, as that configures the jdk version for all plugins.

like image 249
Chirlo Avatar asked Feb 06 '26 07:02

Chirlo


1 Answers

Depending on the plugins and the context, you may solve the problem by using separate Maven runs, i.e. run

mvn clean install

with JDK17 and then run mvn some:plugin with a different JDK.

like image 84
J Fabian Meier Avatar answered Feb 09 '26 08:02

J Fabian Meier