Modular Apache commons compress

Overview

Kala Compress

Gradle Check

This project is based on Apache Commons Compress. Kala Compress has made some improvements on its basis: Modularization (JPMS Support), NIO2 Path API support, etc.

Its API is mostly consistent with Apache Commons Compress, with a few incompatibilities. So I renamed the package (and the module name) from org.apache.commons.compress to kala.compress. Therefore, it can coexist with Apache Commons Compress without conflict.

We assume that you already know about Commons Compress. If not, please refer to the User Guide first.

To add Kala Compress as a dependency, see section Modules.

Different from Apache Commons Compress

Modularization (JPMS Support)

Kala Compress has been fully modularized and now fully supports the the JPMS (Java Platform Module System).

Each compressor and archive is split into a separate artifact with a separate module name, you can optionally add dependencies on some of them without importing the entire Kala Compress. (The size of Kala Compress core jar is less than 90KB)

The appearance of ArchiveStreamFactory and CompressorStreamFactory has not changed, but the inside has been remodeled to find the optional component through ServiceLoader at runtime, so they are no longer dependent on them at compile time.

Each module provides its module-info.class, so it can work well with jlink.

For more information about the Kala Compress modules, see Modules.

Charset

Kala Compress has been completely refactored internally to use java.nio.charset.Charset to represent encoding. All methods that accept an encoding represented by String provide overloads that accept Charset, please use Charset first.

ZipEncoding has been removed, please switch to Charset.

CharsetNames has been removed, please switch to StandardCharsets.

Kala Compress no longer uses Charset.defaultCharset(), but uses UTF-8 as an alternative. Note that file.encoding defaults to UTF-8 since Java 18. When you want to use platform native encoding, use the kala.compress.utils.Charsets.nativeCharset() explicitly as an alternative.

In addition, APIs that accept encoding represented by String now no longer fall back to the default character set when the encoding is not supported or invalid. Now they throw exceptions just like Charset.forName. (The behavior when null is passed in is not affected, it will still fall back to the UTF-8)

NIO2 Support (java.nio.file.Path and java.nio.file.FileSystem)

Based on the Commons Compress 1.21, Kala Compress has better support for the NIO2 Path API.

Internally, Kala Compress has switched entirely to Path-based representation, all methods that accept File provide overloads that accept Path. The original File-based API is now delegated to the Path-based API. Please use the Path-based API first.

Since File is no longer used internally, Kala Compress fully supports Paths on non default file systems.

(TODO: Provide FileSystem implementations for each archivers)

Deprecation and removal

The deprecated features in Apache Commons Compress 1.21 have all been removed.

Additional support for OSGI is no longer provided, but this shouldn't make a big difference. If the problem is caused by caching of dependency checks, use the corresponding setCache[Library]Availablity to turn off its caching.

ZipEncoding and CharsetNames has been removed, please switch to Charset and StandardCharsets.

Since Security Manager will be removed from JDK in the future, Kala Compress no longer use it. For more details, see JEP 411: Deprecate the Security Manager for Removal.

Since finalize method will be removed from JDK in the future, Kala Compress no longer used to clean up resources. For more details, see JEP 421: Deprecate Finalization for Removal. The archiveName in the ZipFile constructor is only used for error reporting in finalize, so it is removed together.

The implementation of pack200 was removed, kala.compress.compressors.pack200 now uses a more flexible reflection strategy to select the underlying implementation:

  • By default, it looks for the following pack200 implementations:
    • For Java 13 and earlier, Kala Compress uses the java.util.jar.Pack200 built into the JDK, so it doesn't need external dependencies at this time.
    • org.glavo.pack200.Pack200 (extracted from JDK 13 and published separately)
    • org.apache.commons.compress.java.util.jar.Pack200 (available in Apache Commons Compress 1.21)
    • io.pack200.Pack200
  • You can use Pack200Utils.setPack200Provider(String provider) to specify specific implementations to use, including those not in the list above.

A small number of methods that accept the File and accept encoding represented by String have been removed. Please use Path and Charset instead.

Modules

Note: Kala Compress is in beta phase. Although it is developed based on mature Apache Commons Compress and has passed all tests, it may still be unstable. I may need to make some adjustments to the API before releasing to production.

The latest Kala Compress version is 1.21.0.1-beta2.

You can add dependencies on Kala Compress modules as follows:

Maven:

<dependency>
  <groupId>org.glavo.kala</groupId>
  <artifactId>${kala-compress-module-name}</artifactId>
  <version>${kala-compress-version}</version>
</dependency>

Gradle:

dependencies {
  implementation("org.glavo.kala:${kala-compress-module-name}:${kala-compress-version}")
}

Replace the ${kala-compress-module-name} with Kala Compress Maven module name (replace . with - in JPMS module name), replace the ${kala-compress-version} with the latest Kala Compress version.

For example, to add the entire Kala Compress, you need to add the following:

Maven:

