'exec-maven-plugin: Can I run exec:exec goal without first running the toolchains:toolchain goal?

I've inherited an application that only compiles and runs in Java 1.8. Because I don't want to make Java 1.8 the primary jvm on my machine, I felt that the best way to manage this was through Maven toolchains. Configuring the maven-compiler-plugin was pretty straight forward, but I also want to add the ability to execute the service via Maven in order to take advantage of the toolchain I have configured for 1.8.

The challenge is that I don't seem to be able to get the exec-maven-plugin to use the toolchain as documented. According to the documentation, I would think that the exec-maven-plugin would utilize the maven-toolchains-plugin as needed. However, in order to get exec:exec to use the right toolchain, I have to use:

mvn toolchains:toolchain exec:exec

This works, but the documentation leads me to think that the toolchain would be configured automatically without me needing to execute the toolchains:toolchain goal.




<?xml version="1.0" encoding="UTF8"?>

Additional Note: I also tried configuring the exec-maven-plugin to run on exec:java with the following configuration:


However this does not work, not even with mvn toolchains:toolchain exec:java.

Is there a way to configure this so that I only have to run mvn exec:exec, or mvn exec:java?

Solution 1:[1]

I think the answer is you must ensure that the toolchains plugin itself is part of your build. Or that's what the relevant documentation seems to say. (I see above you have that; what I'm saying is yes, that is required.)


This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Laird Nelson