0

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?

Bdot42
  • 11
  • 3
  • See [this answer to _Best practices for copying files with Maven_](https://stackoverflow.com/a/42468595/1744774) using the [Wagon Maven Plugin](https://www.mojohaus.org/wagon-maven-plugin/). – Gerold Broser Oct 22 '21 at 20:27
  • Thanks for the link ... I tried wagon-maven-plugin:2.0.2:copy, with file:// urls. However, that creates an intermediate copy and is losing file permissions. And, it fails when overwriting read-only files. Going to try the sshexec goal next ... is that what you suggested? – Bdot42 Oct 23 '21 at 10:48

0 Answers0