Skip to content

Latest commit

 

History

History
84 lines (58 loc) · 3.85 KB

File metadata and controls

84 lines (58 loc) · 3.85 KB

Plexus Archiver

Maven Central GitHub CI Reproducible Builds License

One API for creating and extracting archives — zip, jar, tar and their compressed variants — regardless of format. It is what maven-assembly-plugin, maven-jar-plugin and friends use underneath.

Built on Apache Commons Compress, adding the things a build tool needs on top of it: include/exclude scanning, file mappers and selectors, permission handling, reproducible output, duplicate strategies, modular JARs and archive size limits.

Status

Actively maintained. This is one of the most widely used artifacts in the Maven ecosystem, so public API is kept compatible and changes are deliberately conservative.

Using it

pom.xml — the 5.x line, which requires Java 17:

<dependency>
  <groupId>org.codehaus.plexus</groupId>
  <artifactId>plexus-archiver</artifactId>
</dependency>

The 4.x line, still maintained, for Java 8:

<dependency>
  <groupId>org.codehaus.plexus</groupId>
  <artifactId>plexus-archiver</artifactId>
</dependency>

Take the current version of each line from the releases page; the badge above tracks whichever is newest overall.

Java sourcecode

Components are JSR-330 beans, resolved by role hint (zip, jar, tar.gz, …). No Plexus container is involved — Eclipse Sisu replaced that years ago. The site lists every supported format and its hint.

@Inject
@Named("zip")
Archiver archiver;

@Inject
ArchiverManager archiverManager;

As of version 5.0.0 there's also a ServiceLoader based implementation.

var archiveManager = new ServiceLoaderArchiverManager();

// or without archiveManager
var archiver = ServiceLoader.load(ArchiverProvider.class).stream()
  .map(Provider::get)
  .filter(p -> "zip".equals(p.getName()))
  .findFirst()
  .orElseThrow();

After retrieving a fresh archiver, you can do

var archiver = archiveManager.getArchiver("zip");

archiver.addDirectory(new File("src/main/resources"));
archiver.setDestFile(new File("target/out.zip"));
archiver.createArchive();

Documentation

Contributing

See CONTRIBUTING.md. In short: mvn verify builds, and run mvn spotless:apply before pushing or CI will fail on formatting.

Please report security vulnerabilities privately — see SECURITY.md, not a public issue.