Archie is a Java library for stream-based manipulation of zip
, jar
, and tar.gz
files. Rather than explode and reassemble archives, Archie applies transformations on-the-fly with a simple and expressive callback model.
-
Works with
zip
,jar
, andtar.gz
formats -
Stream-friendly: avoids unzip → modify → rezip overhead
-
Simple builder-based transformation model
-
Supports:
-
Injecting entries before/after the archive or individual entries
-
Skipping entries
-
Prepending text to existing files
-
Archie promotes streaming transformations of archives without hitting the disk or loading files completely into memory.
Any manipulation of an archive will involve copying the file once. Archie allows building complex transformation rules that act on entries during the streaming process. The result is the compressed archive is never fully unpacked on disk at any one time, yet very complicated manipulations can be done on each entry as they are individually streamed.
Useful in deployment pipelines, repackaging tools, or license/compliance stamping workflows.
Add Archie to your project:
<dependency>
<groupId>org.tomitribe</groupId>
<artifactId>archie</artifactId>
<version>1.0.0</version> <!-- Replace with actual -->
</dependency>
Inject a README.txt
into a JAR file:
Transformations transformations = Transformations.builder()
.before(InsertEntry.builder()
.name("README.txt")
.content("Hello, World!")
.build())
.build();
new JarTransformation(transformations)
.transform(new FileInputStream("input.jar"),
new FileOutputStream("output.jar"));
Insert content relative to an entry:
Transformations.builder()
.beforeEntry(name -> name.endsWith("Red.class"), stream -> {
stream.writeEntry("BeforeRed.txt", "Pre-content");
})
.afterEntry(name -> name.endsWith("Red.class"), stream -> {
stream.writeEntry("AfterRed.txt", "Post-content");
})
.build();
Archie supports the following formats via dedicated transformation types:
-
JarTransformation
-
ZipTransformation
-
TarGzTransformation
Each accepts the same Transformations
model for consistent usage across formats.
We welcome contributions! Feel free to submit issues, feature requests, or PRs on GitHub.