<dependency>
  <groupId>org.glavo.kala</groupId>
  <artifactId>kala-compress</artifactId>
  <version>1.21.0.1-beta2</version>
</dependency>

Gradle:

dependencies {
  implementation("org.glavo.kala:kala-compress:1.21.0.1-beta2")
}

All Kala Compress modules are listed below.

kala.compress

This is an empty module, which declares the transitivity dependency on all modules of Kala Compress. You can use all the contents of Kala Compress only by adding dependencies on it.

kala.compress.base

It is the basic module of Kala Compress, and all other modules depend on it.

It contains the following packages:

  • (package) kala.compress
  • (package) kala.compress.archivers
  • (package) kala.compress.compressors
  • (package) kala.compress.compressors.lz77support
  • (package) kala.compress.compressors.lzw
  • (package) kala.compress.compressors.parallel
  • (package) kala.compress.compressors.utils

kala.compress.compressors

It is an empty module that contains transitive dependencies on all compressor modules. You can include all compressors by adding a dependency on it.

In addition, each compressor in Kala Compress has a separate module, and you can add dependencies on one or all of them separately. Here is a list of compressors:

Here are some notes:

  • Different from Apache Commons Compress, the brotli compressor has no external dependencies. It copies the Google Brotli code into package kala.compress.compressors.brotli.dec, The reason for this is that Google Brotli does not support JPMS.
  • The lzma compressor and the xz compressor needs XZ for Java to work.
  • The zstandard compressor needs Zstd JNI to work.

kala.compress.archivers

It is an empty module that contains transitive dependencies on all archiver modules. You can include all archivers by adding a dependency on it.

In addition, each archiver in Kala Compress has a separate module, and you can add dependencies on one or all of them separately. Here is a list of archivers:

Here are some notes:

  • The sevenz archiver needs XZ for Java to work.
  • The sevenz archiver and the zip archiver have optional dependencies on the bzip2 compressor and the deflate64 compressor. They can work without these compressors, but errors will occur when they are required.
  • Support for jar (in package kala.compress.archivers.jar) is in the module kala.compress.archivers.zip.

kala.compress.changes

It contains the package kala.compress.changes.

Task list

  • Deprecate ZipEncoding and CharsetNames, replace them with Charset, StandardCharsets and Charsets;
  • Full support for Java Charset, allows users to specify encoding without using String at all;
  • Use UTF-8 by default;
  • Clean up all deprecated features;
  • In preparation for Valhalla, replace the constructor of a class that can become a value class with a factory method;
  • Flexible choice of pack200 implementation (when the JDK has built-in pack200 support, external dependencies are no longer required);
  • Enhanced NIO2 Path API support, migration from File to Path;
  • Provide FileSystem for each archiver;
  • Dynamic loading compressors in CompressorStreamFactory
  • Dynamic loading archivers in ArchiveStreamFactory
  • Split compressors and archivers into separate modules;
  • Full support for JPMS;
  • Rename the package;
  • Publish it to Maven Central

Bug Report

If you encounter problems using it, please open an issue.

If it's an issue upstream of Apache Commons Compress, it's best to give feedback here and I'll port the upstream fix here.

You might also like...

source code of the live coding demo for "Building resilient and scalable API backends with Apache Pulsar and Spring Reactive" talk held at ApacheCon@Home 2021

reactive-iot-backend The is the source code of the live coding demo for "Building resilient and scalable API backends with Apache Pulsar and Spring Re

Jan 13, 2022

Apache Log4j2 CVE-2021-44228 RCE Demo with RMI and LDAP

Apache Log4j2 CVE-2021-44228 RCE Demo with RMI and LDAP

