janbalangue opened a new pull request, #380:
URL: https://github.com/apache/maven-source-plugin/pull/380

   Fixes #239.
   
   **Where the entries come from.** No parameter asks for them: the plugin 
hands each source root and resource directory to the archiver as a file set, 
and plexus-io turns every directory that the scan selects into a resource, even 
one without files. An empty `target/generated-sources/annotations` below one of 
them becomes three directory entries, which is exactly the difference in 
Reproducible Central's diffoscope for the sources jar of avaje-http-client 
3.4-RC3. Git does not track empty directories, so such a jar cannot be rebuilt 
byte for byte from a clean checkout.
   
   The closest thing to a reason in the history is MSOURCES-95 (6e715b1): the 
default includes became `**/**` so that the archiver has the base directory of 
a file set to compare the jar with. Its commit message says that this is not 
meant to change what is archived. This change keeps the comparison, and nothing 
in the tests, ITs or documentation asks for entries of directories without 
files.
   
   **Change.** A directory is archived only together with a file in or below 
it. The new `EmptyDirectories` scans each file set first and gives it a 
plexus-io `FileSelector` that lets through files, symbolic links that are not 
followed, and the directories that hold them. Those directories and the base 
directory stay resources of the file set, so their entries keep mode and time 
and the archiver still notices a deleted file. A directory that lost its last 
file is no longer a resource, so the mojo keeps the time of the newest 
directory it left out and forces creation when that is newer than the existing 
jar.
   
   `DefaultFileSet.includeEmptyDirs(false)` removes the entries too, but it 
takes every directory out of the file set, the base directory included. The 
archiver then no longer notices a deleted file, and it writes the jar again in 
every build for a file set without files, which is what the IT `MSOURCES-95` 
checks.
   
   **What changes for users**
   
   - There is no parameter to get the entries back. The rule is wider than 
"empty on disk": a directory whose files are all excluded, or a followed link 
to an empty directory, loses its entry too.
   - A file set that selects only directories below its base directory, and no 
file, is not added (`drafts/**` over an empty `drafts`). A project with nothing 
else to archive no longer gets a sources jar. With the default includes, a 
source root without files still gives one.
   - Where two file sets give the same directory path (two roots, or two 
resources over one directory) and the first selects no file there, the entry 
now comes from the other one, or from the archiver as the parent of a file. Its 
position, mode and time can differ from master, even where no directory is 
empty. File entries do not change, except that a file is no longer skipped when 
a directory without files of the same name comes first.
   - With `project.build.outputTimestamp`, creating or removing a directory 
without files no longer changes the content of the jar but still makes it look 
outdated. Every build then generates the archive again, without rewriting the 
file, until the content changes or the jar is deleted. master does the same 
after `touch` on a source file.
   - Each file set is scanned once more: about 0.35 s per run for 20,000 files 
in 2,000 directories here.
   
   `plexus-io` 3.8.1, which plexus-archiver 4.16.0 brings, is now declared, 
because `dependency:analyze-only` fails the build otherwise. The `includes` 
parameter and a new FAQ entry describe the rule as "since 3.5.0". 
`maven-source-plugin-4.x` adds its file sets the same way and is not changed 
here.
   
   **Tests.** With the main code of master, 8 of the 16 tests of the new 
`EmptyDirectoriesTest` fail on an unwanted directory entry (the other 8 guard 
what must stay), and so do the ITs `MSOURCES-95` and `reproducible` (by its 
pinned checksums), which now get empty directories from a `setup.groovy`. One 
more test covers `forceCreation` for an up-to-date jar, because the call is now 
`archive.setForced(forceCreation || outdated)`.
   
   Verified: `mvn -Prun-its verify` → 39 unit tests, 18 ITs, BUILD SUCCESS on 
JDK 17, 21, 25 and 26 (Maven 3.9.16, macOS). Not run on Linux, Windows, JDK 8 
or Maven 4, and the site was not built.
   
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [ ] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to