apache / apache/maven-filtering
[MSHARED-1004] Two (2) issues with symbolic links
- Dominant language
- Java
- Stars
- 9
- Forks
- 36
- Avg merge
- 8h 47m
- Merged PRs (30d)
- 4
Description
**[Jimisola Laursen](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=JIRAUSER281352)** opened **[MSHARED-1004](https://issues.apache.org/jira/browse/MSHARED-1004?redirect=false)** and commented
Two issues with (relative) symbolic links as resources (use attached file for reference and MWE:
```
user@earhart:~/dev/test/my-app$ tree
.
├── pom.xml
├── src
│ ├── main
│ │ ├── java
│ │ │ └── com
│ │ │ └── mycompany
│ │ │ └── app
│ │ │ └── App.java
│ │ └── resources
│ │ ├── B -> ../../../to_be_symlinked/B
│ │ └── folder -> ../../../to_be_symlinked/folder
│ └── test
│ └── java
│ └── com
│ └── mycompany
│ └── app
│ └── AppTest.java
└── to_be_symlinked
├── B
└── folder
└── A
```
* Symlinks for directories copies the actual directory (folder/A) whereas symlinks for files copies the symlink (B). Note the difference between file A and B. B is pointing incorrectly since it is relative.
```
user@earhart:~/dev/test/my-app/target/classes$ ls -l
total 8
lrwxrwxrwx 1 user user 26 dec 10 10:19 B -> ../../../to_be_symlinked/B
drwxrwxr-x 3 user user 4096 dec 10 10:19 com
drwxrwxr-x 2 user user 4096 dec 10 10:19 folder
user@earhart:~/dev/test/my-app/target/classes$ ls -l folder/
total 0
-rw-rw-r-- 1 user user 0 dec 10 10:19 A
```
* Resources are not overwritten (java.nio.file.FileAlreadyExistsException). To reproduce run "mvn compile" two (2x) times:
```
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources) on project my-app: copying /home/user/dev/test/my-app/src/main/resources/folder/A to /home/user/dev/test/my-app/target/classes/folder/A failed with FileAlreadyExistsException: /home/user/dev/test/my-app/target/classes/folder/A -
```
---
**Affects:** maven-filtering-3.3.0
**Attachments:**
- [my-app.tar.gz](https://issues.apache.org/jira/secure/attachment/13037246/my-app.tar.gz) (_1.56 kB_)
- [my-app-wo-symlinks.tar.gz](https://issues.apache.org/jira/secure/attachment/13037374/my-app-wo-symlinks.tar.gz) (_1.50 kB_)
**Issue Links:**
- [MSHARED-966](https://issues.apache.org/jira/browse/MSHARED-966) Resources are not copied to ${project.build.outputDirectory}
- [MRESOURCES-237](https://issues.apache.org/jira/browse/MRESOURCES-237) Resource plugin's handling of symbolic links changed in 3.0.x, broke existing behavior
- [MRESOURCES-269](https://issues.apache.org/jira/browse/MRESOURCES-269) Symlinks cause copying resources to fail
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with the attached my-app.tar.gz minimal example and reproduce the behavior with "mvn compile" twice. Compare directory and file symlink handling in target/classes, then verify that repeated resource copying no longer raises FileAlreadyExistsException and that relative links are handled correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100