I want to copy files in ".jenkins" or in "Temp" direcotry.
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
<executions>
<execution>
<id>copy-resource-one</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>C:\Users\user\.jenkins</outputDirectory>
<resources>
<resource>
<directory>${basedir}/src/main/resources</directory>
<includes>
<include>htmlTemplate.html</include>
<include>Chart.js</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
This is how my pom.xml looks like for now. It is working for me on my local machine, but it won't work for another user.
This is what I want:
<outputDirectory> relative path to Temp </outPutDirectory>
Question: How can I ensure that the file is always copied in "temp" or in ".jenkins" folder? Is there any variable for that?
In Maven you can use Java properties as Maven properties for a build.
Maven exposes all properties from
java.lang.System
. Anything you can retrieve fromSystem.getProperty()
you can reference in a Maven property
So, in your case you could have the following:
<outputDirectory>${java.io.tmpdir}</outputDirectory>
And the output directory will point to the user temporary directory based on the host OS. For instance, in Windows 7 it would be
C:\Users\<user_Id>\AppData\Local\Temp
For a full list of Java properties, check official documentation, from which:
java.io.tmpdir
: Default temp file path
You may also be interested in the user.home
user.home
: User's home directory
So you probably wanted to point to ${user.home}\.jenkins
.