CVE-2021-44228-Demo 利用 CVE-2021-44228,通过 RMI 和 LDAP 两种方式远程注入代码的示例。 Exploit class from RMI Server loaded Hello, ${jndi:rmi://127.0.0.1:1099/exploit} Ex

Dec 14, 2021

Apache Maven artifacts for bootstrapping new open-source projects

OSS Quickstart Apache Maven archetypes for bootstrapping new open-source projects. Think Maven Quickstart Archetype and friends, but more modern, comp

Dec 31, 2022

CVE-2021-44228 - Apache log4j RCE quick test

Build ./build.sh Start log4j RCE Server ./start-log4j-rce-server.sh Test Run java -cp log4j-rce-1.0-SNAPSHOT-all.jar log4j Check if you get logs in ha

Feb 1, 2022

Some tools to help mitigating Apache Log4j 2 CVE-2021-44228

JndiLookup Some tool to help analyzing Apache Log4j 2 CVE-2021-44228 This tool uses the "lookup" feature from log4j-2 to test against the JNDI vulnera

Dec 18, 2021

Mirror of Apache Velocity Engine

Title: Apache Velocity Engine Apache Velocity Welcome to Apache Velocity Engine! Apache Velocity is a general purpose template engine written in Java.

Dec 22, 2022

LOQUI - Real-time chat application built using Apache Kafka, Java, Spring Boot, SockJS and React

LOQUI - Real-time chat application built using Apache Kafka, Java, Spring Boot, SockJS and React

LOQUI is a simple real-time chat application that demonstrates how to use Apache Kafka as a message broker along with Java, Spring Boot and React on the front-end

Jun 5, 2022

PoC for CVE-2021-31805 (Apache Struts2)

CVE-2021-31805 PoC for CVE-2021-31805 (Apache Struts2) CVE-2021-31805の解説記事で使用したアプリケーションです。 セットアップ $ docker-compose build $ docker-compose up -d 動作確認

May 21, 2022

A webshell application and interactive shell for pentesting Apache Tomcat servers.

A webshell application and interactive shell for pentesting Apache Tomcat servers.

Apache Tomcat webshell application for RCE A webshell application and interactive shell for pentesting Apache Tomcat servers. Features Webshell plugin

Jan 1, 2023
Comments
  • Bump org.apache.felix.framework from 7.0.0 to 7.0.3

    Bump org.apache.felix.framework from 7.0.0 to 7.0.3

    Bumps org.apache.felix.framework from 7.0.0 to 7.0.3.

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies java 
    opened by dependabot[bot] 1
  • Bump actions/checkout from 2.3.4 to 2.4.0

    Bump actions/checkout from 2.3.4 to 2.4.0

    ⚠️ Dependabot is rebasing this PR ⚠️

    Rebasing might not happen immediately, so don't worry if this takes some time.

    Note: if you make any changes to this PR yourself, they will take precedence over the rebase.


    Bumps actions/checkout from 2.3.4 to 2.4.0.

    Release notes

    Sourced from actions/checkout's releases.

    v2.4.0

    • Convert SSH URLs like org-<ORG_ID>@github.com: to https://github.com/ - pr

    v2.3.5

    Update dependencies

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
  • Bump actions/cache from 2.1.6 to 2.1.7

    Bump actions/cache from 2.1.6 to 2.1.7

    Bumps actions/cache from 2.1.6 to 2.1.7.

    Release notes

    Sourced from actions/cache's releases.

    v2.1.7

    Support 10GB cache upload using the latest version 1.0.8 of @actions/cache

    Commits

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
    dependencies github_actions 
    opened by dependabot[bot] 1
Owner
Glavo
Glavo
The lightweight library for compress image, video, and audio with an awesome experience

Would you like to support me? react-native-compressor Compress videos, images and audio before upload react-native-compressor package is a set of func

Shobbak 265 Jan 1, 2023
Modular and customizable Material Design UI components for Android

Material Components for Android Material Components for Android (MDC-Android) help developers execute Material Design. Developed by a core team of eng

Material Components 14.4k Jan 3, 2023
A modular, high performance, headless e-commerce(ecommerce) platform built with Java,Springboot, Vue.

What is Shopfly? Shopfly is modular, high performance, headless e-commerce(ecommerce) platform built with Java,Springboot, Vue. Architecture Shopfly i

Shopfly 31 Jul 17, 2022
A modular, high performance, headless e-commerce(ecommerce) platform built with Java,Springboot, Vue.

What is Shopfly? Shopfly is modular, high performance, headless e-commerce(ecommerce) platform built with Java,Springboot, Vue. Architecture Shopfly i

Shopfly 29 Apr 25, 2022
An extremely flexible yet vanilla-esque multiblock mod, that embraces aspects of MultiblockTweaker and Modular Machinery.

Multiblocked Multiblocked (mbd) is an extremely flexible yet vanilla-esque multiblock mod, that embraces aspects of MultiblockTweaker and Modular Mach

Cleanroom 36 Jan 4, 2023
A Spring Boot Camel boilerplate that aims to consume events from Apache Kafka, process it and send to a PostgreSQL database.

SPRING-BOOT CAMEL BOILERPLATE This is a Spring-Boot Camel Application model that you can use as a reference to study or even to use in your company. I

Bruno Delgado 45 Apr 4, 2022
Kong agent for Apache SkyWalking

Apache SkyWalking Kong Agent SkyWalking Kong agent built on SkyWalking Nginx Lua agent to trace Kong API gateway for Apache SkyWalking APM. Usage Inst

The Apache Software Foundation 23 Nov 20, 2022
Apache rocketmq

RocketMQ Streams Features 轻量级部署:可以单独部署,也支持集群部署 多种类型的数据输入以及输出,source支持 rocketmq , sink支持db, rocketmq 等 DataStream Example import org.apache.rocketmq.st

The Apache Software Foundation 145 Jan 6, 2023
The Apache Software Foundation 605 Dec 30, 2022
SpringBoot show case application for reactive-pulsar library (Reactive Streams adapter for Apache Pulsar Java Client)

Reactive Pulsar Client show case application Prerequisites Cloning reactive-pulsar Running this application requires cloning https://github.com/lhotar

Lari Hotari 9 Nov 10, 2022