Keep permissions on files with Maven resources:testResources

Viktor Hedefalk picture Viktor Hedefalk · Jun 29, 2011 · Viewed 13.8k times · Source

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.

Answer

wjans picture wjans · Jun 29, 2011

This seems to be a bug in the Maven Resource Plugin

If you are using the Maven Assembly Plugin, you can configure the file permissions there.

If not, you might consider a workaround. You could do this via Ant by doing something like this:

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-antrun-plugin</artifactId>
    <version>1.6</version>
    <executions>
        <execution>
            <id>process-test-classes</id>
            <phase>process-test-classes</phase>
            <configuration>
                <target>
                    <chmod file="target/test-classes/test.sh" perm="755"/>
                </target>
            </configuration>
            <goals>
                <goal>run</goal>
            </goals>
        </execution>
    </executions>
</plugin>