Repository navigation
Fix #239: leave directories without files out of the sources jar - #380
Open
janbalangue wants to merge 1 commit into
Open
janbalangue wants to merge 1 commit into
janbalangue wants to merge 1 commit into
Conversation
Member
|
Thanks for the thorough analysis and tests. Most of the complexity here (the second scan, the custom |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/annotationsbelow 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
EmptyDirectoriesscans each file set first and gives it a plexus-ioFileSelectorthat 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 ITMSOURCES-95checks.What changes for users
drafts/**over an emptydrafts). 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.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 aftertouchon a source file.plexus-io3.8.1, which plexus-archiver 4.16.0 brings, is now declared, becausedependency:analyze-onlyfails the build otherwise. Theincludesparameter and a new FAQ entry describe the rule as "since 3.5.0".maven-source-plugin-4.xadds 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
EmptyDirectoriesTestfail on an unwanted directory entry (the other 8 guard what must stay), and so do the ITsMSOURCES-95andreproducible(by its pinned checksums), which now get empty directories from asetup.groovy. One more test coversforceCreationfor an up-to-date jar, because the call is nowarchive.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
check one of the following: