plexus-compiler icon indicating copy to clipboard operation
plexus-compiler copied to clipboard

Overwrite lastModified on the folder after compiling

Open MartinKanters opened this issue 5 years ago • 2 comments

For implementing Maven issue MNG-4660 we would like to be able to know when the last compilation happened. We need this information to determine the packaged artifact (.jar) is up-to-date with the compiled sources (in target/classes usually). For now we will look through all target/classes files to check their lastModified time, but if we could use the lastModified time on the target/classes directory, we could improve performance a lot.

On Unix based systems, the target/classes directory will (if I remember correctly) be updated to the time of compilation, but for Windows it isn't. https://stackoverflow.com/questions/12249155/how-to-get-the-last-modified-date-and-time-of-a-directory-in-java

So my suggestion is to overwrite the lastModified property on the target/classes directory after compilation.

MartinKanters avatar Mar 26 '20 14:03 MartinKanters

On unix, the last modified date is modified only when the structure of the directory is changed, according to https://stackoverflow.com/questions/3451863/when-does-a-unix-directory-change-its-timestamp

So an explicit change would have to be done on both systems.

gnodet avatar Feb 08 '22 11:02 gnodet

MNG-4660 has been closed.

gnodet avatar Oct 27 '23 21:10 gnodet