-
Notifications
You must be signed in to change notification settings - Fork 49
Handling empty archives #52
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
Comments
I want to add one somewhat related question. Should the clients of If the answer is 'yes', then the current implementation should be changed. |
This one is fixed with #51 so I'll close it. @michael-o as far I can remember you had some ideas about the creation of empty archives. Would you please add another issue with them as I'm afraid otherwise we'll forgot them. |
There is an issue for the Maven Assembly Plugin (MASSEMBLY-833) asking for a way to skip the creation of empty archives, instead of failing.
This is a use-case that cannot really be solved at the plugin level: it is possible to check if any resources are present with
archiver.getResources().hasNext()
, but this doesn't tackle the possible finalizers adding real or virtual files to the archive when it is created. Archiver can add themselves finalizers, which the plugin is then unaware of. For example, theDotDirectiveArchiveFinalizer
is added at the moment an attempt is made to create the archive.If support for handling empty archives should be added, there seem to be 2 possible solutions:
isEmpty()
on theArchiver
interface.With regard to 1. I don't see an easier way to determine whether an archive is going to be empty or not than the following: check whether there are any added resources, then check whether any finalizer adds virtual files, and finally run all the finalizers on a mock archiver to determine whether or not they would add any real files to the archive (since we don't know in advance if they would, and the archiver doesn't know what the finalizer does). Note that since a method is added on the interface, this would probably require a major version update.
With regard to 2. This isn't specified in the documentation (there is no Javadoc), and currently, all of the built-in archivers, except
DirectoryArchiver
, are raising an exception in this case, although it is not consistent: for exampleAbstractZipArchiver
andTarArchiver
throw anArchiverException
in case of an empty archive, butGZipArchiver
andSnappyArchiver
throw aNoSuchElementException
.First of all, would such an addition be welcomed for Plexus Archiver? And if so, what would be the most appropriate choice here? Solution 1 is preferable: it gives a direct and simple way to check for content and it would allow Plexus Archiver to be able to create empty archives in the future if there's a need for it (the current exceptions could be configurable, and left for the caller to decide what to do in this case). But if it doesn't make sense to try to create empty archive, solution 2 would be simpler.
As far as the Maven Assembly Plugin is concerned, there is no need to create empty archives (no demand for that use-case) and it would most likely represent an error in the configuration; but other projects could have the need for this.
The text was updated successfully, but these errors were encountered: