-
Notifications
You must be signed in to change notification settings - Fork 30
[MSOURCES-95] Fix source Jar is re-created even when sources are not changed #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[MSOURCES-95] Fix source Jar is re-created even when sources are not changed #2
Conversation
In order to keep the empty source folders I've added |
The canonical approach in Git for retaining empty directories is to put a |
I've tried with Probably we should add |
If there is an empty source directory (such as generated-sources/annotations for example) the sources JAR will be re-created even if the sources have not changed. The reason is the default include pattern: "**/*". It does not include the directory itself and if the directory is empty there is no way for Plexus Archiver to know if the archive is up to date (no file or directory to compare with the last modification time of the archive), so it does the safe thing and re-creates the archive. Change the default includes pattern to "**/**". That will cause the empty directory itself (generated-sources/annotations in our example) to be considered when checking the last modification date so the archive will not be re-created if it is up to date. Please note that the change of the pattern will not change what is included in the archive -- the directory itself will not be included, only its content. This closes #2
If there is an empty source directory (such as generated-sources/annotations for example) the sources JAR will be re-created even if the sources have not changed. The reason is the default include pattern: "**/*". It does not include the directory itself and if the directory is empty there is no way for Plexus Archiver to know if the archive is up to date (no file or directory to compare with the last modification time of the archive), so it does the safe thing and re-creates the archive. Change the default includes pattern to "**/**". That will cause the empty directory itself (generated-sources/annotations in our example) to be considered when checking the last modification date so the archive will not be re-created if it is up to date. Please note that the change of the pattern will not change what is included in the archive -- the directory itself will not be included, only its content. This closes #2
@plamentotev Something is fishy here: https://builds.apache.org/job/maven-box/job/maven-source-plugin/job/MSOURCES-95/3/console I cannot make it fail locally. Any idea? |
It is interesting case. Actually the code works but the check fails. The test searches for the log messages that the jar is created and then that the jar is up to date:
Unfortunately it looks like this does not work on Windows in some cases. The tests searches for I've modified the post build script to build the jar files names using file objects instead of concatenating strings. I think that this should fix it. @michael-o would you please try it again. Unfortunately it is not easy to reproduce it locally even on my Windows machine. If this solution does not work I'll use comparison that ignores the letters case. |
If there is an empty source directory (such as generated-sources/annotations for example) the sources JAR will be re-created even if the sources have not changed. The reason is the default include pattern: "**/*". It does not include the directory itself and if the directory is empty there is no way for Plexus Archiver to know if the archive is up to date (no file or directory to compare with the last modification time of the archive), so it does the safe thing and re-creates the archive. Change the default includes pattern to "**/**". That will cause the empty directory itself (generated-sources/annotations in our example) to be considered when checking the last modification date so the archive will not be re-created if it is up to date. Please note that the change of the pattern will not change what is included in the archive -- the directory itself will not be included, only its content. This closes #2
Unfortunately, it does not work. I guess Jenkins does lowercase drive letters. Please reset your branch on top of the pushed one and modify the verify script. |
…changed If there is an empty source directory (such as generated-sources/annotations for example) the sources Jar will be re-created even if the sources are not changed. The reason is the default include pattern - "**/*". It does not include the directory itself and if the directory is empty there is no way for Plexus Archiver to know if the archive is up to date (no file or directory to compare with the last modification time of the archive), so it does the safe thing and re-creates the archive. Change the default includes pattern to "**/**". That will cause the empty directory itself (generated-sources/annotations in our example) to be considered when checking the last modification date so the archive will not be re-created if it is up to date. Please note that the change of the pattern will not change what is included in the archive - the directory itself will not be included, only its content.
@michael-o thank you for trying my change. I've updated the verify script to use regex instead of string match. |
@michael-o thank you for updating the verify script. |
Resolve #168 |
If there is an empty source directory (such as generated-sources/annotations for example) the sources Jar will be re-created even if the sources are not changed. The reason is the default include pattern -
**/*
. It does not include the directory itself and if the directory is empty there is no way for Plexus Archiver to know if the archive is up to date (no file or directory to compare with the last modification time of the archive), so it does the safe thing and re-creates the archive.Change the default includes pattern to
**/**
. That will cause the empty directory itself (generated-sources/annotations in our example) to be considered when checking the last modification date so thearchive will not be re-created if it is up to date. Please note that the change of the pattern will not change what is included in the archive - the directory itself will not be included, only its content.
p.s. This is updated version of #1, but I had to create new pull request as I was not able to update the original.