├── src
├── test
│ ├── resources
│ │ ├── group-writable
│ │ │ ├── bar.txt
│ │ │ └── foo.txt
│ │ ├── world-writable
│ │ │ └── foo.txt
│ │ ├── symlinks
│ │ │ ├── src
│ │ │ │ ├── symDir
│ │ │ │ ├── symR
│ │ │ │ ├── symW
│ │ │ │ ├── symX
│ │ │ │ ├── fileW.txt
│ │ │ │ ├── fileX.txt
│ │ │ │ ├── aDirWithALink
│ │ │ │ │ └── backOutsideToFileX
│ │ │ │ ├── symLinkToDirOnTheOutside
│ │ │ │ ├── symLinkToFileOnTheOutside
│ │ │ │ ├── fileR.txt
│ │ │ │ ├── targetDir
│ │ │ │ │ └── targetFile.txt
│ │ │ │ └── aRegularDir
│ │ │ │ │ └── aRegularFile.txt
│ │ │ ├── onTheOutside.txt
│ │ │ ├── dirOnTheOutside
│ │ │ │ └── FileInDirOnTheOutside.txt
│ │ │ ├── symlinks.tar
│ │ │ ├── symlinks.zip
│ │ │ ├── non_existing_symlink.zip
│ │ │ └── regen.sh
│ │ ├── folders
│ │ │ ├── File.txt
│ │ │ ├── WEB-INF
│ │ │ │ └── web.xml
│ │ │ ├── a
│ │ │ │ └── FileInA.txt
│ │ │ └── b
│ │ │ │ └── FileInB.txt
│ │ ├── mjar179
│ │ │ ├── Messages_en.properties
│ │ │ ├── Messages.properties
│ │ │ └── Messages_fr.properties
│ │ ├── zip-timestamp
│ │ │ ├── file-with-even-time.txt
│ │ │ ├── file-with-odd-time.txt
│ │ │ ├── foo
│ │ │ │ ├── file-with-even-time.txt
│ │ │ │ ├── file-with-odd-time.txt
│ │ │ │ ├── macOsZipFile.jar
│ │ │ │ └── plexus-archiver-2.4.4-SNAPSHOT.jar
│ │ │ └── macOsZipFile.zip
│ │ ├── manifests
│ │ │ ├── manifest1.mf
│ │ │ ├── manifest4.mf
│ │ │ ├── manifest6.mf
│ │ │ ├── manifest2.mf
│ │ │ ├── manifest5.mf
│ │ │ ├── manifest3.mf
│ │ │ ├── manifestMerge2.mf
│ │ │ ├── manifestMerge1.mf
│ │ │ ├── manifestWithDualClassPath.mf
│ │ │ └── manifestWithClassPath.mf
│ │ ├── miscUtf8
│ │ │ ├── aFileWithA#.html
│ │ │ ├── aPiñata.txt
│ │ │ ├── €uro.txt
│ │ │ └── anümlaut.txt
│ │ ├── java-classes
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ ├── resources
│ │ │ │ └── test.properties
│ │ │ │ └── app
│ │ │ │ └── Main.class
│ │ ├── jar-security
│ │ │ └── dummy.txt
│ │ ├── java-src
│ │ │ ├── module-info.java
│ │ │ ├── REAMDE.md
│ │ │ └── com
│ │ │ │ └── example
│ │ │ │ └── app
│ │ │ │ └── Main.java
│ │ ├── test.zip
│ │ ├── unpack_issue.jar
│ │ ├── bogusManifest.zip
│ │ ├── utf8
│ │ │ ├── D12345679012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890æøå.txt
│ │ │ └── D12345679012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890æøå.txt
│ │ ├── zeroFileMode
│ │ │ ├── foobar.zip
│ │ │ └── mixed-file-mode.zip
│ │ ├── unicodePathExtra
│ │ │ ├── efsclear.zip
│ │ │ ├── efsset.zip
│ │ │ ├── README.md
│ │ │ └── GenerateZips.java
│ │ ├── archiveWithIllegalHtmlFileName.zip
│ │ └── java-module-descriptor
│ │ │ └── module-info.class
│ ├── dotfiles
│ │ ├── .plxarc
│ │ └── licenses
│ │ │ └── NOTICE.txt
│ ├── jars
│ │ ├── test.jar
│ │ ├── test.rar
│ │ ├── test.zip
│ │ ├── test.tar.gz
│ │ └── namelessrootfolder.jar
│ ├── zips
│ │ └── zip-slip.zip
│ └── java
│ │ └── org
│ │ └── codehaus
│ │ └── plexus
│ │ └── archiver
│ │ ├── TestSupport.java
│ │ ├── util
│ │ ├── DefaultFileSetTest.java
│ │ ├── ArchiveEntryUtilsTest.java
│ │ ├── ResourceUtilsTest.java
│ │ └── FilePermissionUtilsTest.java
│ │ ├── zip
│ │ ├── OffloadingOutputStreamTest.java
│ │ └── PlexusArchiverZipFileResourceCollectionTest.java
│ │ ├── sar
│ │ └── SarArchiverTest.java
│ │ ├── DotDirectiveArchiveFinalizerTest.java
│ │ ├── tar
│ │ ├── TarRoundTripTest.java
│ │ └── TarUnArchiverTest.java
│ │ ├── AbstractArchiverTest.java
│ │ └── war
│ │ └── WarArchiverTest.java
├── main
│ └── java
│ │ └── org
│ │ └── codehaus
│ │ └── plexus
│ │ ├── archiver
│ │ ├── ResourceIterator.java
│ │ ├── FinalizerEnabled.java
│ │ ├── gzip
│ │ │ ├── PlexusIoGzResourceCollection.java
│ │ │ ├── PlexusIoGzipResourceCollection.java
│ │ │ ├── GZipCompressor.java
│ │ │ ├── GZipArchiver.java
│ │ │ └── GZipUnArchiver.java
│ │ ├── bzip2
│ │ │ ├── PlexusIoBz2ResourceCollection.java
│ │ │ ├── PlexusIoBzip2ResourceCollection.java
│ │ │ ├── BZip2Compressor.java
│ │ │ └── BZip2Archiver.java
│ │ ├── tar
│ │ │ ├── PlexusIoTGZFileResourceCollection.java
│ │ │ ├── PlexusIoTBZ2FileResourceCollection.java
│ │ │ ├── PlexusIoTarGZipFileResourceCollection.java
│ │ │ ├── PlexusIoTarBZip2FileResourceCollection.java
│ │ │ ├── PlexusIoTarSnappyFileResourceCollection.java
│ │ │ ├── BZip2TarFile.java
│ │ │ ├── SnappyTarFile.java
│ │ │ ├── GZipTarFile.java
│ │ │ ├── TXZUnArchiver.java
│ │ │ ├── TXZArchiver.java
│ │ │ ├── TGZUnArchiver.java
│ │ │ ├── TBZ2UnArchiver.java
│ │ │ ├── TZstdArchiver.java
│ │ │ ├── TZstdUnArchiver.java
│ │ │ ├── TGZArchiver.java
│ │ │ ├── TBZ2Archiver.java
│ │ │ ├── PlexusIoTXZFileResourceCollection.java
│ │ │ ├── PlexusIoTZstdFileResourceCollection.java
│ │ │ ├── TarXZArchiver.java
│ │ │ ├── TarZstdArchiver.java
│ │ │ ├── TarGZipArchiver.java
│ │ │ ├── TarBZip2Archiver.java
│ │ │ ├── TarSnappyArchiver.java
│ │ │ ├── PlexusIoTarXZFileResourceCollection.java
│ │ │ ├── PlexusIoTarZstdFileResourceCollection.java
│ │ │ ├── XZTarFile.java
│ │ │ ├── TarXZUnArchiver.java
│ │ │ ├── TarZstdUnArchiver.java
│ │ │ ├── ZstdTarFile.java
│ │ │ ├── TarSnappyUnArchiver.java
│ │ │ ├── TarGZipUnArchiver.java
│ │ │ ├── TarBZip2UnArchiver.java
│ │ │ ├── TarSymlinkResource.java
│ │ │ ├── TarLongFileMode.java
│ │ │ ├── TarResource.java
│ │ │ └── PlexusIoTarFileResourceCollection.java
│ │ ├── ArchiveFilterException.java
│ │ ├── ArchiveFileFilter.java
│ │ ├── FileSet.java
│ │ ├── AbstractArchiveFinalizer.java
│ │ ├── ArchivedFileSet.java
│ │ ├── ArchiveFinalizer.java
│ │ ├── filters
│ │ │ ├── JarSecurityFileFilter.java
│ │ │ └── JarSecurityFileSelector.java
│ │ ├── zip
│ │ │ ├── ZipArchiver.java
│ │ │ ├── ZipUnArchiver.java
│ │ │ ├── AnonymousResource.java
│ │ │ ├── PlexusIoZipFileResourceCollection.java
│ │ │ ├── ZipSymlinkResource.java
│ │ │ ├── DeferredScatterOutputStream.java
│ │ │ ├── PlexusArchiverZipFileResourceCollection.java
│ │ │ └── AddedDirs.java
│ │ ├── ArchiveFile.java
│ │ ├── util
│ │ │ ├── DefaultArchivedFileSet.java
│ │ │ ├── DefaultFileSet.java
│ │ │ ├── FilterSupport.java
│ │ │ ├── ArchiveEntryUtils.java
│ │ │ └── FilePermission.java
│ │ ├── rar
│ │ │ ├── RarArchiver.java
│ │ │ ├── PlexusIoRarFileResourceCollection.java
│ │ │ └── RarUnArchiver.java
│ │ ├── ArchiverException.java
│ │ ├── car
│ │ │ ├── PlexusIoCarFileResourceCollection.java
│ │ │ └── CarUnArchiver.java
│ │ ├── ear
│ │ │ ├── PlexusIoEarFileResourceCollection.java
│ │ │ └── EarUnArchiver.java
│ │ ├── esb
│ │ │ ├── PlexusIoEsbFileResourceCollection.java
│ │ │ └── EsbUnArchiver.java
│ │ ├── nar
│ │ │ ├── PlexusIoNarFileResourceCollection.java
│ │ │ └── NarUnArchiver.java
│ │ ├── par
│ │ │ ├── PlexusIoJarFileResourceCollection.java
│ │ │ └── ParUnArchiver.java
│ │ ├── sar
│ │ │ ├── PlexusIoSarFileResourceCollection.java
│ │ │ └── SarUnArchiver.java
│ │ ├── swc
│ │ │ ├── PlexusIoSwcFileResourceCollection.java
│ │ │ └── SwcUnArchiver.java
│ │ ├── war
│ │ │ ├── PlexusIoWarFileResourceCollection.java
│ │ │ └── WarUnArchiver.java
│ │ ├── exceptions
│ │ │ └── EmptyArchiveException.java
│ │ ├── jar
│ │ │ ├── PlexusIoJarFileResourceCollection.java
│ │ │ ├── JarUnArchiver.java
│ │ │ ├── ManifestException.java
│ │ │ └── ManifestConstants.java
│ │ ├── manager
│ │ │ ├── NoSuchArchiverException.java
│ │ │ └── ArchiverManager.java
│ │ ├── snappy
│ │ │ ├── PlexusIoSnappyResourceCollection.java
│ │ │ ├── SnappyCompressor.java
│ │ │ ├── SnappyArchiver.java
│ │ │ └── SnappyUnArchiver.java
│ │ ├── xz
│ │ │ ├── PlexusIoXZResourceCollection.java
│ │ │ ├── XZCompressor.java
│ │ │ ├── XZArchiver.java
│ │ │ └── XZUnArchiver.java
│ │ ├── resources
│ │ │ └── PlexusIoVirtualSymlinkResource.java
│ │ ├── zstd
│ │ │ ├── PlexusIoZstdResourceCollection.java
│ │ │ ├── ZstdArchiver.java
│ │ │ ├── ZstdCompressor.java
│ │ │ └── ZstdUnArchiver.java
│ │ ├── BaseFileSet.java
│ │ ├── UnixStat.java
│ │ └── DotDirectiveArchiveFinalizer.java
│ │ └── components
│ │ └── io
│ │ └── resources
│ │ └── PlexusIoZipFileResourceCollection.java
└── site
│ └── site.xml
├── .git-blame-ignore-revs
├── .github
├── release-drafter.yml
├── dependabot.yml
└── workflows
│ ├── release-drafter.yml
│ └── maven.yml
├── .gitignore
├── .gitattributes
└── README.md
/src/test/resources/group-writable/bar.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/group-writable/foo.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/world-writable/foo.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/symDir:
--------------------------------------------------------------------------------
1 | targetDir/
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/symR:
--------------------------------------------------------------------------------
1 | fileR.txt
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/symW:
--------------------------------------------------------------------------------
1 | fileW.txt
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/symX:
--------------------------------------------------------------------------------
1 | fileX.txt
--------------------------------------------------------------------------------
/src/test/resources/folders/File.txt:
--------------------------------------------------------------------------------
1 | A file in root
--------------------------------------------------------------------------------
/src/test/resources/folders/WEB-INF/web.xml:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/folders/a/FileInA.txt:
--------------------------------------------------------------------------------
1 | A file in A
--------------------------------------------------------------------------------
/src/test/resources/folders/b/FileInB.txt:
--------------------------------------------------------------------------------
1 | A file in B
--------------------------------------------------------------------------------
/src/test/resources/mjar179/Messages_en.properties:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/fileW.txt:
--------------------------------------------------------------------------------
1 | all w
2 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/fileX.txt:
--------------------------------------------------------------------------------
1 | xxx
2 |
--------------------------------------------------------------------------------
/src/test/resources/zip-timestamp/file-with-even-time.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/zip-timestamp/file-with-odd-time.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/zip-timestamp/foo/file-with-even-time.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/zip-timestamp/foo/file-with-odd-time.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/dotfiles/.plxarc:
--------------------------------------------------------------------------------
1 | licenses
2 | licenses:META-INF/maven
3 |
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifest1.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 |
3 |
--------------------------------------------------------------------------------
/src/test/resources/miscUtf8/aFileWithA#.html:
--------------------------------------------------------------------------------
1 | A file with a hash
2 |
3 |
--------------------------------------------------------------------------------
/src/test/resources/miscUtf8/aPiñata.txt:
--------------------------------------------------------------------------------
1 | This is a second party trick
2 |
--------------------------------------------------------------------------------
/src/test/resources/miscUtf8/€uro.txt:
--------------------------------------------------------------------------------
1 | You need more €uros for that
2 |
--------------------------------------------------------------------------------
/src/test/resources/mjar179/Messages.properties:
--------------------------------------------------------------------------------
1 | messageKey=Hello world !
--------------------------------------------------------------------------------
/src/test/resources/mjar179/Messages_fr.properties:
--------------------------------------------------------------------------------
1 | messageKey=Bonjour le monde !
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/aDirWithALink/backOutsideToFileX:
--------------------------------------------------------------------------------
1 | ../fileX.txt
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/symLinkToDirOnTheOutside:
--------------------------------------------------------------------------------
1 | ../dirOnTheOutside/
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/symLinkToFileOnTheOutside:
--------------------------------------------------------------------------------
1 | ../onTheOutside.txt
--------------------------------------------------------------------------------
/src/test/resources/java-classes/com/example/resources/test.properties:
--------------------------------------------------------------------------------
1 | ley=value
2 |
--------------------------------------------------------------------------------
/src/test/resources/miscUtf8/anümlaut.txt:
--------------------------------------------------------------------------------
1 | This is a file wiht an uülmaut, again
2 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/onTheOutside.txt:
--------------------------------------------------------------------------------
1 | I am on the outside of the src
2 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/fileR.txt:
--------------------------------------------------------------------------------
1 | This file is a source. r r r filemode
2 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/targetDir/targetFile.txt:
--------------------------------------------------------------------------------
1 | This is a target file
2 |
--------------------------------------------------------------------------------
/.git-blame-ignore-revs:
--------------------------------------------------------------------------------
1 | # Change code style
2 | 13b602af7169a8e49d47edf59f4154e1b834c0d8
3 |
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifest4.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Name: test5
3 |
4 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/src/aRegularDir/aRegularFile.txt:
--------------------------------------------------------------------------------
1 | I am just an ordinary file
2 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/dirOnTheOutside/FileInDirOnTheOutside.txt:
--------------------------------------------------------------------------------
1 | I am on the outside...
2 |
--------------------------------------------------------------------------------
/.github/release-drafter.yml:
--------------------------------------------------------------------------------
1 | _extends: .github
2 | tag-template: plexus-archiver-$NEXT_MINOR_VERSION
3 |
--------------------------------------------------------------------------------
/src/test/jars/test.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/jars/test.jar
--------------------------------------------------------------------------------
/src/test/jars/test.rar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/jars/test.rar
--------------------------------------------------------------------------------
/src/test/jars/test.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/jars/test.zip
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifest6.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path: fubar
3 | From: Jack
4 |
5 |
--------------------------------------------------------------------------------
/src/test/jars/test.tar.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/jars/test.tar.gz
--------------------------------------------------------------------------------
/src/test/resources/jar-security/dummy.txt:
--------------------------------------------------------------------------------
1 | This file is used as fake content for the security file filtering tests.
2 |
--------------------------------------------------------------------------------
/src/test/resources/java-src/module-info.java:
--------------------------------------------------------------------------------
1 | module com.example.app
2 | {
3 | exports com.example.app;
4 | }
5 |
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifest2.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Header-without-colon maybe mistyped
3 |
4 |
5 |
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifest5.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 |
3 | Test: test6
4 | Class-Path: fubar
5 |
6 |
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifest3.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 |
3 | Can't start with a continuation line
4 |
5 |
--------------------------------------------------------------------------------
/src/test/resources/test.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/test.zip
--------------------------------------------------------------------------------
/src/test/zips/zip-slip.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/zips/zip-slip.zip
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifestMerge2.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | From: Jack
3 | Bar: 001
4 |
5 | Name: Fudz
6 | Bar: 003
7 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | target/
2 | .project
3 | .classpath
4 | .settings/
5 | bin
6 | *.ipr
7 | *.iml
8 | *.iws
9 | .idea
10 | .DS_Store
11 |
--------------------------------------------------------------------------------
/src/test/resources/unpack_issue.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/unpack_issue.jar
--------------------------------------------------------------------------------
/src/test/jars/namelessrootfolder.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/jars/namelessrootfolder.jar
--------------------------------------------------------------------------------
/src/test/resources/bogusManifest.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/bogusManifest.zip
--------------------------------------------------------------------------------
/src/test/dotfiles/licenses/NOTICE.txt:
--------------------------------------------------------------------------------
1 | This product includes software developed by
2 | The Apache Software Foundation (http://www.apache.org/).
3 |
--------------------------------------------------------------------------------
/src/test/resources/java-src/REAMDE.md:
--------------------------------------------------------------------------------
1 | This is the source code for the Java classes
2 | inside `java-classes` and `java-module` directories.
3 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/symlinks.tar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/symlinks/symlinks.tar
--------------------------------------------------------------------------------
/src/test/resources/symlinks/symlinks.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/symlinks/symlinks.zip
--------------------------------------------------------------------------------
/src/test/resources/utf8/D12345679012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890æøå.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/utf8/D12345679012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890æøå.txt:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/test/resources/zeroFileMode/foobar.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/zeroFileMode/foobar.zip
--------------------------------------------------------------------------------
/src/test/resources/unicodePathExtra/efsclear.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/unicodePathExtra/efsclear.zip
--------------------------------------------------------------------------------
/src/test/resources/unicodePathExtra/efsset.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/unicodePathExtra/efsset.zip
--------------------------------------------------------------------------------
/src/test/resources/zip-timestamp/macOsZipFile.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/zip-timestamp/macOsZipFile.zip
--------------------------------------------------------------------------------
/src/test/resources/archiveWithIllegalHtmlFileName.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/archiveWithIllegalHtmlFileName.zip
--------------------------------------------------------------------------------
/src/test/resources/symlinks/non_existing_symlink.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/symlinks/non_existing_symlink.zip
--------------------------------------------------------------------------------
/src/test/resources/zeroFileMode/mixed-file-mode.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/zeroFileMode/mixed-file-mode.zip
--------------------------------------------------------------------------------
/src/test/resources/zip-timestamp/foo/macOsZipFile.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/zip-timestamp/foo/macOsZipFile.jar
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifestMerge1.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | From: Jack
3 | Bar: 001
4 |
5 | Name: Fudz
6 | Bar: 002
7 |
8 | Name: Redz
9 | Baz: 002
10 |
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifestWithDualClassPath.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path: ../config/
3 | classes12.jar
4 | From: Jack
5 | Ape: Fud
6 | Class-Path: baz
7 |
--------------------------------------------------------------------------------
/src/test/resources/java-classes/com/example/app/Main.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/java-classes/com/example/app/Main.class
--------------------------------------------------------------------------------
/src/test/resources/java-module-descriptor/module-info.class:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/java-module-descriptor/module-info.class
--------------------------------------------------------------------------------
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
4 | *.java text diff=java
5 | *.html text diff=html
6 | *.css text
7 | *.js text
8 | *.sql text
9 |
--------------------------------------------------------------------------------
/src/test/resources/zip-timestamp/foo/plexus-archiver-2.4.4-SNAPSHOT.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/codehaus-plexus/plexus-archiver/HEAD/src/test/resources/zip-timestamp/foo/plexus-archiver-2.4.4-SNAPSHOT.jar
--------------------------------------------------------------------------------
/src/test/resources/java-src/com/example/app/Main.java:
--------------------------------------------------------------------------------
1 | package com.example.app;
2 |
3 | public class Main
4 | {
5 |
6 | public static void main( String[] args )
7 | {
8 | System.out.println( "Hello from Main" );
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "maven"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 | - package-ecosystem: "github-actions"
8 | directory: "/"
9 | schedule:
10 | interval: "daily"
11 |
--------------------------------------------------------------------------------
/.github/workflows/release-drafter.yml:
--------------------------------------------------------------------------------
1 | name: Release Drafter
2 | on:
3 | push:
4 | branches:
5 | - master
6 | jobs:
7 | update_release_draft:
8 | runs-on: ubuntu-latest
9 | steps:
10 | - uses: release-drafter/release-drafter@v6
11 | env:
12 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
13 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/ResourceIterator.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.util.Iterator;
4 |
5 | public interface ResourceIterator extends Iterator {
6 |
7 | @Override
8 | boolean hasNext();
9 |
10 | @Override
11 | ArchiveEntry next();
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/FinalizerEnabled.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.util.List;
4 |
5 | public interface FinalizerEnabled {
6 |
7 | void addArchiveFinalizer(ArchiveFinalizer finalizer);
8 |
9 | void setArchiveFinalizers(List archiveFinalizers);
10 | }
11 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/gzip/PlexusIoGzResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.gzip;
2 |
3 | import javax.inject.Named;
4 |
5 | /**
6 | * Alias for {@link PlexusIoGzipResourceCollection}
7 | */
8 | @Named("gz")
9 | public class PlexusIoGzResourceCollection extends PlexusIoGzipResourceCollection {}
10 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/bzip2/PlexusIoBz2ResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.bzip2;
2 |
3 | import javax.inject.Named;
4 |
5 | /**
6 | * Alias of {@link PlexusIoBzip2ResourceCollection}.
7 | */
8 | @Named("bz2")
9 | public class PlexusIoBz2ResourceCollection extends PlexusIoBzip2ResourceCollection {}
10 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTGZFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import javax.inject.Named;
4 |
5 | /**
6 | * Alias for {@link PlexusIoTarGZipFileResourceCollection}
7 | */
8 | @Named("tgz")
9 | public class PlexusIoTGZFileResourceCollection extends PlexusIoTarGZipFileResourceCollection {}
10 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTBZ2FileResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import javax.inject.Named;
4 |
5 | /**
6 | * Alias for {@link PlexusIoTarBZip2FileResourceCollection}
7 | */
8 | @Named("tbz2")
9 | public class PlexusIoTBZ2FileResourceCollection extends PlexusIoTarBZip2FileResourceCollection {}
10 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/ArchiveFilterException.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | public class ArchiveFilterException extends Exception {
4 |
5 | public ArchiveFilterException(String message, Throwable cause) {
6 | super(message, cause);
7 | }
8 |
9 | public ArchiveFilterException(String message) {
10 | super(message);
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/ArchiveFileFilter.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.io.InputStream;
4 |
5 | import org.codehaus.plexus.components.io.fileselectors.FileSelector;
6 |
7 | /**
8 | * @deprecated Use {@link FileSelector}
9 | */
10 | @Deprecated
11 | public interface ArchiveFileFilter {
12 |
13 | boolean include(InputStream dataStream, String entryName);
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/FileSet.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.io.File;
4 |
5 | /**
6 | * A file set, which consists of the files and directories in
7 | * a common base directory.
8 | *
9 | * @since 1.0-alpha-9
10 | */
11 | public interface FileSet extends BaseFileSet {
12 |
13 | /**
14 | * Returns the file sets base directory.
15 | */
16 | File getDirectory();
17 | }
18 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTarGZipFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import javax.inject.Named;
4 |
5 | import java.io.File;
6 |
7 | @Named("tar.gz")
8 | public class PlexusIoTarGZipFileResourceCollection extends PlexusIoTarFileResourceCollection {
9 |
10 | @Override
11 | protected TarFile newTarFile(File file) {
12 | return new GZipTarFile(file);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTarBZip2FileResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import javax.inject.Named;
4 |
5 | import java.io.File;
6 |
7 | @Named("tar.bz2")
8 | public class PlexusIoTarBZip2FileResourceCollection extends PlexusIoTarFileResourceCollection {
9 |
10 | @Override
11 | protected TarFile newTarFile(File file) {
12 | return new BZip2TarFile(file);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTarSnappyFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import javax.inject.Named;
4 |
5 | import java.io.File;
6 |
7 | @Named("tar.snappy")
8 | public class PlexusIoTarSnappyFileResourceCollection extends PlexusIoTarFileResourceCollection {
9 |
10 | @Override
11 | protected TarFile newTarFile(File file) {
12 | return new SnappyTarFile(file);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/AbstractArchiveFinalizer.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | public abstract class AbstractArchiveFinalizer implements ArchiveFinalizer {
4 |
5 | protected AbstractArchiveFinalizer() {}
6 |
7 | @Override
8 | public void finalizeArchiveCreation(Archiver archiver) throws ArchiverException {}
9 |
10 | @Override
11 | public void finalizeArchiveExtraction(UnArchiver unarchiver) throws ArchiverException {}
12 | }
13 |
--------------------------------------------------------------------------------
/src/site/site.xml:
--------------------------------------------------------------------------------
1 |
3 |
4 |
5 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/ArchivedFileSet.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import javax.annotation.CheckForNull;
4 |
5 | import java.io.File;
6 |
7 | /**
8 | * A file set, which consists of the files and directories in
9 | * an archive.
10 | *
11 | * @since 1.0-alpha-9
12 | */
13 | public interface ArchivedFileSet extends BaseFileSet {
14 |
15 | /**
16 | * Returns the archive file.
17 | */
18 | @CheckForNull
19 | File getArchive();
20 | }
21 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/ArchiveFinalizer.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.util.List;
4 |
5 | /**
6 | * An archive finalizer is just before archive creation (after user has added all files),
7 | * allowing the finalizer to do stuff like create manifests etc.
8 | */
9 | public interface ArchiveFinalizer {
10 |
11 | void finalizeArchiveCreation(Archiver archiver) throws ArchiverException;
12 |
13 | void finalizeArchiveExtraction(UnArchiver unarchiver) throws ArchiverException;
14 |
15 | List getVirtualFiles();
16 | }
17 |
--------------------------------------------------------------------------------
/src/test/resources/manifests/manifestWithClassPath.mf:
--------------------------------------------------------------------------------
1 | Manifest-Version: 1.0
2 | Class-Path: ../config/
3 | classes12.jar
4 | bc4jct.jar
5 | bc4jdomorcl.jar
6 | bc4jmt.jar
7 | commons-beanutils-bean-collections.jar
8 | commons-beanutils-core.jar
9 | commons-beanutils.jar
10 | commons-codec-1.3.jar
11 | commons-collections-3.1.jar
12 | commons-configuration-1.2.jar
13 | commons-digester.jar
14 | commons-lang-2.0.jar
15 | commons-logging.jar
16 | htbclnt.jar
17 | areallylongjarfilethatisnotentirelyrealbutstillaverylongname.jar
18 | j2ee/home/oc4jclient.jar
19 | From: Jack
20 |
--------------------------------------------------------------------------------
/src/test/resources/symlinks/regen.sh:
--------------------------------------------------------------------------------
1 | rm symlinks.zip
2 | rm symlinks.tar
3 | cd src
4 | zip --symlinks ../symlinks.zip file* targetDir sym*
5 | tar -cvf ../symlinks.tar file* targetDir sym*
6 |
7 | cd ..
8 | rm non_existing_symlink.zip
9 | mkdir non_existing_symlink
10 | cd non_existing_symlink
11 | ln -s /tmp/target entry1
12 | echo -ne 'content' > entry2
13 | zip --symlinks ../non_existing_symlink.zip entry1 entry2
14 | cd ..
15 | rm -rf non_existing_symlink
16 | if [ "x$(uname)" = "xLinux" ];then
17 | LC_ALL=C sed -i 's/entry2/entry1/' non_existing_symlink.zip
18 | else
19 | LC_ALL=C sed -i '' 's/entry2/entry1/' non_existing_symlink.zip
20 | fi
21 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/BZip2TarFile.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 |
7 | import org.codehaus.plexus.archiver.bzip2.BZip2UnArchiver;
8 |
9 | /**
10 | * Extension of {@link TarFile} for bzip2 compressed files.
11 | */
12 | public class BZip2TarFile extends TarFile {
13 |
14 | /**
15 | * Creates a new instance with the given file.
16 | */
17 | public BZip2TarFile(File file) {
18 | super(file);
19 | }
20 |
21 | @Override
22 | protected InputStream getInputStream(File file) throws IOException {
23 | return BZip2UnArchiver.getBZip2InputStream(super.getInputStream(file));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/SnappyTarFile.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 |
7 | import org.codehaus.plexus.archiver.snappy.SnappyUnArchiver;
8 |
9 | /**
10 | * Extension of {@link org.codehaus.plexus.archiver.tar.TarFile} for snappy compressed files.
11 | */
12 | public class SnappyTarFile extends TarFile {
13 |
14 | /**
15 | * Creates a new instance with the given file.
16 | */
17 | public SnappyTarFile(File file) {
18 | super(file);
19 | }
20 |
21 | @Override
22 | protected InputStream getInputStream(File file) throws IOException {
23 | return SnappyUnArchiver.getSnappyInputStream(super.getInputStream(file));
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/GZipTarFile.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.io.InputStream;
6 | import java.util.zip.GZIPInputStream;
7 |
8 | import org.codehaus.plexus.archiver.util.Streams;
9 |
10 | /**
11 | * Extension of {@link TarFile} for gzip compressed files.
12 | */
13 | public class GZipTarFile extends TarFile {
14 |
15 | /**
16 | * Creates a new instance with the given file.
17 | */
18 | public GZipTarFile(File file) {
19 | super(file);
20 | }
21 |
22 | @Override
23 | protected InputStream getInputStream(File file) throws IOException {
24 | return Streams.bufferedInputStream(new GZIPInputStream(super.getInputStream(file)));
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/filters/JarSecurityFileFilter.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.filters;
2 |
3 | import java.io.InputStream;
4 |
5 | import org.codehaus.plexus.archiver.ArchiveFileFilter;
6 | import org.codehaus.plexus.util.SelectorUtils;
7 |
8 | /**
9 | * @deprecated Use {@link JarSecurityFileSelector}
10 | */
11 | @Deprecated
12 | public class JarSecurityFileFilter implements ArchiveFileFilter {
13 |
14 | public static final String[] SECURITY_FILE_PATTERNS = JarSecurityFileSelector.SECURITY_FILE_PATTERNS;
15 |
16 | @Override
17 | public boolean include(InputStream dataStream, String entryName) {
18 | for (String pattern : SECURITY_FILE_PATTERNS) {
19 | if (SelectorUtils.match(pattern, entryName)) {
20 | return false;
21 | }
22 | }
23 |
24 | return true;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zip/ZipArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.zip;
18 |
19 | import javax.inject.Named;
20 |
21 | @Named("zip")
22 | public class ZipArchiver extends AbstractZipArchiver {}
23 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/ArchiveFile.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.io.IOException;
4 | import java.io.InputStream;
5 | import java.util.Enumeration;
6 |
7 | /**
8 | * Interface of a zip, or tar file.
9 | */
10 | public interface ArchiveFile {
11 |
12 | /**
13 | * Returns an enumeration with the archive files entries.
14 | * Any element returned by the enumeration is an instance
15 | * of {@link org.apache.commons.compress.archivers.ArchiveEntry}.
16 | */
17 | Enumeration extends org.apache.commons.compress.archivers.ArchiveEntry> getEntries() throws IOException;
18 |
19 | /**
20 | * Returns an {@link InputStream} with the given entries contents.
21 | * org.apache.commons.compress.archivers.ArchiveEntry
22 | */
23 | InputStream getInputStream(org.apache.commons.compress.archivers.ArchiveEntry entry) throws IOException;
24 | }
25 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TXZUnArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | /**
21 | * Alias for {@link TarXZUnArchiver}.
22 | */
23 | @Named("txz")
24 | public class TXZUnArchiver extends TarXZUnArchiver {}
25 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TXZArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | /**
21 | * Alias for {@link TarXZArchiver}.
22 | *
23 | * @since 4.7.0
24 | */
25 | @Named("txz")
26 | public class TXZArchiver extends TarXZArchiver {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TGZUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | /**
22 | * Alias for {@link TarGZipUnArchiver}.
23 | */
24 | @Named("tgz")
25 | public class TGZUnArchiver extends TarGZipUnArchiver {}
26 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TBZ2UnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | /**
22 | * Alias for {@link TarBZip2UnArchiver}.
23 | */
24 | @Named("tbz2")
25 | public class TBZ2UnArchiver extends TarBZip2UnArchiver {}
26 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TZstdArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The Plexus developers.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | /**
21 | * Alias for {@link TarZstdArchiver}.
22 | *
23 | * @since 4.7.2
24 | */
25 | @Named("tzst")
26 | public class TZstdArchiver extends TarZstdArchiver {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TZstdUnArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The Plexus developers.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | /**
21 | * Alias for {@link TarZstdUnArchiver}
22 | *
23 | * @since 4.7.2
24 | */
25 | @Named("tzst")
26 | public class TZstdUnArchiver extends TarZstdUnArchiver {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TGZArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | /**
22 | * Alias for {@link TarGZipArchiver}.
23 | *
24 | * @since 4.7.0
25 | */
26 | @Named("tgz")
27 | public class TGZArchiver extends TarGZipArchiver {}
28 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TBZ2Archiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | /**
22 | * Alias for {@link TarBZip2Archiver}.
23 | *
24 | * @since 4.7.0
25 | */
26 | @Named("tbz2")
27 | public class TBZ2Archiver extends TarBZip2Archiver {}
28 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTXZFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | /**
21 | * Alias for {@link PlexusIoTarXZFileResourceCollection}
22 | */
23 | @Named("txz")
24 | public class PlexusIoTXZFileResourceCollection extends PlexusIoTarXZFileResourceCollection {}
25 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/util/DefaultArchivedFileSet.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.util;
2 |
3 | import javax.annotation.Nonnull;
4 |
5 | import java.io.File;
6 |
7 | import org.codehaus.plexus.archiver.ArchivedFileSet;
8 |
9 | /**
10 | * Default implementation of {@link ArchivedFileSet}.
11 | *
12 | * @since 1.0-alpha-9
13 | */
14 | public class DefaultArchivedFileSet extends AbstractFileSet implements ArchivedFileSet {
15 |
16 | private final File archive;
17 |
18 | public DefaultArchivedFileSet(@Nonnull File archive) {
19 | this.archive = archive;
20 | }
21 |
22 | @Override
23 | public File getArchive() {
24 | return archive;
25 | }
26 |
27 | public static DefaultArchivedFileSet archivedFileSet(File archiveFile) {
28 | if (archiveFile == null) {
29 | throw new IllegalArgumentException("Archive File cannot be null");
30 | }
31 | return new DefaultArchivedFileSet(archiveFile);
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/rar/RarArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2000-2004 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.codehaus.plexus.archiver.rar;
18 |
19 | import javax.inject.Named;
20 |
21 | import org.codehaus.plexus.archiver.jar.JarArchiver;
22 |
23 | /**
24 | * Rar archiver.
25 | *
26 | * @see JarArchiver
27 | */
28 | @Named("rar")
29 | public class RarArchiver extends JarArchiver {}
30 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTZstdFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The Plexus developers.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | /**
21 | * Alias for {@link PlexusIoTarZstdFileResourceCollection}
22 | *
23 | * @since 4.7.2
24 | */
25 | @Named("tzst")
26 | public class PlexusIoTZstdFileResourceCollection extends PlexusIoTarZstdFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/ArchiverException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2004 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver;
17 |
18 | public class ArchiverException extends RuntimeException {
19 |
20 | public ArchiverException(String message) {
21 | super(message);
22 | }
23 |
24 | public ArchiverException(String message, Throwable cause) {
25 | super(message, cause);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/car/PlexusIoCarFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.car;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusArchiverZipFileResourceCollection;
21 |
22 | /**
23 | * Resource collection for CAR files.
24 | */
25 | @Named("car")
26 | public class PlexusIoCarFileResourceCollection extends PlexusArchiverZipFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/ear/PlexusIoEarFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.ear;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusArchiverZipFileResourceCollection;
21 |
22 | /**
23 | * Resource collection for EAR files.
24 | */
25 | @Named("ear")
26 | public class PlexusIoEarFileResourceCollection extends PlexusArchiverZipFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/esb/PlexusIoEsbFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.esb;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusArchiverZipFileResourceCollection;
21 |
22 | /**
23 | * Resource collection for ESB files.
24 | */
25 | @Named("esb")
26 | public class PlexusIoEsbFileResourceCollection extends PlexusArchiverZipFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/nar/PlexusIoNarFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.nar;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusArchiverZipFileResourceCollection;
21 |
22 | /**
23 | * Resource collection for NAR files.
24 | */
25 | @Named("nar")
26 | public class PlexusIoNarFileResourceCollection extends PlexusArchiverZipFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/par/PlexusIoJarFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.par;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusArchiverZipFileResourceCollection;
21 |
22 | /**
23 | * Resource collection for PAR files.
24 | */
25 | @Named("par")
26 | public class PlexusIoJarFileResourceCollection extends PlexusArchiverZipFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/rar/PlexusIoRarFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.rar;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusArchiverZipFileResourceCollection;
21 |
22 | /**
23 | * Resource collection for RAR files.
24 | */
25 | @Named("rar")
26 | public class PlexusIoRarFileResourceCollection extends PlexusArchiverZipFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/sar/PlexusIoSarFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.sar;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusArchiverZipFileResourceCollection;
21 |
22 | /**
23 | * Resource collection for SAR files.
24 | */
25 | @Named("sar")
26 | public class PlexusIoSarFileResourceCollection extends PlexusArchiverZipFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/swc/PlexusIoSwcFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.swc;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusArchiverZipFileResourceCollection;
21 |
22 | /**
23 | * Resource collection for SWC files.
24 | */
25 | @Named("swc")
26 | public class PlexusIoSwcFileResourceCollection extends PlexusArchiverZipFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/war/PlexusIoWarFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.war;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusArchiverZipFileResourceCollection;
21 |
22 | /**
23 | * Resource collection for WAR files.
24 | */
25 | @Named("war")
26 | public class PlexusIoWarFileResourceCollection extends PlexusArchiverZipFileResourceCollection {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/util/DefaultFileSet.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.util;
2 |
3 | import javax.annotation.Nonnull;
4 |
5 | import java.io.File;
6 |
7 | import org.codehaus.plexus.archiver.FileSet;
8 |
9 | /**
10 | * Default implementation of {@link FileSet}.
11 | *
12 | * @since 1.0-alpha-9
13 | */
14 | public class DefaultFileSet extends AbstractFileSet implements FileSet {
15 |
16 | private File directory;
17 |
18 | public DefaultFileSet(File directory) {
19 | this.directory = directory;
20 | }
21 |
22 | public DefaultFileSet() {}
23 |
24 | /**
25 | * Sets the file sets base directory.
26 | */
27 | public void setDirectory(@Nonnull File directory) {
28 | this.directory = directory;
29 | }
30 |
31 | @Nonnull
32 | public File getDirectory() {
33 | return directory;
34 | }
35 |
36 | public static DefaultFileSet fileSet(File directory) {
37 | final DefaultFileSet defaultFileSet = new DefaultFileSet(directory);
38 | return defaultFileSet;
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/components/io/resources/PlexusIoZipFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.components.io.resources;
17 |
18 | /**
19 | * Wrapper to retain compatibility with old-style plexus-io. Can be removed "some day".
20 | * Make sure maven-assembly-plugin IT's work when you do :)
21 | */
22 | public class PlexusIoZipFileResourceCollection
23 | extends org.codehaus.plexus.archiver.zip.PlexusIoZipFileResourceCollection {}
24 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/TestSupport.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.io.File;
4 | import java.nio.file.Path;
5 | import java.nio.file.Paths;
6 |
7 | import org.eclipse.sisu.launch.InjectedTest;
8 | import org.junit.jupiter.api.AfterEach;
9 | import org.junit.jupiter.api.BeforeEach;
10 |
11 | /**
12 | * Test support class.
13 | */
14 | public abstract class TestSupport extends InjectedTest {
15 | @Override
16 | @BeforeEach
17 | public void setUp() throws Exception {
18 | super.setUp();
19 | }
20 |
21 | @Override
22 | @AfterEach
23 | public void tearDown() throws Exception {
24 | super.tearDown();
25 | }
26 |
27 | private static Path basedir() {
28 | return Paths.get(System.getProperty("basedir", (new File("")).getAbsolutePath()));
29 | }
30 |
31 | protected static File getTestFile(final String path) {
32 | return basedir().resolve(path).toFile();
33 | }
34 |
35 | protected static File getTestFile(final String basedir, final String path) {
36 | return basedir().resolve(basedir).resolve(path).toFile();
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarXZArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | /**
21 | * Create tar with XZ compression.
22 | *
23 | * @since 4.7.0
24 | */
25 | @Named("tar.xz")
26 | public class TarXZArchiver extends TarArchiver {
27 |
28 | public TarXZArchiver() {
29 | setupCompressionMethod();
30 | }
31 |
32 | private void setupCompressionMethod() {
33 | setCompression(TarCompressionMethod.xz);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zip/ZipUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.zip;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | /**
24 | * @author Emmanuel Venisse
25 | */
26 | @Named("zip")
27 | public class ZipUnArchiver extends AbstractZipUnArchiver {
28 |
29 | public ZipUnArchiver() {}
30 |
31 | public ZipUnArchiver(File sourceFile) {
32 | super(sourceFile);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/exceptions/EmptyArchiveException.java:
--------------------------------------------------------------------------------
1 | /**
2 | * Copyright 2004 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.exceptions;
17 |
18 | import org.codehaus.plexus.archiver.ArchiverException;
19 |
20 | public class EmptyArchiveException extends ArchiverException {
21 |
22 | public EmptyArchiveException(String message) {
23 | super(message);
24 | }
25 |
26 | public EmptyArchiveException(String message, Throwable cause) {
27 | super(message, cause);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/util/DefaultFileSetTest.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.util;
2 |
3 | import java.io.File;
4 |
5 | import org.junit.jupiter.api.Test;
6 |
7 | import static org.codehaus.plexus.archiver.util.DefaultFileSet.fileSet;
8 | import static org.junit.jupiter.api.Assertions.assertEquals;
9 |
10 | /**
11 | * @author Kristian Rosenvold
12 | */
13 | class DefaultFileSetTest {
14 |
15 | @Test
16 | void create() {
17 | final String[] includes = {"zz", "yy"};
18 | final String[] exc = {"xx1", "xx2"};
19 | final boolean usingDefaultExcludes = true;
20 | final DefaultFileSet dfs = fileSet(new File("foo"))
21 | .prefixed("pfx")
22 | .include(includes)
23 | .exclude(exc)
24 | .usingDefaultExcludes(usingDefaultExcludes);
25 | assertEquals("foo", dfs.getDirectory().getName());
26 | assertEquals("pfx", dfs.getPrefix());
27 | assertEquals("zz", dfs.getIncludes()[0]);
28 | assertEquals("xx1", dfs.getExcludes()[0]);
29 | assertEquals(usingDefaultExcludes, dfs.isUsingDefaultExcludes());
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/jar/PlexusIoJarFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.jar;
17 |
18 | import javax.inject.Named;
19 |
20 | import org.codehaus.plexus.archiver.zip.PlexusIoJarFileResourceCollectionWithSignatureVerification;
21 |
22 | /**
23 | * Resource collection for JAR files that uses JarFile to verify signatures when present.
24 | */
25 | @Named("jar")
26 | public class PlexusIoJarFileResourceCollection extends PlexusIoJarFileResourceCollectionWithSignatureVerification {}
27 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/car/CarUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.car;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("car")
29 | public class CarUnArchiver extends ZipUnArchiver {
30 |
31 | public CarUnArchiver() {}
32 |
33 | public CarUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/ear/EarUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.ear;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("ear")
29 | public class EarUnArchiver extends ZipUnArchiver {
30 |
31 | public EarUnArchiver() {}
32 |
33 | public EarUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/esb/EsbUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.esb;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("esb")
29 | public class EsbUnArchiver extends ZipUnArchiver {
30 |
31 | public EsbUnArchiver() {}
32 |
33 | public EsbUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/jar/JarUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.jar;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("jar")
29 | public class JarUnArchiver extends ZipUnArchiver {
30 |
31 | public JarUnArchiver() {}
32 |
33 | public JarUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/nar/NarUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.nar;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("nar")
29 | public class NarUnArchiver extends ZipUnArchiver {
30 |
31 | public NarUnArchiver() {}
32 |
33 | public NarUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/par/ParUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.par;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("par")
29 | public class ParUnArchiver extends ZipUnArchiver {
30 |
31 | public ParUnArchiver() {}
32 |
33 | public ParUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/rar/RarUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.rar;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("rar")
29 | public class RarUnArchiver extends ZipUnArchiver {
30 |
31 | public RarUnArchiver() {}
32 |
33 | public RarUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/sar/SarUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.sar;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("sar")
29 | public class SarUnArchiver extends ZipUnArchiver {
30 |
31 | public SarUnArchiver() {}
32 |
33 | public SarUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/swc/SwcUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.swc;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("swc")
29 | public class SwcUnArchiver extends ZipUnArchiver {
30 |
31 | public SwcUnArchiver() {}
32 |
33 | public SwcUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/war/WarUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.war;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | import org.codehaus.plexus.archiver.zip.ZipUnArchiver;
24 |
25 | /**
26 | * Alias for {@link ZipUnArchiver}.
27 | */
28 | @Named("war")
29 | public class WarUnArchiver extends ZipUnArchiver {
30 |
31 | public WarUnArchiver() {}
32 |
33 | public WarUnArchiver(File sourceFile) {
34 | super(sourceFile);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/jar/ManifestException.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.jar;
18 |
19 | /**
20 | * Exception thrown indicating problems in a JAR Manifest
21 | */
22 | public class ManifestException extends Exception {
23 |
24 | /**
25 | * Constructs an exception with the given descriptive message.
26 | *
27 | * @param msg Description of or information about the exception.
28 | */
29 | public ManifestException(String msg) {
30 | super(msg);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarZstdArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | /**
21 | * Create tar with zstd compression.
22 | *
23 | * @since 4.7.0
24 | */
25 | @Named("tar.zst")
26 | public class TarZstdArchiver extends TarArchiver {
27 |
28 | public TarZstdArchiver() {
29 | setupCompressionMethod();
30 | }
31 |
32 | private final void setupCompressionMethod() {
33 | setCompression(TarCompressionMethod.zstd);
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarGZipArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | /**
22 | * Create tar with gzip compression.
23 | *
24 | * @since 4.7.0
25 | */
26 | @Named("tar.gz")
27 | public class TarGZipArchiver extends TarArchiver {
28 |
29 | public TarGZipArchiver() {
30 | this.setupCompressionMethod();
31 | }
32 |
33 | private void setupCompressionMethod() {
34 | this.setCompression(TarCompressionMethod.gzip);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarBZip2Archiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | /**
22 | * Create tar with bzip2 compression.
23 | *
24 | * @since 4.7.0
25 | */
26 | @Named("tar.bz2")
27 | public class TarBZip2Archiver extends TarArchiver {
28 |
29 | public TarBZip2Archiver() {
30 | this.setupCompressionMethod();
31 | }
32 |
33 | private void setupCompressionMethod() {
34 | this.setCompression(TarCompressionMethod.bzip2);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zip/AnonymousResource.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.zip;
2 |
3 | import javax.annotation.Nonnull;
4 |
5 | import java.io.File;
6 | import java.io.IOException;
7 | import java.io.InputStream;
8 | import java.net.URL;
9 |
10 | import org.codehaus.plexus.components.io.resources.AbstractPlexusIoResource;
11 |
12 | public class AnonymousResource extends AbstractPlexusIoResource {
13 |
14 | private final File file;
15 |
16 | public AnonymousResource(File file) {
17 | this(file, getName(file));
18 | }
19 |
20 | public AnonymousResource(File file, String name) {
21 | super(name, file.lastModified(), file.length(), file.isFile(), file.isDirectory(), file.exists());
22 | this.file = file;
23 | }
24 |
25 | @Nonnull
26 | @Override
27 | public InputStream getContents() throws IOException {
28 | throw new UnsupportedOperationException("not supp");
29 | }
30 |
31 | @Override
32 | public URL getURL() throws IOException {
33 | return file.toURI().toURL();
34 | }
35 |
36 | private static String getName(File file) {
37 | return file.getPath().replace('\\', '/');
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarSnappyArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | /**
22 | * Create tar with snappy compression.
23 | *
24 | * @since 4.7.0
25 | */
26 | @Named("tar.snappy")
27 | public class TarSnappyArchiver extends TarArchiver {
28 |
29 | public TarSnappyArchiver() {
30 | this.setupCompressionMethod();
31 | }
32 |
33 | private void setupCompressionMethod() {
34 | this.setCompression(TarCompressionMethod.snappy);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/.github/workflows/maven.yml:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 |
18 | name: GitHub CI
19 |
20 | on: [push, pull_request]
21 |
22 | jobs:
23 | build:
24 | name: Build it
25 | uses: codehaus-plexus/.github/.github/workflows/maven.yml@master
26 |
27 | # deploy:
28 | # name: Deploy
29 | # needs: build
30 | # uses: codehaus-plexus/.github/.github/workflows/maven-deploy.yml@master
31 | # secrets: inherit
32 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTarXZFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | import java.io.File;
21 |
22 | /**
23 | *
24 | * @author philip.lourandos
25 | * @since 3.3
26 | */
27 | @Named("tar.xz")
28 | public class PlexusIoTarXZFileResourceCollection extends PlexusIoTarFileResourceCollection {
29 |
30 | public PlexusIoTarXZFileResourceCollection() {}
31 |
32 | @Override
33 | protected TarFile newTarFile(File file) {
34 | return new XZTarFile(file);
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/manager/NoSuchArchiverException.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001,2004 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.codehaus.plexus.archiver.manager;
18 |
19 | /**
20 | * @author dantran
21 | */
22 | public class NoSuchArchiverException extends Exception {
23 |
24 | private final String archiverName;
25 |
26 | public NoSuchArchiverException(String archiverName) {
27 | super("No such archiver: '" + archiverName + "'.");
28 |
29 | this.archiverName = archiverName;
30 | }
31 |
32 | public String getArchiver() {
33 | return archiverName;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTarZstdFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | import java.io.File;
21 |
22 | /**
23 | * Alias for {@link PlexusIoTarFileResourceCollection}
24 | */
25 | @Named("tar.zst")
26 | public class PlexusIoTarZstdFileResourceCollection extends PlexusIoTarFileResourceCollection {
27 |
28 | public PlexusIoTarZstdFileResourceCollection() {}
29 |
30 | @Override
31 | protected TarFile newTarFile(File file) {
32 | return new ZstdTarFile(file);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zip/PlexusIoZipFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.zip;
17 |
18 | /**
19 | * Zip file resource collection that uses PlexusArchiverZipFileResourceCollection
20 | * for better performance. For JAR files that need signature verification,
21 | * use {@link PlexusIoJarFileResourceCollectionWithSignatureVerification}.
22 | */
23 | // TODO: there were two components for same name!
24 | // @Named( "zip" )
25 | public class PlexusIoZipFileResourceCollection extends PlexusArchiverZipFileResourceCollection {
26 |
27 | public PlexusIoZipFileResourceCollection() {}
28 | }
29 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/XZTarFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import java.io.File;
19 | import java.io.IOException;
20 | import java.io.InputStream;
21 |
22 | import org.codehaus.plexus.archiver.xz.XZUnArchiver;
23 |
24 | /**
25 | *
26 | * @author philip.lourandos
27 | * @since 3.3
28 | */
29 | public class XZTarFile extends TarFile {
30 |
31 | public XZTarFile(File file) {
32 | super(file);
33 | }
34 |
35 | @Override
36 | protected InputStream getInputStream(File file) throws IOException {
37 | return XZUnArchiver.getXZInputStream(super.getInputStream(file));
38 | }
39 | }
40 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarXZUnArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | import java.io.File;
21 |
22 | /**
23 | *
24 | * @author philip.lourandos
25 | * @since 3.3
26 | */
27 | @Named("tar.xz")
28 | public class TarXZUnArchiver extends TarUnArchiver {
29 |
30 | public TarXZUnArchiver() {
31 | setupCompressionMethod();
32 | }
33 |
34 | public TarXZUnArchiver(File sourceFile) {
35 | super(sourceFile);
36 |
37 | setupCompressionMethod();
38 | }
39 |
40 | private void setupCompressionMethod() {
41 | setCompression(TarUnArchiver.UntarCompressionMethod.XZ);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarZstdUnArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | import java.io.File;
21 |
22 | /**
23 | * Extract files in tar with zstd compression
24 | */
25 | @Named("tar.zst")
26 | public class TarZstdUnArchiver extends TarUnArchiver {
27 |
28 | public TarZstdUnArchiver() {
29 | setupCompressionMethod();
30 | }
31 |
32 | public TarZstdUnArchiver(File sourceFile) {
33 | super(sourceFile);
34 |
35 | setupCompressionMethod();
36 | }
37 |
38 | private final void setupCompressionMethod() {
39 | setCompression(UntarCompressionMethod.ZSTD);
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/ZstdTarFile.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import java.io.File;
19 | import java.io.IOException;
20 | import java.io.InputStream;
21 |
22 | import org.codehaus.plexus.archiver.zstd.ZstdUnArchiver;
23 |
24 | /**
25 | * Extension of {@link org.codehaus.plexus.archiver.tar.TarFile} for zst compressed files.
26 | */
27 | public class ZstdTarFile extends TarFile {
28 |
29 | public ZstdTarFile(File file) {
30 | super(file);
31 | }
32 |
33 | @Override
34 | protected InputStream getInputStream(File file) throws IOException {
35 | return ZstdUnArchiver.getZstdInputStream(super.getInputStream(file));
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarSnappyUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | /**
24 | * Extract files in tar with snappy compression
25 | *
26 | */
27 | @Named("tar.snappy")
28 | public class TarSnappyUnArchiver extends TarUnArchiver {
29 |
30 | public TarSnappyUnArchiver() {
31 | this.setupCompressionMethod();
32 | }
33 |
34 | public TarSnappyUnArchiver(File sourceFile) {
35 | super(sourceFile);
36 | this.setupCompressionMethod();
37 | }
38 |
39 | private void setupCompressionMethod() {
40 | this.setCompression(UntarCompressionMethod.SNAPPY);
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarGZipUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | /**
24 | * Extract files in tar with gzip compression
25 | *
26 | * @author Dan Tran
27 | */
28 | @Named("tar.gz")
29 | public class TarGZipUnArchiver extends TarUnArchiver {
30 |
31 | public TarGZipUnArchiver() {
32 | this.setupCompressionMethod();
33 | }
34 |
35 | public TarGZipUnArchiver(File sourceFile) {
36 | super(sourceFile);
37 | this.setupCompressionMethod();
38 | }
39 |
40 | private void setupCompressionMethod() {
41 | this.setCompression(UntarCompressionMethod.GZIP);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/snappy/PlexusIoSnappyResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.snappy;
2 |
3 | import javax.annotation.Nonnull;
4 | import javax.annotation.WillNotClose;
5 | import javax.inject.Named;
6 |
7 | import java.io.File;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 |
11 | import org.codehaus.plexus.archiver.util.Streams;
12 | import org.codehaus.plexus.components.io.attributes.FileAttributes;
13 | import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
14 | import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection;
15 |
16 | /**
17 | * Implementation of {@link org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection} for
18 | * snappy compressed files.
19 | */
20 | @Named("snappy")
21 | public class PlexusIoSnappyResourceCollection extends PlexusIoCompressedFileResourceCollection {
22 |
23 | @Nonnull
24 | @Override
25 | protected @WillNotClose InputStream getInputStream(File file) throws IOException {
26 | return SnappyUnArchiver.getSnappyInputStream(Streams.fileInputStream(file));
27 | }
28 |
29 | @Override
30 | protected PlexusIoResourceAttributes getAttributes(File file) throws IOException {
31 | return new FileAttributes(file);
32 | }
33 |
34 | @Override
35 | protected String getDefaultExtension() {
36 | return ".snappy";
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarBZip2UnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 |
23 | /**
24 | * Extract files in tar with bzip2 compression
25 | *
26 | * @author Dan Tran
27 | */
28 | @Named("tar.bz2")
29 | public class TarBZip2UnArchiver extends TarUnArchiver {
30 |
31 | public TarBZip2UnArchiver() {
32 | this.setupCompressionMethod();
33 | }
34 |
35 | public TarBZip2UnArchiver(File sourceFile) {
36 | super(sourceFile);
37 | this.setupCompressionMethod();
38 | }
39 |
40 | private void setupCompressionMethod() {
41 | this.setCompression(UntarCompressionMethod.BZIP2);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/gzip/PlexusIoGzipResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.gzip;
2 |
3 | import javax.annotation.Nonnull;
4 | import javax.inject.Named;
5 |
6 | import java.io.File;
7 | import java.io.IOException;
8 | import java.io.InputStream;
9 | import java.util.zip.GZIPInputStream;
10 |
11 | import org.codehaus.plexus.components.io.attributes.FileAttributes;
12 | import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
13 | import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection;
14 |
15 | import static org.codehaus.plexus.archiver.util.Streams.bufferedInputStream;
16 | import static org.codehaus.plexus.archiver.util.Streams.fileInputStream;
17 |
18 | /**
19 | * Abstract base class for compressed files, aka singleton
20 | * resource collections.
21 | */
22 | @Named("gzip")
23 | public class PlexusIoGzipResourceCollection extends PlexusIoCompressedFileResourceCollection {
24 |
25 | @Override
26 | protected String getDefaultExtension() {
27 | return ".gz";
28 | }
29 |
30 | @Nonnull
31 | @Override
32 | protected InputStream getInputStream(File file) throws IOException {
33 | return bufferedInputStream(new GZIPInputStream(fileInputStream(file)));
34 | }
35 |
36 | @Override
37 | protected PlexusIoResourceAttributes getAttributes(File file) throws IOException {
38 | return new FileAttributes(file);
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/bzip2/PlexusIoBzip2ResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.bzip2;
2 |
3 | import javax.annotation.Nonnull;
4 | import javax.annotation.WillNotClose;
5 | import javax.inject.Named;
6 |
7 | import java.io.File;
8 | import java.io.IOException;
9 | import java.io.InputStream;
10 |
11 | import org.codehaus.plexus.components.io.attributes.FileAttributes;
12 | import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
13 | import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection;
14 | import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection;
15 |
16 | import static org.codehaus.plexus.archiver.util.Streams.fileInputStream;
17 |
18 | /**
19 | * Implementation of {@link PlexusIoResourceCollection} for
20 | * bzip2 compressed files.
21 | */
22 | @Named("bzip2")
23 | public class PlexusIoBzip2ResourceCollection extends PlexusIoCompressedFileResourceCollection {
24 |
25 | @Nonnull
26 | @Override
27 | protected @WillNotClose InputStream getInputStream(File file) throws IOException {
28 | return BZip2UnArchiver.getBZip2InputStream(fileInputStream(file));
29 | }
30 |
31 | @Override
32 | protected PlexusIoResourceAttributes getAttributes(File file) throws IOException {
33 | return new FileAttributes(file);
34 | }
35 |
36 | @Override
37 | protected String getDefaultExtension() {
38 | return ".bz2";
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/util/FilterSupport.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.util;
2 |
3 | import java.io.InputStream;
4 | import java.util.List;
5 |
6 | import org.codehaus.plexus.archiver.ArchiveFileFilter;
7 | import org.codehaus.plexus.archiver.Archiver;
8 | import org.codehaus.plexus.components.io.fileselectors.FileSelector;
9 | import org.slf4j.Logger;
10 |
11 | /**
12 | * @deprecated Use {@link FileSelector} and {@link Archiver#addFileSet}.
13 | */
14 | @Deprecated
15 | public class FilterSupport {
16 |
17 | private final List filters;
18 |
19 | private final Logger logger;
20 |
21 | public FilterSupport(List filters, Logger logger) {
22 | this.filters = filters;
23 | this.logger = logger;
24 | }
25 |
26 | public boolean include(InputStream dataStream, String entryName) {
27 | boolean included = true;
28 |
29 | if (filters != null && !filters.isEmpty()) {
30 | for (ArchiveFileFilter filter : filters) {
31 | included = filter.include(dataStream, entryName);
32 |
33 | if (!included) {
34 | if (logger.isDebugEnabled()) {
35 | logger.debug("Entry: \'" + entryName + "\' excluded by filter: "
36 | + filter.getClass().getName());
37 | }
38 |
39 | break;
40 | }
41 | }
42 | }
43 |
44 | return included;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/zip/OffloadingOutputStreamTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The Plexus developers.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.codehaus.plexus.archiver.zip;
18 |
19 | import java.io.File;
20 | import java.nio.file.Files;
21 |
22 | import org.junit.jupiter.api.Test;
23 |
24 | import static org.assertj.core.api.Assertions.assertThat;
25 |
26 | class OffloadingOutputStreamTest {
27 |
28 | @Test
29 | void temporaryFileShouldBeCreated() throws Exception {
30 | File streamFile = null;
31 | try (OffloadingOutputStream stream = new OffloadingOutputStream(100, "test", "test")) {
32 | stream.write(new byte[256]);
33 | stream.close();
34 | streamFile = stream.getFile();
35 | assertThat(streamFile).isFile().hasSize(256);
36 | } finally {
37 | if (streamFile != null) {
38 | Files.delete(streamFile.toPath());
39 | }
40 | }
41 | }
42 | }
43 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Plexus-archiver
2 | ===============
3 |
4 | [](http://www.apache.org/licenses/)
5 | [](https://search.maven.org/artifact/org.codehaus.plexus/plexus-archiver)
6 | [](https://github.com/codehaus-plexus/plexus-archiver/actions/workflows/maven.yml)
7 | [](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/codehaus/plexus/plexus-archiver/README.md)
8 |
9 | The current master is now at https://github.com/codehaus-plexus/plexus-archiver
10 |
11 | ## Important Hint
12 |
13 | Based on a hint of snyk.io security team they have found a possible security issue.
14 | Furthermore they have offered an patch to prevent the possible security issue.
15 | This patch has been integrated into the Release 3.6.0
16 |
17 | ## Release Notes
18 |
19 | Current release notes are maintained on GitHub [releases](https://github.com/codehaus-plexus/plexus-archiver/releases)
20 |
21 | You can find details about the historical releases in the [Release Notes](https://github.com/codehaus-plexus/plexus-archiver/blob/master/ReleaseNotes.md).
22 |
23 |
--------------------------------------------------------------------------------
/src/test/resources/unicodePathExtra/README.md:
--------------------------------------------------------------------------------
1 | # Test ZIP Files for Unicode Path Extra Field
2 |
3 | These files are used to test for proper use of Unicode Path extra fields ([zip specification §4.6.9](https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT)) when unarchiving zip archives.
4 |
5 | Both contain three empty files, one without a Unicode Path extra field, one with a good extra field (CRC matches the header file name), one with a stale extra field (mismatched CRC). By using different values in the header file name and the Unicode path, it can be distinguished which one was used. A compliant unarchiver will use the names marked in bold.
6 |
7 | | File name in header | CRC | Unicode Path |
8 | |---------------------|-----------------------|---------------------|
9 | | **nameonly-name** |
10 | | goodextra-name | CRC("goodextra-name") | **goodextra-extra** |
11 | | **badextra-name** | CRC("bogus") | badextra-extra |
12 |
13 | The difference between the two archives is whether the Language Encoding Flag (EFS) is set, which indicates that the header file names are already in UTF-8. The specification is not explicit about which one wins when both the flag is set and a Unicode Path extra field is present (it only says archivers shouldn’t do that). In practice, all unarchivers I have seen (including Apache Commons Compress used by Plexus-Archiver) ignore the extra field when the flag is set, which is why only _efsclear.zip_ is useful for testing.
14 |
15 | The archives were created by the included _GenerateZips.java_ using Commons Compress.
16 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/sar/SarArchiverTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.sar;
17 |
18 | import org.codehaus.plexus.archiver.BasePlexusArchiverTest;
19 | import org.codehaus.plexus.archiver.manager.ArchiverManager;
20 | import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection;
21 | import org.junit.jupiter.api.Test;
22 |
23 | import static org.junit.jupiter.api.Assertions.assertNotNull;
24 |
25 | class SarArchiverTest extends BasePlexusArchiverTest {
26 |
27 | @Test
28 | void testLookup() throws Exception {
29 | ArchiverManager dam = lookup(ArchiverManager.class);
30 | PlexusIoResourceCollection sar = dam.getResourceCollection("sar");
31 | assertNotNull(sar);
32 | PlexusIoResourceCollection archiver =
33 | (PlexusIoResourceCollection) lookup(PlexusIoResourceCollection.class, "sar");
34 |
35 | assertNotNull(archiver);
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarSymlinkResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010-2015 The plexus developers.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import java.io.IOException;
19 |
20 | import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
21 | import org.codehaus.plexus.components.io.functions.SymlinkDestinationSupplier;
22 |
23 | /**
24 | * A {@link TarResource} that represents symbolic link.
25 | */
26 | public class TarSymlinkResource extends TarResource implements SymlinkDestinationSupplier {
27 |
28 | private final String symlinkDestination;
29 |
30 | public TarSymlinkResource(TarFile tarFile, TarArchiveEntry entry) {
31 | super(tarFile, entry);
32 | symlinkDestination = entry.getLinkName();
33 | }
34 |
35 | @Override
36 | public String getSymlinkDestination() throws IOException {
37 | return symlinkDestination;
38 | }
39 |
40 | @Override
41 | public boolean isSymbolicLink() {
42 | return true;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtilsTest.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.util;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 | import java.nio.file.Files;
6 | import java.nio.file.Path;
7 |
8 | import org.codehaus.plexus.components.io.attributes.FileAttributes;
9 | import org.junit.jupiter.api.Test;
10 | import org.junit.jupiter.api.condition.DisabledOnOs;
11 | import org.junit.jupiter.api.condition.OS;
12 | import org.junit.jupiter.api.io.TempDir;
13 |
14 | import static org.junit.jupiter.api.Assertions.assertFalse;
15 | import static org.junit.jupiter.api.Assertions.assertTrue;
16 |
17 | class ArchiveEntryUtilsTest {
18 |
19 | @TempDir
20 | private Path tempDir;
21 |
22 | @Test
23 | @DisabledOnOs(OS.WINDOWS)
24 | void chmodForFileWithDollarPLXCOMP164() throws Exception {
25 | File temp = Files.createTempFile(tempDir, "A$A", "BB$").toFile();
26 | ArchiveEntryUtils.chmod(temp, 0770);
27 | assert0770(temp);
28 | }
29 |
30 | @Test
31 | @DisabledOnOs(OS.WINDOWS)
32 | void chmodWithJava7() throws Exception {
33 | File temp = Files.createTempFile(tempDir, "D$D", "BB$").toFile();
34 | ArchiveEntryUtils.chmod(temp, 0770);
35 | assert0770(temp);
36 | }
37 |
38 | private void assert0770(File temp) throws IOException {
39 | FileAttributes j7 = new FileAttributes(temp);
40 | assertTrue(j7.isGroupExecutable());
41 | assertTrue(j7.isGroupReadable());
42 | assertTrue(j7.isGroupWritable());
43 |
44 | assertFalse(j7.isWorldExecutable());
45 | assertFalse(j7.isWorldReadable());
46 | assertFalse(j7.isWorldWritable());
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/util/ResourceUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright The Plexus developers.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.util;
17 |
18 | import java.util.stream.Stream;
19 |
20 | import org.junit.jupiter.params.ParameterizedTest;
21 | import org.junit.jupiter.params.provider.Arguments;
22 | import org.junit.jupiter.params.provider.MethodSource;
23 |
24 | import static org.assertj.core.api.Assertions.assertThat;
25 |
26 | class ResourceUtilsTest {
27 |
28 | public static Stream testIsUpToDate() {
29 | return Stream.of(
30 | Arguments.of(0, 0, false), // dest and src 0
31 | Arguments.of(100, 0, false), // dest 0
32 | Arguments.of(0, 100, false), // src 0
33 | Arguments.of(100, 200, true),
34 | Arguments.of(200, 100, false),
35 | Arguments.of(100, 100, true));
36 | }
37 |
38 | @ParameterizedTest
39 | @MethodSource
40 | void testIsUpToDate(long source, long destination, boolean expected) {
41 | assertThat(ResourceUtils.isUptodate(source, destination)).isEqualTo(expected);
42 | }
43 | }
44 |
--------------------------------------------------------------------------------
/src/test/resources/unicodePathExtra/GenerateZips.java:
--------------------------------------------------------------------------------
1 | import java.io.File;
2 | import java.io.IOException;
3 | import java.nio.charset.Charset;
4 |
5 | import org.apache.commons.compress.archivers.zip.UnicodePathExtraField;
6 | import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
7 | import org.apache.commons.compress.archivers.zip.ZipArchiveOutputStream;
8 |
9 | public class GenerateZips {
10 |
11 | private static void generate(String outfilename, boolean languageEncodingFlag) {
12 | try {
13 | ZipArchiveOutputStream zs = new ZipArchiveOutputStream(new File(outfilename));
14 | zs.setUseLanguageEncodingFlag(languageEncodingFlag);
15 | zs.setMethod(ZipArchiveOutputStream.STORED);
16 | ZipArchiveEntry ze = new ZipArchiveEntry("nameonly-name");
17 | ze.setTime(0);
18 | zs.putArchiveEntry(ze);
19 | //zs.write(nothing);
20 | zs.closeArchiveEntry();
21 | ze = new ZipArchiveEntry("goodextra-name");
22 | ze.setTime(0);
23 | ze.addExtraField(new UnicodePathExtraField("goodextra-extra", "goodextra-name".getBytes(Charset.forName("UTF-8"))));
24 | zs.putArchiveEntry(ze);
25 | //zs.write(nothing);
26 | zs.closeArchiveEntry();
27 | ze = new ZipArchiveEntry("badextra-name");
28 | ze.setTime(0);
29 | ze.addExtraField(new UnicodePathExtraField("badextra-extra", "bogus".getBytes(Charset.forName("UTF-8"))));
30 | zs.putArchiveEntry(ze);
31 | //zs.write(nothing);
32 | zs.closeArchiveEntry();
33 | zs.finish();
34 | zs.close();
35 | } catch (IOException e) {
36 | e.printStackTrace();
37 | }
38 | }
39 |
40 | public static void main(String[] args) {
41 | generate("efsclear.zip", false);
42 | // with the flag set, decoders tend to not look at the extra field
43 | generate("efsset.zip", true);
44 | System.out.println("done");
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/jar/ManifestConstants.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.jar;
18 |
19 | /**
20 | * Manifest constants
21 | * Not part of any public API
22 | */
23 | class ManifestConstants {
24 |
25 | /**
26 | * The standard manifest version header
27 | */
28 | public static final String ATTRIBUTE_MANIFEST_VERSION = "Manifest-Version";
29 |
30 | /**
31 | * The standard Signature Version header
32 | */
33 | public static final String ATTRIBUTE_SIGNATURE_VERSION = "Signature-Version";
34 |
35 | /**
36 | * The Name Attribute is the first in a named section
37 | */
38 | public static final String ATTRIBUTE_NAME = "Name";
39 |
40 | /**
41 | * The From Header is disallowed in a Manifest
42 | */
43 | public static final String ATTRIBUTE_FROM = "From";
44 |
45 | /**
46 | * The Class-Path Header is special - it can be duplicated
47 | */
48 | public static final String ATTRIBUTE_CLASSPATH = "Class-Path";
49 |
50 | /**
51 | * Default Manifest version if one is not specified
52 | */
53 | public static final String DEFAULT_MANIFEST_VERSION = "1.0";
54 | }
55 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/xz/PlexusIoXZResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.xz;
17 |
18 | import javax.inject.Named;
19 |
20 | import java.io.File;
21 | import java.io.IOException;
22 | import java.io.InputStream;
23 |
24 | import org.codehaus.plexus.archiver.util.Streams;
25 | import org.codehaus.plexus.components.io.attributes.FileAttributes;
26 | import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
27 | import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection;
28 |
29 | /**
30 | * @author lore
31 | * @since 3.3
32 | */
33 | @Named("xz")
34 | public class PlexusIoXZResourceCollection extends PlexusIoCompressedFileResourceCollection {
35 |
36 | @Override
37 | protected PlexusIoResourceAttributes getAttributes(File file) throws IOException {
38 | return new FileAttributes(file);
39 | }
40 |
41 | @Override
42 | protected String getDefaultExtension() {
43 | return ".xz";
44 | }
45 |
46 | @Override
47 | protected InputStream getInputStream(File file) throws IOException {
48 | return XZUnArchiver.getXZInputStream(Streams.fileInputStream(file));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/resources/PlexusIoVirtualSymlinkResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.resources;
17 |
18 | import java.io.File;
19 | import java.io.IOException;
20 |
21 | import org.codehaus.plexus.components.io.attributes.SymlinkUtils;
22 | import org.codehaus.plexus.components.io.functions.SymlinkDestinationSupplier;
23 |
24 | /**
25 | * A symlink that does not necessarily exist (anywhere).
26 | */
27 | public class PlexusIoVirtualSymlinkResource extends PlexusIoVirtualFileResource implements SymlinkDestinationSupplier {
28 |
29 | private final String symnlinkDestination;
30 |
31 | public PlexusIoVirtualSymlinkResource(File symlinkFile, String symnlinkDestination) {
32 | super(symlinkFile, getName(symlinkFile));
33 | this.symnlinkDestination = symnlinkDestination;
34 | }
35 |
36 | @Override
37 | public String getSymlinkDestination() throws IOException {
38 | return symnlinkDestination == null
39 | ? SymlinkUtils.readSymbolicLink(getFile()).toString()
40 | : symnlinkDestination;
41 | }
42 |
43 | @Override
44 | public boolean isSymbolicLink() {
45 | return true;
46 | }
47 | }
48 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zip/ZipSymlinkResource.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010-2015 The plexus developers.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.zip;
17 |
18 | import java.io.IOException;
19 |
20 | import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
21 | import org.apache.commons.compress.archivers.zip.ZipFile;
22 | import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
23 | import org.codehaus.plexus.components.io.functions.SymlinkDestinationSupplier;
24 |
25 | /**
26 | * A {@link ZipResource} that represents symbolic link.
27 | */
28 | public class ZipSymlinkResource extends ZipResource implements SymlinkDestinationSupplier {
29 |
30 | private final String symlinkDestination;
31 |
32 | public ZipSymlinkResource(ZipFile zipFile, ZipArchiveEntry entry, InputStreamTransformer streamTransformer) {
33 | super(zipFile, entry, streamTransformer);
34 | try {
35 | symlinkDestination = zipFile.getUnixSymlink(entry);
36 | } catch (IOException e) {
37 | throw new RuntimeException(e);
38 | }
39 | }
40 |
41 | @Override
42 | public String getSymlinkDestination() throws IOException {
43 | return symlinkDestination;
44 | }
45 |
46 | @Override
47 | public boolean isSymbolicLink() {
48 | return true;
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/filters/JarSecurityFileSelector.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2007 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 | * in compliance with the License. You may obtain a copy of the License at
6 | *
7 | * http://www.apache.org/licenses/LICENSE-2.0
8 | *
9 | * Unless required by applicable law or agreed to in writing, software distributed under the License
10 | * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 | * or implied. See the License for the specific language governing permissions and limitations under
12 | * the License.
13 | */
14 | package org.codehaus.plexus.archiver.filters;
15 |
16 | import javax.annotation.Nonnull;
17 | import javax.inject.Named;
18 | import javax.inject.Singleton;
19 |
20 | import java.io.IOException;
21 |
22 | import org.codehaus.plexus.components.io.fileselectors.FileInfo;
23 | import org.codehaus.plexus.components.io.fileselectors.FileSelector;
24 | import org.codehaus.plexus.util.SelectorUtils;
25 |
26 | /**
27 | * @since 1.0-alpha-9
28 | */
29 | @Singleton
30 | @Named("jar-security")
31 | public class JarSecurityFileSelector implements FileSelector {
32 | public static final String[] SECURITY_FILE_PATTERNS = {
33 | "META-INF/*.RSA",
34 | "META-INF/*.DSA",
35 | "META-INF/*.SF",
36 | "META-INF/*.EC",
37 | "META-INF/*.rsa",
38 | "META-INF/*.dsa",
39 | "META-INF/*.sf",
40 | "META-INF/*.ec"
41 | };
42 |
43 | @Override
44 | public boolean isSelected(@Nonnull FileInfo fileInfo) throws IOException {
45 | String name = fileInfo.getName();
46 |
47 | for (String pattern : SECURITY_FILE_PATTERNS) {
48 | if (SelectorUtils.match(pattern, name)) {
49 | return false;
50 | }
51 | }
52 |
53 | return true;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zstd/PlexusIoZstdResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.zstd;
17 |
18 | import javax.inject.Named;
19 |
20 | import java.io.File;
21 | import java.io.IOException;
22 | import java.io.InputStream;
23 |
24 | import org.codehaus.plexus.archiver.util.Streams;
25 | import org.codehaus.plexus.components.io.attributes.FileAttributes;
26 | import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
27 | import org.codehaus.plexus.components.io.resources.PlexusIoCompressedFileResourceCollection;
28 |
29 | /**
30 | * Implementation of {@link org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection} for
31 | * zstd compressed files.
32 | */
33 | @Named("zst")
34 | public class PlexusIoZstdResourceCollection extends PlexusIoCompressedFileResourceCollection {
35 |
36 | @Override
37 | protected PlexusIoResourceAttributes getAttributes(File file) throws IOException {
38 | return new FileAttributes(file);
39 | }
40 |
41 | @Override
42 | protected String getDefaultExtension() {
43 | return ".zst";
44 | }
45 |
46 | @Override
47 | protected InputStream getInputStream(File file) throws IOException {
48 | return ZstdUnArchiver.getZstdInputStream(Streams.fileInputStream(file));
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zip/DeferredScatterOutputStream.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one or more
3 | * contributor license agreements. See the NOTICE file distributed with
4 | * this work for additional information regarding copyright ownership.
5 | * The ASF licenses this file to You under the Apache License, Version 2.0
6 | * (the "License"); you may not use this file except in compliance with
7 | * the License. You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | *
17 | */
18 | package org.codehaus.plexus.archiver.zip;
19 |
20 | import java.io.File;
21 | import java.io.IOException;
22 | import java.io.InputStream;
23 |
24 | import org.apache.commons.compress.parallel.ScatterGatherBackingStore;
25 |
26 | public class DeferredScatterOutputStream implements ScatterGatherBackingStore {
27 |
28 | private final OffloadingOutputStream dfos;
29 |
30 | public DeferredScatterOutputStream(int threshold) {
31 | dfos = new OffloadingOutputStream(threshold, "scatterzipfragment", "zip");
32 | }
33 |
34 | @Override
35 | public InputStream getInputStream() throws IOException {
36 | return dfos.getInputStream();
37 | }
38 |
39 | @Override
40 | public void writeOut(byte[] data, int offset, int length) throws IOException {
41 | dfos.write(data, offset, length);
42 | }
43 |
44 | @Override
45 | public void closeForWriting() throws IOException {
46 | dfos.close();
47 | }
48 |
49 | @Override
50 | public void close() throws IOException {
51 | File file = dfos.getFile();
52 | if (file != null) {
53 | file.delete();
54 | }
55 | }
56 | }
57 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/DotDirectiveArchiveFinalizerTest.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.io.File;
4 | import java.util.jar.JarFile;
5 |
6 | import org.codehaus.plexus.archiver.jar.JarArchiver;
7 | import org.junit.jupiter.api.Test;
8 |
9 | import static org.junit.jupiter.api.Assertions.assertNotNull;
10 |
11 | /**
12 | * @author Jason van Zyl
13 | */
14 | class DotDirectiveArchiveFinalizerTest extends TestSupport {
15 |
16 | @Test
17 | void dotDirectiveArchiveFinalizer() throws Exception {
18 | DotDirectiveArchiveFinalizer ddaf =
19 | new DotDirectiveArchiveFinalizer(new File(getBasedir(), "src/test/dotfiles"));
20 |
21 | JarArchiver archiver = new JarArchiver();
22 |
23 | File jarFile = new File(getBasedir(), "target/dotfiles.jar");
24 |
25 | archiver.setDestFile(jarFile);
26 |
27 | archiver.addArchiveFinalizer(ddaf);
28 |
29 | archiver.createArchive();
30 |
31 | JarFile jar = new JarFile(jarFile);
32 |
33 | assertNotNull(jar.getEntry("LICENSE.txt"));
34 |
35 | assertNotNull(jar.getEntry("NOTICE.txt"));
36 |
37 | assertNotNull(jar.getEntry("META-INF/maven/LICENSE.txt"));
38 |
39 | assertNotNull(jar.getEntry("META-INF/maven/NOTICE.txt"));
40 | }
41 |
42 | @Test
43 | void defaultDotDirectiveBehaviour() throws Exception {
44 | File dotFileDirectory = new File(getBasedir(), "src/test/dotfiles");
45 |
46 | JarArchiver archiver = new JarArchiver();
47 |
48 | archiver.setDotFileDirectory(dotFileDirectory);
49 |
50 | File jarFile = new File(getBasedir(), "target/default-dotfiles.jar");
51 |
52 | archiver.setDestFile(jarFile);
53 |
54 | archiver.createArchive();
55 |
56 | JarFile jar = new JarFile(jarFile);
57 |
58 | assertNotNull(jar.getEntry("LICENSE.txt"));
59 |
60 | assertNotNull(jar.getEntry("NOTICE.txt"));
61 |
62 | assertNotNull(jar.getEntry("META-INF/maven/LICENSE.txt"));
63 |
64 | assertNotNull(jar.getEntry("META-INF/maven/NOTICE.txt"));
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/BaseFileSet.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import javax.annotation.CheckForNull;
4 |
5 | import org.codehaus.plexus.components.io.filemappers.FileMapper;
6 | import org.codehaus.plexus.components.io.fileselectors.FileSelector;
7 | import org.codehaus.plexus.components.io.functions.InputStreamTransformer;
8 |
9 | /**
10 | * A file set is a set of files, which may be added to an
11 | * archive.
12 | *
13 | * @since 1.0-alpha-9
14 | */
15 | public interface BaseFileSet {
16 |
17 | /**
18 | * Returns the prefix, which the file sets contents shall
19 | * have.
20 | */
21 | @CheckForNull
22 | String getPrefix();
23 |
24 | /**
25 | * Returns a string of patterns, which included files
26 | * should match.
27 | */
28 | @CheckForNull
29 | String[] getIncludes();
30 |
31 | /**
32 | * Returns a string of patterns, which excluded files
33 | * should match.
34 | */
35 | @CheckForNull
36 | String[] getExcludes();
37 |
38 | /**
39 | * Returns, whether the include/exclude patterns are
40 | * case-sensitive.
41 | */
42 | boolean isCaseSensitive();
43 |
44 | /**
45 | * Returns, whether the default excludes are being
46 | * applied.
47 | */
48 | boolean isUsingDefaultExcludes();
49 |
50 | /**
51 | * Returns, whether empty directories are being included.
52 | */
53 | boolean isIncludingEmptyDirectories();
54 |
55 | /**
56 | * Returns a set of file selectors, which should be used
57 | * to select the included files.
58 | */
59 | @CheckForNull
60 | FileSelector[] getFileSelectors();
61 |
62 | /**
63 | * Returns the InputStreamTransformers that can be applied to this fileset
64 | *
65 | * @return The transformers.
66 | */
67 | InputStreamTransformer getStreamTransformer();
68 |
69 | /**
70 | * Returns a set of file mappers, which should be used
71 | * to change the filename of the included files.
72 | */
73 | @CheckForNull
74 | FileMapper[] getFileMappers();
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/manager/ArchiverManager.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001,2004 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.codehaus.plexus.archiver.manager;
18 |
19 | import javax.annotation.Nonnull;
20 |
21 | import java.io.File;
22 | import java.util.Collection;
23 |
24 | import org.codehaus.plexus.archiver.Archiver;
25 | import org.codehaus.plexus.archiver.UnArchiver;
26 | import org.codehaus.plexus.components.io.resources.PlexusIoResourceCollection;
27 |
28 | /**
29 | * @author dantran
30 | */
31 | public interface ArchiverManager {
32 | @Nonnull
33 | Archiver getArchiver(@Nonnull String archiverName) throws NoSuchArchiverException;
34 |
35 | @Nonnull
36 | Archiver getArchiver(@Nonnull File file) throws NoSuchArchiverException;
37 |
38 | @Nonnull
39 | Collection getAvailableArchivers();
40 |
41 | @Nonnull
42 | UnArchiver getUnArchiver(@Nonnull String unArchiverName) throws NoSuchArchiverException;
43 |
44 | @Nonnull
45 | UnArchiver getUnArchiver(@Nonnull File file) throws NoSuchArchiverException;
46 |
47 | @Nonnull
48 | Collection getAvailableUnArchivers();
49 |
50 | @Nonnull
51 | PlexusIoResourceCollection getResourceCollection(@Nonnull File file) throws NoSuchArchiverException;
52 |
53 | @Nonnull
54 | PlexusIoResourceCollection getResourceCollection(String unArchiverName) throws NoSuchArchiverException;
55 |
56 | @Nonnull
57 | Collection getAvailableResourceCollections();
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/xz/XZCompressor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.xz;
17 |
18 | import java.io.IOException;
19 |
20 | import org.apache.commons.compress.compressors.xz.XZCompressorOutputStream;
21 | import org.codehaus.plexus.archiver.ArchiverException;
22 | import org.codehaus.plexus.archiver.util.Compressor;
23 |
24 | import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
25 | import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
26 |
27 | /**
28 | * @author philip.lourandos
29 | * @since 3.3
30 | */
31 | public class XZCompressor extends Compressor {
32 |
33 | private XZCompressorOutputStream xzOut;
34 |
35 | public XZCompressor() {}
36 |
37 | @Override
38 | public void compress() throws ArchiverException {
39 | try {
40 | xzOut = new XZCompressorOutputStream(bufferedOutputStream(fileOutputStream(getDestFile())));
41 | compress(getSource(), xzOut);
42 | } catch (IOException ioe) {
43 | throw new ArchiverException("Problem creating xz " + ioe.getMessage(), ioe);
44 | }
45 | }
46 |
47 | @Override
48 | public void close() {
49 | try {
50 | if (this.xzOut != null) {
51 | this.xzOut.close();
52 | xzOut = null;
53 | }
54 | } catch (final IOException e) {
55 | throw new ArchiverException("Failure closing target.", e);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/gzip/GZipCompressor.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.gzip;
18 |
19 | import java.io.IOException;
20 | import java.io.OutputStream;
21 | import java.util.zip.GZIPOutputStream;
22 |
23 | import org.codehaus.plexus.archiver.ArchiverException;
24 | import org.codehaus.plexus.archiver.util.Compressor;
25 |
26 | import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
27 | import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
28 |
29 | public class GZipCompressor extends Compressor {
30 |
31 | private OutputStream zOut;
32 |
33 | /**
34 | * perform the GZip compression operation.
35 | */
36 | @Override
37 | public void compress() throws ArchiverException {
38 | try {
39 | zOut = bufferedOutputStream(new GZIPOutputStream(fileOutputStream(getDestFile())));
40 | compress(getSource(), zOut);
41 | } catch (IOException ioe) {
42 | String msg = "Problem creating gzip " + ioe.getMessage();
43 | throw new ArchiverException(msg, ioe);
44 | }
45 | }
46 |
47 | @Override
48 | public void close() {
49 | try {
50 | if (this.zOut != null) {
51 | this.zOut.close();
52 | zOut = null;
53 | }
54 | } catch (final IOException e) {
55 | throw new ArchiverException("Failure closing target.", e);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarLongFileMode.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2000-2004 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | /**
20 | * Set of options for long file handling in the task.
21 | */
22 | public enum TarLongFileMode {
23 | warn,
24 | fail,
25 | truncate,
26 | gnu,
27 | omit,
28 | posix,
29 | posix_warn;
30 |
31 | /**
32 | * @return true if value is "truncate".
33 | */
34 | public boolean isTruncateMode() {
35 | return truncate.equals(this);
36 | }
37 |
38 | /**
39 | * @return true if value is "warn".
40 | */
41 | public boolean isWarnMode() {
42 | return warn.equals(this);
43 | }
44 |
45 | /**
46 | * @return true if value is "gnu".
47 | */
48 | public boolean isGnuMode() {
49 | return gnu.equals(this);
50 | }
51 |
52 | /**
53 | * @return true if value is "fail".
54 | */
55 | public boolean isFailMode() {
56 | return fail.equals(this);
57 | }
58 |
59 | /**
60 | * @return true if value is "omit".
61 | */
62 | public boolean isOmitMode() {
63 | return omit.equals(this);
64 | }
65 |
66 | /**
67 | * @return true if value is "posix".
68 | */
69 | public boolean isPosixMode() {
70 | return posix.equals(this);
71 | }
72 |
73 | /**
74 | * @return true if value is "posix_warn".
75 | */
76 | public boolean isPosixWarnMode() {
77 | return posix_warn.equals(this);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/UnixStat.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2001,2004 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.codehaus.plexus.archiver;
18 |
19 | /**
20 | * Constants from stat.h on Unix systems.
21 | *
22 | * from org.apache.ant.tools.zip.UnixStat v1.9
23 | */
24 | public interface UnixStat {
25 |
26 | /**
27 | * Bits used for permissions (and sticky bit)
28 | *
29 | * @since 1.1
30 | */
31 | int PERM_MASK = 0_7777;
32 |
33 | /**
34 | * Indicates symbolic links.
35 | *
36 | * @since 1.1
37 | */
38 | int LINK_FLAG = 0_120000;
39 |
40 | /**
41 | * Indicates plain files.
42 | *
43 | * @since 1.1
44 | */
45 | int FILE_FLAG = 0_100000;
46 |
47 | /**
48 | * Indicates directories.
49 | *
50 | * @since 1.1
51 | */
52 | int DIR_FLAG = 0_40000;
53 |
54 | // ----------------------------------------------------------
55 | // somewhat arbitrary choices that are quite common for shared
56 | // installations
57 | // -----------------------------------------------------------
58 | /**
59 | * Default permissions for symbolic links.
60 | *
61 | * @since 1.1
62 | */
63 | int DEFAULT_LINK_PERM = 0_777;
64 |
65 | /**
66 | * Default permissions for directories.
67 | *
68 | * @since 1.1
69 | */
70 | int DEFAULT_DIR_PERM = 0_755;
71 |
72 | /**
73 | * Default permissions for plain files.
74 | *
75 | * @since 1.1
76 | */
77 | int DEFAULT_FILE_PERM = 0_644;
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/snappy/SnappyCompressor.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.snappy;
18 |
19 | import java.io.IOException;
20 |
21 | import io.airlift.compress.snappy.SnappyFramedOutputStream;
22 | import org.codehaus.plexus.archiver.ArchiverException;
23 | import org.codehaus.plexus.archiver.util.Compressor;
24 |
25 | import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
26 | import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
27 |
28 | /**
29 | * Snappy compression
30 | */
31 | public class SnappyCompressor extends Compressor {
32 |
33 | private SnappyFramedOutputStream zOut;
34 |
35 | /**
36 | * perform the Snappy compression operation.
37 | */
38 | @Override
39 | public void compress() throws ArchiverException {
40 | try {
41 | zOut = new SnappyFramedOutputStream(bufferedOutputStream(fileOutputStream(getDestFile())));
42 | compress(getSource(), zOut);
43 | } catch (IOException ioe) {
44 | String msg = "Problem creating snappy " + ioe.getMessage();
45 | throw new ArchiverException(msg, ioe);
46 | }
47 | }
48 |
49 | @Override
50 | public void close() {
51 | try {
52 | if (this.zOut != null) {
53 | this.zOut.close();
54 | zOut = null;
55 | }
56 | } catch (final IOException e) {
57 | throw new ArchiverException("Failure closing target.", e);
58 | }
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/bzip2/BZip2Compressor.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.bzip2;
18 |
19 | import java.io.IOException;
20 |
21 | import org.apache.commons.compress.compressors.bzip2.BZip2CompressorOutputStream;
22 | import org.codehaus.plexus.archiver.ArchiverException;
23 | import org.codehaus.plexus.archiver.util.Compressor;
24 |
25 | import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
26 | import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
27 |
28 | public class BZip2Compressor extends Compressor {
29 |
30 | private BZip2CompressorOutputStream zOut;
31 |
32 | /**
33 | * perform the BZip2 compression operation.
34 | */
35 | @Override
36 | public void compress() throws ArchiverException {
37 | try {
38 | zOut = new BZip2CompressorOutputStream(bufferedOutputStream(fileOutputStream(getDestFile())));
39 | // BUffering of the source stream seems to have little/no impact
40 | compress(getSource(), zOut);
41 | } catch (IOException ioe) {
42 | String msg = "Problem creating bzip2 " + ioe.getMessage();
43 | throw new ArchiverException(msg, ioe);
44 | }
45 | }
46 |
47 | @Override
48 | public void close() {
49 | try {
50 | if (this.zOut != null) {
51 | this.zOut.close();
52 | zOut = null;
53 | }
54 | } catch (final IOException e) {
55 | throw new ArchiverException("Failure closing target.", e);
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/gzip/GZipArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.gzip;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.IOException;
22 |
23 | import org.codehaus.plexus.archiver.AbstractArchiver;
24 | import org.codehaus.plexus.archiver.ArchiveEntry;
25 | import org.codehaus.plexus.archiver.ArchiverException;
26 | import org.codehaus.plexus.archiver.ResourceIterator;
27 | import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
28 |
29 | @Named("gzip")
30 | public class GZipArchiver extends AbstractArchiver {
31 |
32 | final GZipCompressor compressor = new GZipCompressor();
33 |
34 | @Override
35 | protected void execute() throws ArchiverException, IOException {
36 | if (!checkForced()) {
37 | return;
38 | }
39 |
40 | ResourceIterator iter = getResources();
41 | if (!iter.hasNext()) {
42 | throw new EmptyArchiveException("archive cannot be empty");
43 | }
44 | ArchiveEntry entry = iter.next();
45 | if (iter.hasNext()) {
46 | throw new ArchiverException("There is more than one file in input.");
47 | }
48 | compressor.setSource(entry.getResource());
49 | compressor.setDestFile(getDestFile());
50 | compressor.compress();
51 | }
52 |
53 | @Override
54 | public boolean isSupportingForced() {
55 | return true;
56 | }
57 |
58 | @Override
59 | protected void close() {
60 | compressor.close();
61 | }
62 |
63 | @Override
64 | protected String getArchiveType() {
65 | return "gzip";
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/bzip2/BZip2Archiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.bzip2;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.IOException;
22 |
23 | import org.codehaus.plexus.archiver.AbstractArchiver;
24 | import org.codehaus.plexus.archiver.ArchiveEntry;
25 | import org.codehaus.plexus.archiver.ArchiverException;
26 | import org.codehaus.plexus.archiver.ResourceIterator;
27 | import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
28 |
29 | @Named("bzip2")
30 | public class BZip2Archiver extends AbstractArchiver {
31 |
32 | private final BZip2Compressor compressor = new BZip2Compressor();
33 |
34 | @Override
35 | public void execute() throws ArchiverException, IOException {
36 | if (!checkForced()) {
37 | return;
38 | }
39 |
40 | ResourceIterator iter = getResources();
41 | if (!iter.hasNext()) {
42 | throw new EmptyArchiveException("archive cannot be empty");
43 | }
44 | ArchiveEntry entry = iter.next();
45 | if (iter.hasNext()) {
46 | throw new ArchiverException("There is more than one file in input.");
47 | }
48 | compressor.setSource(entry.getResource());
49 | compressor.setDestFile(getDestFile());
50 | compressor.compress();
51 | }
52 |
53 | @Override
54 | public boolean isSupportingForced() {
55 | return true;
56 | }
57 |
58 | @Override
59 | protected void close() {
60 | compressor.close();
61 | }
62 |
63 | @Override
64 | protected String getArchiveType() {
65 | return "bzip2";
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/snappy/SnappyArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.snappy;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.IOException;
22 |
23 | import org.codehaus.plexus.archiver.AbstractArchiver;
24 | import org.codehaus.plexus.archiver.ArchiveEntry;
25 | import org.codehaus.plexus.archiver.ArchiverException;
26 | import org.codehaus.plexus.archiver.ResourceIterator;
27 | import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
28 |
29 | /**
30 | * Snappy archiver.
31 | */
32 | @Named("snappy")
33 | public class SnappyArchiver extends AbstractArchiver {
34 |
35 | private final SnappyCompressor compressor = new SnappyCompressor();
36 |
37 | @Override
38 | public void execute() throws ArchiverException, IOException {
39 | if (!checkForced()) {
40 | return;
41 | }
42 |
43 | ResourceIterator iter = getResources();
44 | if (!iter.hasNext()) {
45 | throw new EmptyArchiveException("archive cannot be empty");
46 | }
47 | ArchiveEntry entry = iter.next();
48 | if (iter.hasNext()) {
49 | throw new ArchiverException("There is more than one file in input.");
50 | }
51 | compressor.setSource(entry.getResource());
52 | compressor.setDestFile(getDestFile());
53 | compressor.compress();
54 | }
55 |
56 | @Override
57 | public boolean isSupportingForced() {
58 | return true;
59 | }
60 |
61 | @Override
62 | protected void close() {
63 | compressor.close();
64 | }
65 |
66 | @Override
67 | protected String getArchiveType() {
68 | return "snappy";
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/xz/XZArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.xz;
17 |
18 | import javax.inject.Named;
19 |
20 | import java.io.IOException;
21 |
22 | import org.codehaus.plexus.archiver.AbstractArchiver;
23 | import org.codehaus.plexus.archiver.ArchiveEntry;
24 | import org.codehaus.plexus.archiver.ArchiverException;
25 | import org.codehaus.plexus.archiver.ResourceIterator;
26 | import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
27 |
28 | /**
29 | * @author philiplourandos
30 | * @since 3.3
31 | */
32 | @Named("xz")
33 | public class XZArchiver extends AbstractArchiver {
34 |
35 | private final XZCompressor compressor = new XZCompressor();
36 |
37 | public XZArchiver() {}
38 |
39 | @Override
40 | protected void execute() throws ArchiverException, IOException {
41 | if (!checkForced()) {
42 | return;
43 | }
44 |
45 | ResourceIterator iter = getResources();
46 | if (!iter.hasNext()) {
47 | throw new EmptyArchiveException("archive cannot be empty");
48 | }
49 | ArchiveEntry entry = iter.next();
50 | if (iter.hasNext()) {
51 | throw new ArchiverException("There is more than one file in input.");
52 | }
53 | compressor.setSource(entry.getResource());
54 | compressor.setDestFile(getDestFile());
55 | compressor.compress();
56 | }
57 |
58 | @Override
59 | public boolean isSupportingForced() {
60 | return true;
61 | }
62 |
63 | @Override
64 | protected void close() throws IOException {
65 | compressor.close();
66 | }
67 |
68 | @Override
69 | protected String getArchiveType() {
70 | return "xz";
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/TarResource.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import javax.annotation.Nonnull;
4 |
5 | import java.io.IOException;
6 | import java.io.InputStream;
7 | import java.net.URL;
8 |
9 | import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
10 | import org.codehaus.plexus.components.io.attributes.PlexusIoResourceAttributes;
11 | import org.codehaus.plexus.components.io.attributes.SimpleResourceAttributes;
12 | import org.codehaus.plexus.components.io.functions.ResourceAttributeSupplier;
13 | import org.codehaus.plexus.components.io.resources.AbstractPlexusIoResource;
14 | import org.codehaus.plexus.components.io.resources.PlexusIoResource;
15 |
16 | public class TarResource extends AbstractPlexusIoResource implements ResourceAttributeSupplier {
17 |
18 | private final TarFile tarFile;
19 |
20 | private final TarArchiveEntry entry;
21 |
22 | private PlexusIoResourceAttributes attributes;
23 |
24 | public TarResource(TarFile tarFile, TarArchiveEntry entry) {
25 | super(
26 | entry.getName(),
27 | getLastModifiedTime(entry),
28 | entry.isDirectory() ? PlexusIoResource.UNKNOWN_RESOURCE_SIZE : entry.getSize(),
29 | !entry.isDirectory(),
30 | entry.isDirectory(),
31 | true);
32 |
33 | this.tarFile = tarFile;
34 | this.entry = entry;
35 | }
36 |
37 | private static long getLastModifiedTime(TarArchiveEntry entry) {
38 | long l = entry.getModTime().getTime();
39 | return l == -1 ? PlexusIoResource.UNKNOWN_MODIFICATION_DATE : l;
40 | }
41 |
42 | @Override
43 | public synchronized PlexusIoResourceAttributes getAttributes() {
44 | if (attributes == null) {
45 | attributes = new SimpleResourceAttributes(
46 | entry.getUserId(), entry.getUserName(), entry.getGroupId(), entry.getGroupName(), entry.getMode());
47 | }
48 |
49 | return attributes;
50 | }
51 |
52 | public synchronized void setAttributes(PlexusIoResourceAttributes attributes) {
53 | this.attributes = attributes;
54 | }
55 |
56 | @Override
57 | public URL getURL() throws IOException {
58 | return null;
59 | }
60 |
61 | @Nonnull
62 | @Override
63 | public InputStream getContents() throws IOException {
64 | return tarFile.getInputStream(entry);
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/util/ArchiveEntryUtils.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2014 The Codehaus Foundation.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.util;
17 |
18 | import java.io.File;
19 | import java.io.IOException;
20 |
21 | import org.codehaus.plexus.archiver.ArchiverException;
22 | import org.codehaus.plexus.components.io.attributes.AttributeUtils;
23 | import org.codehaus.plexus.util.Os;
24 | import org.slf4j.Logger;
25 |
26 | @SuppressWarnings("JavaDoc")
27 | public final class ArchiveEntryUtils {
28 |
29 | private ArchiveEntryUtils() {
30 | // no op
31 | }
32 |
33 | /**
34 | * This method is now deprecated.
35 | *
36 | * The {@code useJvmChmod} flag is ignored as the JVM is always used.
37 | * The {@code logger} provided is no longer used.
38 | *
39 | * @deprecated Use {@link #chmod(File, int)}
40 | */
41 | @Deprecated
42 | public static void chmod(final File file, final int mode, final Logger logger, boolean useJvmChmod)
43 | throws ArchiverException {
44 | chmod(file, mode);
45 | }
46 |
47 | /**
48 | * This method is now deprecated.
49 | *
50 | * The {@code logger} provided is no longer used.
51 | *
52 | * @deprecated Use {@link #chmod(File, int)}
53 | */
54 | @Deprecated
55 | public static void chmod(final File file, final int mode, final Logger logger) throws ArchiverException {
56 | chmod(file, mode);
57 | }
58 |
59 | public static void chmod(final File file, final int mode) throws ArchiverException {
60 | if (!Os.isFamily(Os.FAMILY_UNIX)) {
61 | return;
62 | }
63 |
64 | try {
65 | AttributeUtils.chmod(file, mode);
66 | } catch (IOException e) {
67 | throw new ArchiverException("Failed setting file attributes", e);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zstd/ZstdArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.zstd;
17 |
18 | import javax.inject.Named;
19 |
20 | import java.io.IOException;
21 |
22 | import org.codehaus.plexus.archiver.AbstractArchiver;
23 | import org.codehaus.plexus.archiver.ArchiveEntry;
24 | import org.codehaus.plexus.archiver.ArchiverException;
25 | import org.codehaus.plexus.archiver.ResourceIterator;
26 | import org.codehaus.plexus.archiver.exceptions.EmptyArchiveException;
27 |
28 | /**
29 | * Zstd archiver.
30 | */
31 | @Named("zst")
32 | public class ZstdArchiver extends AbstractArchiver {
33 |
34 | private final ZstdCompressor compressor = new ZstdCompressor();
35 |
36 | public ZstdArchiver() {}
37 |
38 | /**
39 | * Set compression level
40 | */
41 | public void setLevel(Integer level) throws ArchiverException {
42 | compressor.setLevel(level);
43 | }
44 |
45 | @Override
46 | protected void execute() throws ArchiverException, IOException {
47 | if (!checkForced()) {
48 | return;
49 | }
50 |
51 | ResourceIterator iter = getResources();
52 | if (!iter.hasNext()) {
53 | throw new EmptyArchiveException("archive cannot be empty");
54 | }
55 | ArchiveEntry entry = iter.next();
56 | if (iter.hasNext()) {
57 | throw new ArchiverException("There is more than one file in input.");
58 | }
59 | compressor.setSource(entry.getResource());
60 | compressor.setDestFile(getDestFile());
61 | compressor.compress();
62 | }
63 |
64 | @Override
65 | public boolean isSupportingForced() {
66 | return true;
67 | }
68 |
69 | @Override
70 | protected void close() throws IOException {
71 | compressor.close();
72 | }
73 |
74 | @Override
75 | protected String getArchiveType() {
76 | return "zstd";
77 | }
78 | }
79 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zstd/ZstdCompressor.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.zstd;
17 |
18 | import java.io.BufferedOutputStream;
19 | import java.io.IOException;
20 |
21 | import org.apache.commons.compress.compressors.zstandard.ZstdCompressorOutputStream;
22 | import org.codehaus.plexus.archiver.ArchiverException;
23 | import org.codehaus.plexus.archiver.util.Compressor;
24 |
25 | import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
26 | import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
27 |
28 | /**
29 | * Zstd compression
30 | */
31 | public class ZstdCompressor extends Compressor {
32 |
33 | private Integer level;
34 |
35 | private ZstdCompressorOutputStream zstdOut;
36 |
37 | public ZstdCompressor() {}
38 |
39 | public void setLevel(Integer level) {
40 | this.level = level;
41 | }
42 |
43 | @Override
44 | public void compress() throws ArchiverException {
45 | try {
46 | BufferedOutputStream outStream = bufferedOutputStream(fileOutputStream(getDestFile()));
47 | ZstdCompressorOutputStream.Builder zstdOutBuilder = ZstdCompressorOutputStream.builder();
48 | zstdOutBuilder.setOutputStream(outStream);
49 | if (level != null) {
50 | zstdOutBuilder.setLevel(level);
51 | }
52 | zstdOut = zstdOutBuilder.get();
53 | compress(getSource(), zstdOut);
54 | } catch (IOException ioe) {
55 | throw new ArchiverException("Problem creating zstd " + ioe.getMessage(), ioe);
56 | }
57 | }
58 |
59 | @Override
60 | public void close() {
61 | try {
62 | if (this.zstdOut != null) {
63 | this.zstdOut.close();
64 | zstdOut = null;
65 | }
66 | } catch (final IOException e) {
67 | throw new ArchiverException("Failure closing target.", e);
68 | }
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/tar/TarRoundTripTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2003-2004 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | *
16 | */
17 | package org.codehaus.plexus.archiver.tar;
18 |
19 | import java.io.ByteArrayInputStream;
20 | import java.io.ByteArrayOutputStream;
21 |
22 | import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
23 | import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
24 | import org.apache.commons.compress.archivers.tar.TarArchiveOutputStream;
25 | import org.junit.jupiter.api.Test;
26 |
27 | import static org.junit.jupiter.api.Assertions.assertEquals;
28 | import static org.junit.jupiter.api.Assertions.assertNull;
29 | import static org.junit.jupiter.api.Assertions.assertTrue;
30 |
31 | /**
32 | * from org.apache.ant.tools.tar.TarRoundTripTest v1.6
33 | */
34 | class TarRoundTripTest {
35 |
36 | private static final String LONG_NAME = "this/path/name/contains/more/than/one/hundred/characters/in/order/"
37 | + "to/test/the/GNU/long/file/name/capability/round/tripped";
38 |
39 | /**
40 | * test round-tripping long (GNU) entries
41 | */
42 | @Test
43 | void longRoundTripping() throws Exception {
44 | TarArchiveEntry original = new TarArchiveEntry(LONG_NAME);
45 | assertTrue(LONG_NAME.length() > 100, "over 100 chars");
46 | assertEquals(LONG_NAME, original.getName(), "original name");
47 |
48 | ByteArrayOutputStream buff = new ByteArrayOutputStream();
49 | TarArchiveOutputStream tos = new TarArchiveOutputStream(buff);
50 | tos.setLongFileMode(TarArchiveOutputStream.LONGFILE_GNU);
51 | tos.putArchiveEntry(original);
52 | tos.closeArchiveEntry();
53 | tos.close();
54 |
55 | TarArchiveInputStream tis = new TarArchiveInputStream(new ByteArrayInputStream(buff.toByteArray()));
56 | TarArchiveEntry tripped = tis.getNextEntry();
57 | assertEquals(LONG_NAME, tripped.getName(), "round-tripped name");
58 | assertNull(tis.getNextEntry(), "no more entries");
59 | tis.close();
60 | }
61 | }
62 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/zip/PlexusArchiverZipFileResourceCollectionTest.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.zip;
2 |
3 | import java.io.File;
4 | import java.io.InputStream;
5 | import java.util.HashMap;
6 | import java.util.HashSet;
7 | import java.util.Iterator;
8 | import java.util.Map;
9 | import java.util.Set;
10 |
11 | import org.codehaus.plexus.archiver.TestSupport;
12 | import org.codehaus.plexus.components.io.functions.ResourceAttributeSupplier;
13 | import org.codehaus.plexus.components.io.resources.PlexusIoResource;
14 | import org.junit.jupiter.api.Test;
15 |
16 | import static org.junit.jupiter.api.Assertions.assertEquals;
17 | import static org.junit.jupiter.api.Assertions.assertTrue;
18 |
19 | class PlexusArchiverZipFileResourceCollectionTest extends TestSupport {
20 |
21 | @Test
22 | void filesWithIllegalHtmlChars() throws Exception {
23 | File testZip = new File(getBasedir(), "src/test/resources/archiveWithIllegalHtmlFileName.zip");
24 | Set seen = new HashSet<>();
25 | seen.add("AFileThatNeedsHtmlEsc%3F>");
26 | seen.add("Afile<Yo>.txt");
27 | seen.add("File With Space.txt");
28 | seen.add("FileWith%.txt");
29 | PlexusArchiverZipFileResourceCollection prc = new PlexusArchiverZipFileResourceCollection();
30 | prc.setFile(testZip);
31 | final Iterator entries = prc.getEntries();
32 | while (entries.hasNext()) {
33 | final PlexusIoResource next = entries.next();
34 | assertTrue(seen.remove(next.getName()), next.getName() + "was not present");
35 | final InputStream contents = next.getContents();
36 | contents.close();
37 | }
38 | }
39 |
40 | @Test
41 | void fileModes() throws Exception {
42 | File testZip = new File(getBasedir(), "src/test/resources/zeroFileMode/mixed-file-mode.zip");
43 | Map originalUnixModes = new HashMap<>();
44 | originalUnixModes.put("platform-fat", -1);
45 | originalUnixModes.put("zero-unix-mode", 0);
46 | // ---xrw-r-- the crazy permissions are on purpose so we don't hit some default value
47 | originalUnixModes.put("non-zero-unix-mode", 0164);
48 | PlexusArchiverZipFileResourceCollection prc = new PlexusArchiverZipFileResourceCollection();
49 | prc.setFile(testZip);
50 | Iterator entries = prc.getEntries();
51 | while (entries.hasNext()) {
52 | PlexusIoResource entry = entries.next();
53 | int entryUnixMode =
54 | ((ResourceAttributeSupplier) entry).getAttributes().getOctalMode();
55 | int originalUnixMode = originalUnixModes.get(entry.getName());
56 | assertEquals(originalUnixMode, entryUnixMode);
57 | }
58 | }
59 | }
60 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/gzip/GZipUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.gzip;
18 |
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 | import java.io.IOException;
23 | import java.io.InputStream;
24 | import java.util.zip.GZIPInputStream;
25 |
26 | import org.codehaus.plexus.archiver.AbstractUnArchiver;
27 | import org.codehaus.plexus.archiver.ArchiverException;
28 | import org.codehaus.plexus.archiver.util.Streams;
29 |
30 | import static org.codehaus.plexus.archiver.util.Streams.copyFully;
31 | import static org.codehaus.plexus.archiver.util.Streams.fileInputStream;
32 | import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
33 |
34 | /**
35 | * @author Emmanuel Venisse
36 | */
37 | @Named("gzip")
38 | public class GZipUnArchiver extends AbstractUnArchiver {
39 |
40 | private static final String OPERATION_GZIP = "gzip";
41 |
42 | public GZipUnArchiver() {}
43 |
44 | public GZipUnArchiver(File sourceFile) {
45 | super(sourceFile);
46 | }
47 |
48 | @Override
49 | protected void execute() throws ArchiverException {
50 | if (getSourceFile().lastModified() > getDestFile().lastModified()) {
51 | getLogger()
52 | .info("Expanding " + getSourceFile().getAbsolutePath() + " to "
53 | + getDestFile().getAbsolutePath());
54 |
55 | copyFully(
56 | getGzipInputStream(fileInputStream(getSourceFile(), OPERATION_GZIP)),
57 | fileOutputStream(getDestFile(), OPERATION_GZIP),
58 | OPERATION_GZIP);
59 | }
60 | }
61 |
62 | private InputStream getGzipInputStream(InputStream in) throws ArchiverException {
63 | try {
64 | return Streams.bufferedInputStream(new GZIPInputStream(in));
65 | } catch (IOException e) {
66 | throw new ArchiverException("Problem creating GZIP input stream", e);
67 | }
68 | }
69 |
70 | @Override
71 | protected void execute(String path, File outputDirectory) {
72 | throw new UnsupportedOperationException("Targeted extraction not supported in GZIP format.");
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/util/FilePermission.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.codehaus.plexus.archiver.util;
20 |
21 | /**
22 | * @author Olivier Lamy
23 | * @since 1.1
24 | *
25 | */
26 | public class FilePermission {
27 |
28 | private final boolean executable;
29 |
30 | private final boolean ownerOnlyExecutable;
31 |
32 | private final boolean ownerOnlyReadable;
33 |
34 | private final boolean readable;
35 |
36 | private final boolean ownerOnlyWritable;
37 |
38 | private final boolean writable;
39 |
40 | public FilePermission(
41 | boolean executable,
42 | boolean ownerOnlyExecutable,
43 | boolean ownerOnlyReadable,
44 | boolean readable,
45 | boolean ownerOnlyWritable,
46 | boolean writable) {
47 | this.executable = executable;
48 | this.ownerOnlyExecutable = ownerOnlyExecutable;
49 | this.ownerOnlyReadable = ownerOnlyReadable;
50 | this.readable = readable;
51 | this.ownerOnlyWritable = ownerOnlyWritable;
52 | this.writable = writable;
53 | }
54 |
55 | public boolean isExecutable() {
56 | return executable;
57 | }
58 |
59 | public boolean isOwnerOnlyExecutable() {
60 | return ownerOnlyExecutable;
61 | }
62 |
63 | public boolean isOwnerOnlyReadable() {
64 | return ownerOnlyReadable;
65 | }
66 |
67 | public boolean isReadable() {
68 | return readable;
69 | }
70 |
71 | public boolean isOwnerOnlyWritable() {
72 | return ownerOnlyWritable;
73 | }
74 |
75 | public boolean isWritable() {
76 | return writable;
77 | }
78 |
79 | @Override
80 | public String toString() {
81 | return "FilePermission [executable=" + executable + ", ownerOnlyExecutable=" + ownerOnlyExecutable
82 | + ", ownerOnlyReadable=" + ownerOnlyReadable + ", readable=" + readable + ", ownerOnlyWritable="
83 | + ownerOnlyWritable + ", writable=" + writable + "]";
84 | }
85 | }
86 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/tar/TarUnArchiverTest.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.tar;
2 |
3 | import java.io.File;
4 |
5 | import org.apache.commons.io.FileUtils;
6 | import org.codehaus.plexus.archiver.TestSupport;
7 | import org.codehaus.plexus.archiver.UnArchiver;
8 | import org.codehaus.plexus.components.io.fileselectors.FileSelector;
9 | import org.codehaus.plexus.components.io.fileselectors.IncludeExcludeFileSelector;
10 | import org.junit.jupiter.api.Test;
11 |
12 | import static org.junit.jupiter.api.Assertions.assertEquals;
13 |
14 | /**
15 | * @author Viktor Sadovnikov
16 | */
17 | class TarUnArchiverTest extends TestSupport {
18 |
19 | private void runUnarchiver(FileSelector[] selectors, boolean[] results) throws Exception {
20 | String s = "target/tar-unarchiver-tests";
21 |
22 | File testJar = new File(getBasedir(), "src/test/jars/test.tar.gz");
23 |
24 | File outputDirectory = new File(getBasedir(), s);
25 |
26 | TarUnArchiver tarUn = (TarUnArchiver) lookup(UnArchiver.class, "tar.gz");
27 | tarUn.setSourceFile(testJar);
28 | tarUn.setDestDirectory(outputDirectory);
29 | tarUn.setFileSelectors(selectors);
30 |
31 | FileUtils.deleteDirectory(outputDirectory);
32 |
33 | tarUn.extract(testJar.getAbsolutePath(), outputDirectory);
34 |
35 | assertFileExistance(s, "/resources/artifactId/test.properties", results[0]);
36 | assertFileExistance(s, "/resources/artifactId/directory/test.properties", results[1]);
37 | assertFileExistance(s, "/META-INF/MANIFEST.MF", results[2]);
38 | }
39 |
40 | private void assertFileExistance(String s, String file, boolean exists) {
41 | File f0 = new File(getBasedir(), s + file);
42 | assertEquals(
43 | exists,
44 | f0.exists(),
45 | String.format("Did %s expect to find %s file", exists ? "" : "NOT", f0.getAbsoluteFile()));
46 | }
47 |
48 | @Test
49 | void extractingADirectory() throws Exception {
50 | runUnarchiver(null, new boolean[] {true, true, true});
51 | }
52 |
53 | @Test
54 | void selectors() throws Exception {
55 | IncludeExcludeFileSelector fileSelector = new IncludeExcludeFileSelector();
56 | runUnarchiver(new FileSelector[] {fileSelector}, new boolean[] {true, true, true});
57 |
58 | fileSelector.setExcludes(new String[] {"**/test.properties"});
59 | runUnarchiver(new FileSelector[] {fileSelector}, new boolean[] {false, false, true});
60 |
61 | fileSelector.setIncludes(new String[] {"**/test.properties"});
62 | fileSelector.setExcludes(null);
63 | runUnarchiver(new FileSelector[] {fileSelector}, new boolean[] {true, true, false});
64 |
65 | fileSelector.setExcludes(new String[] {"resources/artifactId/directory/test.properties"});
66 | runUnarchiver(new FileSelector[] {fileSelector}, new boolean[] {true, false, false});
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/util/FilePermissionUtilsTest.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Licensed to the Apache Software Foundation (ASF) under one
3 | * or more contributor license agreements. See the NOTICE file
4 | * distributed with this work for additional information
5 | * regarding copyright ownership. The ASF licenses this file
6 | * to you under the Apache License, Version 2.0 (the
7 | * "License"); you may not use this file except in compliance
8 | * with the License. You may obtain a copy of the License at
9 | *
10 | * http://www.apache.org/licenses/LICENSE-2.0
11 | *
12 | * Unless required by applicable law or agreed to in writing,
13 | * software distributed under the License is distributed on an
14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 | * KIND, either express or implied. See the License for the
16 | * specific language governing permissions and limitations
17 | * under the License.
18 | */
19 | package org.codehaus.plexus.archiver.util;
20 |
21 | import org.junit.jupiter.api.Test;
22 | import org.slf4j.Logger;
23 | import org.slf4j.LoggerFactory;
24 |
25 | import static org.junit.jupiter.api.Assertions.assertFalse;
26 | import static org.junit.jupiter.api.Assertions.assertTrue;
27 |
28 | /**
29 | * @author Olivier Lamy
30 | */
31 | class FilePermissionUtilsTest {
32 |
33 | Logger getLogger() {
34 | return LoggerFactory.getLogger("foo");
35 | }
36 |
37 | @Test
38 | void onlyWritableOnlyUser() throws Exception {
39 | FilePermission fp = FilePermissionUtils.getFilePermissionFromMode("200", getLogger());
40 | assertTrue(fp.isWritable());
41 | assertTrue(fp.isOwnerOnlyWritable());
42 | assertFalse(fp.isExecutable());
43 | assertTrue(fp.isOwnerOnlyExecutable());
44 | assertFalse(fp.isReadable());
45 | }
46 |
47 | @Test
48 | void execAndRead() {
49 | FilePermission fp = FilePermissionUtils.getFilePermissionFromMode("500", getLogger());
50 | assertFalse(fp.isWritable());
51 | assertTrue(fp.isOwnerOnlyWritable());
52 | assertTrue(fp.isExecutable());
53 | assertTrue(fp.isOwnerOnlyExecutable());
54 | assertTrue(fp.isReadable());
55 | }
56 |
57 | @Test
58 | void allUser() {
59 | FilePermission fp = FilePermissionUtils.getFilePermissionFromMode("700", getLogger());
60 | assertTrue(fp.isWritable());
61 | assertTrue(fp.isOwnerOnlyWritable());
62 | assertTrue(fp.isExecutable());
63 | assertTrue(fp.isOwnerOnlyExecutable());
64 | assertTrue(fp.isReadable());
65 | }
66 |
67 | @Test
68 | void allAllUser() {
69 | FilePermission fp = FilePermissionUtils.getFilePermissionFromMode("707", getLogger());
70 | assertTrue(fp.isWritable());
71 | assertFalse(fp.isOwnerOnlyWritable());
72 | assertTrue(fp.isExecutable());
73 | assertFalse(fp.isOwnerOnlyExecutable());
74 | assertTrue(fp.isReadable());
75 | assertFalse(fp.isOwnerOnlyReadable());
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zip/PlexusArchiverZipFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.zip;
2 |
3 | import javax.inject.Named;
4 |
5 | import java.io.Closeable;
6 | import java.io.File;
7 | import java.io.IOException;
8 | import java.nio.charset.Charset;
9 | import java.nio.charset.StandardCharsets;
10 | import java.util.Enumeration;
11 | import java.util.Iterator;
12 |
13 | import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
14 | import org.apache.commons.compress.archivers.zip.ZipFile;
15 | import org.codehaus.plexus.components.io.resources.AbstractPlexusIoArchiveResourceCollection;
16 | import org.codehaus.plexus.components.io.resources.EncodingSupported;
17 | import org.codehaus.plexus.components.io.resources.PlexusIoResource;
18 |
19 | @Named("zip")
20 | public class PlexusArchiverZipFileResourceCollection extends AbstractPlexusIoArchiveResourceCollection
21 | implements EncodingSupported {
22 |
23 | private Charset charset = StandardCharsets.UTF_8;
24 |
25 | @Override
26 | protected Iterator getEntries() throws IOException {
27 | final File file = getFile();
28 | if (file == null) {
29 | throw new IOException("The tar archive file has not been set.");
30 | }
31 |
32 | final ZipFile zipFile = ZipFile.builder()
33 | .setFile(file)
34 | .setCharset(charset != null ? charset : StandardCharsets.UTF_8)
35 | .get();
36 | return new CloseableIterator(zipFile);
37 | }
38 |
39 | @Override
40 | public boolean isConcurrentAccessSupported() {
41 | // Well maybe someday investigate if we can do concurrent zip
42 | return false;
43 | }
44 |
45 | class CloseableIterator implements Iterator, Closeable {
46 |
47 | final Enumeration en;
48 |
49 | private final ZipFile zipFile;
50 |
51 | public CloseableIterator(ZipFile zipFile) {
52 | this.en = zipFile.getEntriesInPhysicalOrder();
53 | this.zipFile = zipFile;
54 | }
55 |
56 | @Override
57 | public boolean hasNext() {
58 | return en.hasMoreElements();
59 | }
60 |
61 | @Override
62 | public PlexusIoResource next() {
63 | final ZipArchiveEntry entry = en.nextElement();
64 | return entry.isUnixSymlink()
65 | ? new ZipSymlinkResource(zipFile, entry, getStreamTransformer())
66 | : new ZipResource(zipFile, entry, getStreamTransformer());
67 | }
68 |
69 | @Override
70 | public void remove() {
71 | throw new UnsupportedOperationException("Removing isn't implemented.");
72 | }
73 |
74 | @Override
75 | public void close() throws IOException {
76 | zipFile.close();
77 | }
78 | }
79 |
80 | @Override
81 | public void setEncoding(Charset charset) {
82 | this.charset = charset;
83 | }
84 | }
85 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zip/AddedDirs.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2015 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.zip;
18 |
19 | import java.util.ArrayDeque;
20 | import java.util.Deque;
21 | import java.util.HashSet;
22 | import java.util.Set;
23 | import java.util.Stack;
24 |
25 | /**
26 | * A list of directories that have been added to an archive.
27 | */
28 | public class AddedDirs {
29 |
30 | private final Set addedDirs = new HashSet();
31 |
32 | /**
33 | * @deprecated use {@link #asStringDeque(String)} instead.
34 | */
35 | @Deprecated
36 | public Stack asStringStack(String entry) {
37 | Stack directories = new Stack<>();
38 |
39 | // Don't include the last entry itself if it's
40 | // a dir; it will be added on its own.
41 | int slashPos = entry.length() - (entry.endsWith("/") ? 1 : 0);
42 |
43 | while ((slashPos = entry.lastIndexOf('/', slashPos - 1)) != -1) {
44 | String dir = entry.substring(0, slashPos + 1);
45 |
46 | if (addedDirs.contains(dir)) {
47 | break;
48 | }
49 |
50 | directories.push(dir);
51 | }
52 | return directories;
53 | }
54 |
55 | public Deque asStringDeque(String entry) {
56 | Deque directories = new ArrayDeque<>();
57 |
58 | // Don't include the last entry itself if it's
59 | // a dir; it will be added on its own.
60 | int slashPos = entry.length() - (entry.endsWith("/") ? 1 : 0);
61 |
62 | while ((slashPos = entry.lastIndexOf('/', slashPos - 1)) != -1) {
63 | String dir = entry.substring(0, slashPos + 1);
64 |
65 | if (addedDirs.contains(dir)) {
66 | break;
67 | }
68 |
69 | directories.push(dir);
70 | }
71 | return directories;
72 | }
73 |
74 | public void clear() {
75 | addedDirs.clear();
76 | }
77 |
78 | /**
79 | * Adds the path to this list.
80 | *
81 | * @param vPath The path to add.
82 | *
83 | * @return true if the path was already present, false if it has been added.
84 | */
85 | public boolean update(String vPath) {
86 | return !addedDirs.add(vPath);
87 | }
88 |
89 | public Set allAddedDirs() {
90 | return new HashSet(addedDirs);
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/tar/PlexusIoTarFileResourceCollection.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2010-2015 The plexus developers.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.tar;
17 |
18 | import javax.inject.Named;
19 |
20 | import java.io.Closeable;
21 | import java.io.File;
22 | import java.io.IOException;
23 | import java.util.Enumeration;
24 | import java.util.Iterator;
25 |
26 | import org.apache.commons.compress.archivers.ArchiveEntry;
27 | import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
28 | import org.codehaus.plexus.components.io.resources.AbstractPlexusIoArchiveResourceCollection;
29 | import org.codehaus.plexus.components.io.resources.PlexusIoResource;
30 |
31 | @Named("tar")
32 | public class PlexusIoTarFileResourceCollection extends AbstractPlexusIoArchiveResourceCollection implements Closeable {
33 |
34 | protected TarFile newTarFile(File file) {
35 | return new TarFile(file);
36 | }
37 |
38 | TarFile tarFile = null;
39 |
40 | @Override
41 | public void close() throws IOException {
42 | if (tarFile != null) {
43 | tarFile.close();
44 | }
45 | }
46 |
47 | @Override
48 | public boolean isConcurrentAccessSupported() {
49 | return false;
50 | }
51 |
52 | @Override
53 | protected Iterator getEntries() throws IOException {
54 | final File f = getFile();
55 | if (f == null) {
56 | throw new IOException("The tar archive file has not been set.");
57 | }
58 | if (tarFile == null) {
59 | tarFile = newTarFile(f);
60 | }
61 | final Enumeration en = tarFile.getEntries();
62 | return new Iterator() {
63 |
64 | @Override
65 | public boolean hasNext() {
66 | return en.hasMoreElements();
67 | }
68 |
69 | @Override
70 | public PlexusIoResource next() {
71 | final TarArchiveEntry entry = (TarArchiveEntry) en.nextElement();
72 | return entry.isSymbolicLink()
73 | ? new TarSymlinkResource(tarFile, entry)
74 | : new TarResource(tarFile, entry);
75 | }
76 |
77 | @Override
78 | public void remove() {
79 | throw new UnsupportedOperationException("Removing isn't implemented.");
80 | }
81 | };
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/xz/XZUnArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016 Codehaus.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.xz;
17 |
18 | import javax.annotation.Nonnull;
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 | import java.io.IOException;
23 | import java.io.InputStream;
24 |
25 | import org.apache.commons.compress.compressors.xz.XZCompressorInputStream;
26 | import org.codehaus.plexus.archiver.AbstractUnArchiver;
27 | import org.codehaus.plexus.archiver.ArchiverException;
28 |
29 | import static org.codehaus.plexus.archiver.util.Streams.bufferedInputStream;
30 | import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
31 | import static org.codehaus.plexus.archiver.util.Streams.copyFully;
32 | import static org.codehaus.plexus.archiver.util.Streams.fileInputStream;
33 | import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
34 |
35 | /**
36 | * @author philip.lourandos
37 | * @since 3.3
38 | */
39 | @Named("xz")
40 | public class XZUnArchiver extends AbstractUnArchiver {
41 |
42 | private static final String OPERATION_XZ = "xz";
43 |
44 | public XZUnArchiver() {}
45 |
46 | public XZUnArchiver(File source) {
47 | super(source);
48 | }
49 |
50 | @Override
51 | protected void execute() throws ArchiverException {
52 | if (getSourceFile().lastModified() > getDestFile().lastModified()) {
53 | getLogger()
54 | .info("Expanding " + getSourceFile().getAbsolutePath() + " to "
55 | + getDestFile().getAbsolutePath());
56 |
57 | copyFully(
58 | getXZInputStream(bufferedInputStream(fileInputStream(getSourceFile(), OPERATION_XZ))),
59 | bufferedOutputStream(fileOutputStream(getDestFile(), OPERATION_XZ)),
60 | OPERATION_XZ);
61 | }
62 | }
63 |
64 | public static @Nonnull XZCompressorInputStream getXZInputStream(InputStream in) throws ArchiverException {
65 | try {
66 | return new XZCompressorInputStream(in);
67 | } catch (IOException ioe) {
68 | throw new ArchiverException("Trouble creating BZIP2 compressor, invalid file ?", ioe);
69 | }
70 | }
71 |
72 | @Override
73 | protected void execute(String path, File outputDirectory) throws ArchiverException {
74 | throw new UnsupportedOperationException("Targeted execution not supported in xz format");
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/AbstractArchiverTest.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.io.File;
4 | import java.io.IOException;
5 |
6 | import org.junit.jupiter.api.BeforeEach;
7 | import org.junit.jupiter.api.Test;
8 |
9 | import static org.junit.jupiter.api.Assertions.assertEquals;
10 |
11 | class AbstractArchiverTest {
12 |
13 | private AbstractArchiver archiver;
14 |
15 | @BeforeEach
16 | void setUp() throws Exception {
17 | this.archiver = new AbstractArchiver() {
18 |
19 | @Override
20 | protected String getArchiveType() {
21 | throw new UnsupportedOperationException();
22 | }
23 |
24 | @Override
25 | protected void execute() throws ArchiverException, IOException {
26 | throw new UnsupportedOperationException();
27 | }
28 |
29 | @Override
30 | protected void close() throws IOException {
31 | throw new UnsupportedOperationException();
32 | }
33 | };
34 | }
35 |
36 | @Test
37 | void modesAndOverridesAreUnsetByDefault() {
38 | assertEquals(-1, archiver.getDefaultFileMode());
39 | assertEquals(-1, archiver.getOverrideFileMode());
40 |
41 | assertEquals(Archiver.DEFAULT_DIR_MODE, archiver.getDefaultDirectoryMode());
42 | assertEquals(-1, archiver.getOverrideDirectoryMode());
43 | }
44 |
45 | @Test
46 | void whenUnsetModeUsesDefault() {
47 | assertEquals(Archiver.DEFAULT_FILE_MODE, archiver.getFileMode());
48 | assertEquals(Archiver.DEFAULT_DIR_MODE, archiver.getDirectoryMode());
49 | }
50 |
51 | @Test
52 | void setModeIsUsedWithFlagsForType() {
53 | archiver.setFileMode(0400);
54 | assertEquals(0100400, archiver.getFileMode());
55 |
56 | archiver.setDirectoryMode(0600);
57 | assertEquals(040600, archiver.getDirectoryMode());
58 | }
59 |
60 | @Test
61 | void setDefaultIncludesFlagsForType() {
62 | archiver.setDefaultFileMode(0400);
63 | assertEquals(0100400, archiver.getDefaultFileMode());
64 |
65 | archiver.setDefaultDirectoryMode(0600);
66 | assertEquals(040600, archiver.getDefaultDirectoryMode());
67 | }
68 |
69 | @Test
70 | void defaultIsUsedWhenModeIsUnset() {
71 | archiver.setDefaultFileMode(0400);
72 | assertEquals(0100400, archiver.getFileMode());
73 |
74 | archiver.setDefaultDirectoryMode(0600);
75 | assertEquals(040600, archiver.getDirectoryMode());
76 | }
77 |
78 | @Test
79 | void overridesCanBeReset() {
80 | archiver.setFileMode(0400);
81 | archiver.setFileMode(-1);
82 | assertEquals(-1, archiver.getOverrideFileMode());
83 |
84 | archiver.setDirectoryMode(0600);
85 | archiver.setDirectoryMode(-1);
86 | assertEquals(-1, archiver.getOverrideDirectoryMode());
87 | }
88 |
89 | @Test
90 | void setDestFileInTheWorkingDir() {
91 | archiver.setDestFile(new File("archive"));
92 | }
93 | }
94 |
--------------------------------------------------------------------------------
/src/test/java/org/codehaus/plexus/archiver/war/WarArchiverTest.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver.war;
2 |
3 | import java.io.File;
4 |
5 | import org.apache.commons.io.FileUtils;
6 | import org.codehaus.plexus.archiver.ArchiveEntry;
7 | import org.codehaus.plexus.archiver.Archiver;
8 | import org.codehaus.plexus.archiver.ResourceIterator;
9 | import org.codehaus.plexus.archiver.TestSupport;
10 | import org.junit.jupiter.api.BeforeEach;
11 | import org.junit.jupiter.api.Test;
12 |
13 | import static org.junit.jupiter.api.Assertions.assertEquals;
14 | import static org.junit.jupiter.api.Assertions.assertTrue;
15 |
16 | /**
17 | * @author Kristian Rosenvold
18 | */
19 | class WarArchiverTest extends TestSupport {
20 |
21 | private final int expected = 8;
22 |
23 | @Test
24 | void reAddingPlatformSpecificEncoding() throws Exception {
25 | WarArchiver archiver = (WarArchiver) lookup(Archiver.class, "war");
26 | archiver.setDestFile(new File(getTargetRarFolder(), "test.war"));
27 |
28 | File dummyContent = getTestFile("src/test/resources/folders");
29 | archiver.addDirectory(dummyContent);
30 |
31 | assertEquals(expected, count(archiver.getResources())); // I wonder what the first entry is
32 |
33 | File file = getTestFile("src/test/resources/folders/WEB-INF/web.xml");
34 | archiver.setWebxml(file);
35 |
36 | assertEquals(expected, count(archiver.getResources())); // I wonder what the first entry is
37 |
38 | archiver.createArchive();
39 | assertTrue(new File(getTargetRarFolder(), "test.war").exists());
40 | }
41 |
42 | @Test
43 | void infiniteRecursion() throws Exception {
44 | WarArchiver archiver = (WarArchiver) lookup(Archiver.class, "war");
45 | archiver.setDestFile(new File(getTargetRarFolder(), "test.war"));
46 |
47 | // Easy to produce infinite recursion if you just add existing files again and again
48 | File dummyContent = getTestFile("src/test/resources/folders", "File.txt");
49 | final int INFINITY = 10;
50 | for (int i = 0; i < INFINITY; i++) {
51 | archiver.addFile(dummyContent, "testZ");
52 | }
53 | assertEquals(1, count(archiver.getResources())); // I wonder what the first entry is
54 | }
55 |
56 | public File getTargetRarFolder() {
57 | return new File(getBasedir(), "/target/wartest/");
58 | }
59 |
60 | @Override
61 | @BeforeEach
62 | public void setUp() throws Exception {
63 | super.setUp();
64 | // clean output directory and re create it
65 | if (getTargetRarFolder().exists()) {
66 | FileUtils.deleteDirectory(getTargetRarFolder());
67 | }
68 | }
69 |
70 | private int count(ResourceIterator resourceIterator) {
71 | int i = 0;
72 | while (resourceIterator.hasNext()) {
73 | i++;
74 | ArchiveEntry next = resourceIterator.next();
75 | System.out.print(next.getMode());
76 | System.out.println(next.getName());
77 | }
78 | return i;
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/snappy/SnappyUnArchiver.java:
--------------------------------------------------------------------------------
1 | /**
2 | *
3 | * Copyright 2004 The Apache Software Foundation
4 | *
5 | * Licensed under the Apache License, Version 2.0 (the "License");
6 | * you may not use this file except in compliance with the License.
7 | * You may obtain a copy of the License at
8 | *
9 | * http://www.apache.org/licenses/LICENSE-2.0
10 | *
11 | * Unless required by applicable law or agreed to in writing, software
12 | * distributed under the License is distributed on an "AS IS" BASIS,
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 | * See the License for the specific language governing permissions and
15 | * limitations under the License.
16 | */
17 | package org.codehaus.plexus.archiver.snappy;
18 |
19 | import javax.annotation.Nonnull;
20 | import javax.inject.Named;
21 |
22 | import java.io.File;
23 | import java.io.IOException;
24 | import java.io.InputStream;
25 |
26 | import io.airlift.compress.snappy.SnappyFramedInputStream;
27 | import org.codehaus.plexus.archiver.AbstractUnArchiver;
28 | import org.codehaus.plexus.archiver.ArchiverException;
29 |
30 | import static org.codehaus.plexus.archiver.util.Streams.bufferedInputStream;
31 | import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
32 | import static org.codehaus.plexus.archiver.util.Streams.copyFully;
33 | import static org.codehaus.plexus.archiver.util.Streams.fileInputStream;
34 | import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
35 |
36 | /**
37 | * Unarchiver for snappy-compressed files.
38 | */
39 | @Named("snappy")
40 | public class SnappyUnArchiver extends AbstractUnArchiver {
41 |
42 | private static final String OPERATION_SNAPPY = "snappy";
43 |
44 | public SnappyUnArchiver() {}
45 |
46 | public SnappyUnArchiver(File sourceFile) {
47 | super(sourceFile);
48 | }
49 |
50 | @Override
51 | protected void execute() throws ArchiverException {
52 | if (getSourceFile().lastModified() > getDestFile().lastModified()) {
53 | getLogger()
54 | .info("Expanding " + getSourceFile().getAbsolutePath() + " to "
55 | + getDestFile().getAbsolutePath());
56 |
57 | copyFully(
58 | getSnappyInputStream(bufferedInputStream(fileInputStream(getSourceFile(), OPERATION_SNAPPY))),
59 | bufferedOutputStream(fileOutputStream(getDestFile(), OPERATION_SNAPPY)),
60 | OPERATION_SNAPPY);
61 | }
62 | }
63 |
64 | public static @Nonnull SnappyFramedInputStream getSnappyInputStream(InputStream bis) throws ArchiverException {
65 | try {
66 | return new SnappyFramedInputStream(bis, true);
67 | } catch (IOException e) {
68 | throw new ArchiverException("Trouble creating Snappy compressor, invalid file ?", e);
69 | }
70 | }
71 |
72 | @Override
73 | protected void execute(String path, File outputDirectory) {
74 | throw new UnsupportedOperationException("Targeted extraction not supported in Snappy format.");
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/zstd/ZstdUnArchiver.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2022 The Apache Software Foundation
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 | package org.codehaus.plexus.archiver.zstd;
17 |
18 | import javax.annotation.Nonnull;
19 | import javax.inject.Named;
20 |
21 | import java.io.File;
22 | import java.io.IOException;
23 | import java.io.InputStream;
24 |
25 | import org.apache.commons.compress.compressors.zstandard.ZstdCompressorInputStream;
26 | import org.codehaus.plexus.archiver.AbstractUnArchiver;
27 | import org.codehaus.plexus.archiver.ArchiverException;
28 |
29 | import static org.codehaus.plexus.archiver.util.Streams.bufferedInputStream;
30 | import static org.codehaus.plexus.archiver.util.Streams.bufferedOutputStream;
31 | import static org.codehaus.plexus.archiver.util.Streams.copyFully;
32 | import static org.codehaus.plexus.archiver.util.Streams.fileInputStream;
33 | import static org.codehaus.plexus.archiver.util.Streams.fileOutputStream;
34 |
35 | /**
36 | * Unarchiver for zstd-compressed files.
37 | */
38 | @Named("zst")
39 | public class ZstdUnArchiver extends AbstractUnArchiver {
40 |
41 | private static final String OPERATION_ZSTD = "zstd";
42 |
43 | public ZstdUnArchiver() {}
44 |
45 | public ZstdUnArchiver(File source) {
46 | super(source);
47 | }
48 |
49 | @Override
50 | protected void execute() throws ArchiverException {
51 | if (getSourceFile().lastModified() > getDestFile().lastModified()) {
52 | getLogger()
53 | .info("Expanding " + getSourceFile().getAbsolutePath() + " to "
54 | + getDestFile().getAbsolutePath());
55 |
56 | copyFully(
57 | getZstdInputStream(bufferedInputStream(fileInputStream(getSourceFile(), OPERATION_ZSTD))),
58 | bufferedOutputStream(fileOutputStream(getDestFile(), OPERATION_ZSTD)),
59 | OPERATION_ZSTD);
60 | }
61 | }
62 |
63 | public static @Nonnull ZstdCompressorInputStream getZstdInputStream(InputStream in) throws ArchiverException {
64 | try {
65 | return new ZstdCompressorInputStream(in);
66 | } catch (IOException ioe) {
67 | throw new ArchiverException("Trouble creating Zstd compressor, invalid file ?", ioe);
68 | }
69 | }
70 |
71 | @Override
72 | protected void execute(String path, File outputDirectory) throws ArchiverException {
73 | throw new UnsupportedOperationException("Targeted execution not supported in zstd format");
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/main/java/org/codehaus/plexus/archiver/DotDirectiveArchiveFinalizer.java:
--------------------------------------------------------------------------------
1 | package org.codehaus.plexus.archiver;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.File;
5 | import java.io.IOException;
6 | import java.nio.charset.StandardCharsets;
7 | import java.nio.file.Files;
8 | import java.util.Collections;
9 | import java.util.List;
10 |
11 | import org.codehaus.plexus.archiver.util.DefaultFileSet;
12 | import org.codehaus.plexus.util.FileUtils;
13 | import org.codehaus.plexus.util.StringUtils;
14 |
15 | /**
16 | * An {@link ArchiveFinalizer} that process dot files with archiver directives
17 | * contained within. This basically means you can communicate archive creation
18 | * instructions between processes using dot files.
19 | *
20 | * @author Jason van Zyl
21 | */
22 | public class DotDirectiveArchiveFinalizer extends AbstractArchiveFinalizer {
23 |
24 | private static final String DEFAULT_DOT_FILE_PREFIX = ".plxarc";
25 |
26 | private final File dotFileDirectory;
27 |
28 | private final String dotFilePrefix;
29 |
30 | public DotDirectiveArchiveFinalizer(File dotFileDirectory) {
31 | this(dotFileDirectory, DEFAULT_DOT_FILE_PREFIX);
32 | }
33 |
34 | public DotDirectiveArchiveFinalizer(File dotFileDirectory, String dotFilePrefix) {
35 | this.dotFileDirectory = dotFileDirectory;
36 |
37 | this.dotFilePrefix = dotFilePrefix;
38 | }
39 |
40 | @Override
41 | public void finalizeArchiveCreation(Archiver archiver) throws ArchiverException {
42 | try {
43 | List dotFiles = FileUtils.getFiles(dotFileDirectory, dotFilePrefix + "*", null);
44 |
45 | for (File dotFile : dotFiles) {
46 | try (BufferedReader in = Files.newBufferedReader(dotFile.toPath(), StandardCharsets.UTF_8)) {
47 |
48 | for (String line = in.readLine(); line != null; line = in.readLine()) {
49 | String[] s = StringUtils.split(line, ":");
50 |
51 | if (s.length == 1) {
52 | File directory = new File(dotFileDirectory, s[0]);
53 |
54 | System.out.println("adding directory = " + directory);
55 |
56 | archiver.addFileSet(new DefaultFileSet(directory));
57 | } else {
58 | File directory = new File(dotFileDirectory, s[0]);
59 |
60 | System.out.println("adding directory = " + directory + " to: " + s[1]);
61 |
62 | if (s[1].endsWith("/")) {
63 |
64 | archiver.addFileSet(new DefaultFileSet(directory).prefixed(s[1]));
65 | } else {
66 | archiver.addFileSet(new DefaultFileSet(directory).prefixed(s[1] + "/"));
67 | }
68 | }
69 | }
70 | }
71 | }
72 | } catch (IOException e) {
73 | throw new ArchiverException("Error processing dot files.", e);
74 | }
75 | }
76 |
77 | @Override
78 | public List getVirtualFiles() {
79 | return Collections.EMPTY_LIST;
80 | }
81 | }
82 |
--------------------------------------------------------------------------------