After updating maven-resources-plugin to version 3.2.0 to get the fix for maintaining file permissions (x-bits), the copy fails when encountering a symbolic link of the form file -> ../file
(and possibly other symlinks too):
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:copy-resources
(copy-jdk) on project preinstall: <target>/jre/lib/amd64/server/libjsig.so -> [Help 1]
ll <source>/jre/lib/amd64/server/
lrwxrwxrwx 1 user users 13 Oct 22 15:09 libjsig.so -> ../libjsig.so
...
The target's jre/lib/amd64
folder received some files, but not yet libjsig.so. <source>/jre/lib/amd64/libjsig.so
exists, therefore the symlink's target would be created if the plugin did not abort.
Can anyone tell me if that's a bug or a feature? Any configuration / idea / workaround that allows to keep the source's file permissions and have symbolic links copied?
Here's the relevant pom.xml part:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<!-- version 3.2.0 stops on symlinks in the jdk, when the symlink target is not yet copied -->
<version>3.1.0</version>
<executions>
<execution>
<id>copy-jdk</id>
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${product.install.folder}/jdk</outputDirectory>
<resources>
<resource>
<directory>${jdk.tmp.folder}/${jdk.directory}</directory>
<filtering>false</filtering>
<include>**/*</include>
</resource>
</resources>
</configuration>
</execution>
...
Edit: BTW, creating a dummy target at <target>/jre/lib/amd64/libjsig.so
helps to continue with the copy task, but then, that dummy is not replaced during the copy (probably because it is newer) ...
Edit2: Playing around with the above dummy idea and the <overwrite> option. That option is not usable if the file tree contains read-only files. <overwrite> does not delete and recreate the files but tries to rewrite them, which fails for read-only files.
Therefore I think, the maven-resources-plugin might be the wrong approach to copy files around - here's the evolved question:
What is the best approach to copy a larger set of files (such as a jdk, which includes read-only files, executable files and symbolic links) from within a maven build?