Keep permissions on files with Maven resources:testResources

Viewed 15374

Is it possible to keep permissions on file with Maven resources:testResources? My use case is a Selenium binary driver that I put in /src/test/resources that I would like to be able to use from my tests. My -rwxr-xr-x is however changed to -rw-r--r-- in target/test-classes.

3 Answers

My solution is to execute the scripts in a way that do not mind the flags. So, for instance, when running from Maven Exec Plugin, I use:

Before:

<executable>myScript.sh</executable>
<commandlineArgs>...</commandlineArgs>

After:

<executable>bash</executable>
<commandlineArgs>myScript.sh ...</commandlineArgs>

Note: If you use bash -c, it will also fail if the exec flag is off.


Adding this remarks from Jason van Zyl, one of the creators of Maven:

The maven-resources-plugin was never intended to create any resources that would be used in a naked filesystem. It was strictly intended to place resources into the resultant artifact for use in a platform independent way, in general from the classpath. If you want to move archives around that are going to be unpacked and used I suggest the assembly plugin for making the archives and the dependency plugin for unpacking them.

http://maven.40175.n5.nabble.com/maven-resources-plugin-not-retaining-unix-permissions-td4938002.html

Related