UPDATE:
If I change ${env.JAVA_HOME} to a system property ${java.home} then it executes the maven-dependency-plugin unpack and copy tasks. But now it fails on the maven-antrun-plugin:1.8:run (build-content).
[ERROR] one of its dependencies could not be resolved: Could not find artifact ... at specified path ... -> [Help 1]
Why is it looking for my jar files in the JRE folder?
/{path to jdk}/Contents/Home/jre/lib/...
It's sitting right here:
/{path to jdk}/Contents/Home/lib
My pom.xml file is not reading my JAVA_HOME environment variable. I'm on a Mac. Here's the entry:
<dependencies>
<dependency>
<groupId>{groupId}</groupId>
<artifactId>{artifactId}</artifactId>
<version>${version}</version>
<scope>system</scope>
<systemPath>${env.JAVA_HOME}/lib/myPersonalJar.jar</systemPath>
</dependency>
</dependencies>
Here's the error:
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'build.plugins.plugin[org.apache.maven.plugins:maven-antrun-plugin].dependencies.dependency.systemPath' for ... must specify an absolute path but is ${env.JAVA_HOME}/lib/myPersonalJar.jar
In the iTerm app I can echo $JAVA_HOME and it points to the right place.
It works just fine when I hardcode the systemPath to my Java home. I can't figure out why. To give some context, my ant build files aren't reading my environment variables either.
Am I missing something stupid simple?
Try adding this profile to your pom.xml
(in <profiles/>
):
<profile>
<id>tools.jar</id>
<activation>
<file><exists>${java.home}/../lib/tools.jar</exists></file>
</activation>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>jdk</groupId>
<artifactId>tools</artifactId>
<version>${java.specification.version}</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<dependencies>
<dependency>
<groupId>jdk</groupId>
<artifactId>tools</artifactId>
<version>${java.specification.version}</version>
<scope>system</scope>
<systemPath>${java.home}/../lib/tools.jar</systemPath>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<configuration>
<docletPath>${tools.jar}</docletPath>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
I've included the corresponding change to the javadoc plug-in which may or may not be useful to you. You can remove it if you don't need it.