0

I need to pass jdkHome value to exec-maven-plugin and set it as $JAVA_HOME. The toolchain plugin configuration:

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-toolchains-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>toolchain</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <toolchains>
                        <jdk>
                            <version>11</version>
                        </jdk>
                    </toolchains>
                </configuration>
            </plugin>

and I need to pass jdkHome value (configured in the toolchains.xml) to set $JAVA_HOME environment variable.

            <plugin>
                <groupId>org.codehaus.mojo</groupId>
                <artifactId>exec-maven-plugin</artifactId>
                <version>3.1.0</version>
                <executions>
                    <execution>
                        <id>build-test-environment</id>
                        <phase>generate-test-resources</phase>
                        <goals>
                            <goal>exec</goal>
                        </goals>
                    </execution>
                </executions>
                <configuration>
                    <executable>JAVA_HOME=<jdkHome-value> <command-which-reads-$JAVA_HOME></executable>
                </configuration>
            </plugin>

Thanks for help.

Pat
  • 391
  • 2
  • 3
  • 13
  • Please check the documentation for using toolchains: https://www.mojohaus.org/exec-maven-plugin/examples/example-exec-using-toolchains.html and why even need toolchain? Use JDK11+ ? – khmarbaise Aug 13 '23 at 09:56
  • I don't see the solution in documentation :-( It's build by Jenkins and each team uses different configuration, that's why setting JAVA_HOME. Thanks – Pat Aug 13 '23 at 17:07

0 Answers0