Pat
Pat

Reputation: 419

Use javaHome, from toolchain, to set JAVA_HOME in exec-maven-plugin

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.

Upvotes: 0

Views: 354

Answers (0)

Related Questions