{"id":15522016,"url":"https://github.com/hyperxpro/brotli4j","last_synced_at":"2026-04-26T13:02:00.003Z","repository":{"id":38412140,"uuid":"304113716","full_name":"hyperxpro/Brotli4j","owner":"hyperxpro","description":"Brotli4j provides Brotli compression and decompression for Java.","archived":false,"fork":false,"pushed_at":"2026-04-01T21:29:00.000Z","size":4072,"stargazers_count":144,"open_issues_count":5,"forks_count":41,"subscribers_count":3,"default_branch":"main","last_synced_at":"2026-04-03T02:19:03.995Z","etag":null,"topics":["brotli","brotli-compression","brotli-decoder","brotli-decompressor","brotli-encoder","brotli-java","compression","java"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hyperxpro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":".github/CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":".github/SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":"NOTICE.txt","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null},"funding":{"github":"hyperxpro"}},"created_at":"2020-10-14T19:20:21.000Z","updated_at":"2026-04-01T21:29:04.000Z","dependencies_parsed_at":"2023-02-12T16:31:40.041Z","dependency_job_id":"5bba4ca3-13ba-4c9a-a4d2-0b7f64427c4b","html_url":"https://github.com/hyperxpro/Brotli4j","commit_stats":{"total_commits":180,"total_committers":19,"mean_commits":9.473684210526315,"dds":0.3222222222222222,"last_synced_commit":"3c271d543884dda1c2e8b9452aa3036fb8cc787c"},"previous_names":[],"tags_count":29,"template":false,"template_full_name":null,"purl":"pkg:github/hyperxpro/Brotli4j","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperxpro%2FBrotli4j","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperxpro%2FBrotli4j/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperxpro%2FBrotli4j/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperxpro%2FBrotli4j/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hyperxpro","download_url":"https://codeload.github.com/hyperxpro/Brotli4j/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hyperxpro%2FBrotli4j/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32297900,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-26T09:34:17.070Z","status":"ssl_error","status_checked_at":"2026-04-26T09:34:00.993Z","response_time":129,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["brotli","brotli-compression","brotli-decoder","brotli-decompressor","brotli-encoder","brotli-java","compression","java"],"created_at":"2024-10-02T10:39:06.388Z","updated_at":"2026-04-26T13:01:59.997Z","avatar_url":"https://github.com/hyperxpro.png","language":"Java","readme":"# Brotli4j\n\n[![Maven Central](https://img.shields.io/maven-central/v/com.aayushatharva.brotli4j/brotli4j-parent.svg?label=Maven%20Central)](https://search.maven.org/search?q=g:%22com.aayushatharva.brotli4j%22%20AND%20a:%22brotli4j-parent%22)\n\nBrotli4j provides Brotli compression and decompression for Java.\n\n## Supported Platforms:\n\n| Module                        | Architecture |                       Tested On |\n|:------------------------------|:------------:|--------------------------------:|\n| Windows (Windows Server 2022) |     x64      | JDK 1.8, JDK 11, JDK 17, JDK 21 |\n| Windows 11                    |   Aarch64    |                           JDK 8 |\n| Linux (CentOS 6)              |     x64      | JDK 1.8, JDK 11, JDK 17, JDK 21 |\n| Linux (Ubuntu 18.04)          |   Aarch64    | JDK 1.8, JDK 11, JDK 17, JDK 21 |\n| Linux (Ubuntu 18.04)          |    ARMv7     |         JDK 1.8, JDK 11, JDK 17 |\n| Linux (Ubuntu 18.04)          |    s390x     |                 JDK 1.8, JDK 11 |\n| Linux (Ubuntu 18.04)          |   ppc64le    |                 JDK 1.8, JDK 11 |\n| Linux (Ubuntu 20.04)          |   RISC-v64   | JDK 1.8, JDK 11, JDK 17, JDK 21 |\n| macOS (Catalina)              |     x64      | JDK 1.8, JDK 11, JDK 17, JDK 21 |\n| macOS (Catalina)              |   Aarch64    | JDK 1.8, JDK 11, JDK 17, JDK 21 |\n\n\u003e [!IMPORTANT]\n\u003e Install [Microsoft Visual C++ Redistributable](https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170) before running this\n\u003e library on Windows\n\n## Download\n\n### Maven\n\nFor maven, the natives will\n[import automatically by your system family and architecture](https://github.com/hyperxpro/Brotli4j/blob/main/natives/pom.xml#L38-L114).\n\n```xml\n\u003cdependency\u003e\n    \u003cgroupId\u003ecom.aayushatharva.brotli4j\u003c/groupId\u003e\n    \u003cartifactId\u003ebrotli4j\u003c/artifactId\u003e\n    \u003cversion\u003e1.23.0\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\n### Gradle\n\nFor gradle, some additional configuration must be added in order to allow gradle to resolve the correct native artifacts automatically,\nbased on your architecture.\nThis also supports [shadow](https://gradleup.com/shadow/), so that the shaded jar will contain the natives for *all* architectures.\n\n\u003e [!NOTE]\n\u003e Do note that when creating a [distribution zip/tar](https://docs.gradle.org/current/userguide/distribution_plugin.html),\n\u003e this will cause the distribution to only have the natives for the architecture it was compiled on.\n\u003e In order to have it include all natives, some additional configuration would be necessary.\n\u003e (For example, creating a custom configuration which has the `all` operating system \u0026 architecture, similar to what is done for shadow)\n\nThere are two ways it can be added:\n\n1. Project-wide configuration.  \n   For this, you must add the rule class as well as the global rule usage \u0026 global attributes to the `settings.gradle.kts`/`settings.gradle` file.\n   This rule will apply to *all* subprojects, and is best suited for working with multiple gradle subprojects.\n2. Subproject-specific configuration.  \n   For this, you must add the rule class as well as the rule usage \u0026 attributes to the `build.gradle.kts`/`build.gradle` file.\n   This rule will only apply to the project it is added to and will not be applied to other projects.\n   This is useful when, for example, you only have a single gradle subproject.\n\nAs of gradle 8.14.3, both of these methods work.\nBut they should also work for any version of gradle since 8.0.\nThey have not been tested on versions lower than that and may or may not work.\n\nNote that this method requires the use of some internal gradle apis, which may get break at some point in the future.\nIf it does, please open an issue.\nHowever, the apis seem to be somewhat stable, and if it does break then in the past it's just because they were moved to a different package.\n\nTo add the dependency, use:\n\n```kotlin\ndependencies {\n    implementation(\"com.aayushatharva.brotli4j:brotli4j:1.23.0\")\n    runtimeOnly(\"com.aayushatharva.brotli4j:natives:1.23.0\")\n}\n```\n\n\u003e [!IMPORTANT]\n\u003e Don't forget to also include the dependency metadata rule. You can see how to include the appropriate rule below based on which DSL you're using.\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eGradle Kotlin DSL\u003c/h4\u003e\u003c/summary\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eProject-Wide Configuration\u003c/summary\u003e\n\nTo configure the rule to be used project-wide, in addition to the below `Brotli4JRule` class,\nthis must also be added to the `settings.gradle.kts` file:\n\n```kotlin\nimport org.gradle.nativeplatform.internal.DefaultTargetMachineFactory\n\ngradle.beforeProject {\n    val host = DefaultTargetMachineFactory(objects).host()\n\n    // This tells gradle that we want an artifact with the correct OperatingSystemFamily and MachineArchitecture\n    // Gradle will then attempt to find the artifact with the best matching value, or if one cannot be found,\n    // fall back to the default (i.e. in the case of any dependency other than brotli4j)\n    configurations.configureEach {\n        // if the configuration is being published, don't set the attributes\n        if (isCanBeConsumed)\n            return@configureEach\n\n        attributes {\n            if (OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE !in keySet())\n                attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, host.operatingSystemFamily)\n            if (MachineArchitecture.ARCHITECTURE_ATTRIBUTE !in keySet())\n                attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, host.architecture)\n        }\n    }\n\n    // can be removed if not using shadow plugin\n    pluginManager.withPlugin(\"com.gradleup.shadow\") {\n        val runtimeClasspath by configurations.getting\n\n        configurations.register(\"shaded\") {\n            extendsFrom(runtimeClasspath)\n\n            isCanBeConsumed = false\n            isCanBeResolved = true\n            isCanBeDeclared = true\n\n            attributes {\n                attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))\n                attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))\n                attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))\n\n                attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named(\"all\"))\n                attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(\"all\"))\n            }\n        }\n    }\n}\n\ndependencyResolutionManagement {\n    components {\n        withModule\u003cBrotli4JRule\u003e(\"com.aayushatharva.brotli4j:natives\")\n    }\n}\n```\n\nIf you are using the shadow gradle plugin, then in your `build.gradle.kts` include:\n\n```kotlin\ndependencies {\n    shaded(\"com.aayushatharva.brotli4j:natives:1.23.0\")\n}\n\ntasks {\n    shadowJar.configure {\n        // shadow 8.x\n        configurations = listOf(project.configurations.shaded).map { it.get() }\n        // shadow 9.x\n        configurations.add(project.configurations.shaded)\n    }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSubproject-Specific Configuration\u003c/summary\u003e\n\nTo configure the rule to be used in a specific subproject, in addition to the below `Brotli4JRule` class,\nthis must also be added to the `build.gradle.kts` file:\n\n```kotlin\nimport org.gradle.nativeplatform.internal.DefaultTargetMachineFactory\n\nval host = DefaultTargetMachineFactory(objects).host()\n\n// This tells gradle that we want an artifact with the correct OperatingSystemFamily and MachineArchitecture\n// Gradle will then attempt to find the artifact with the best matching value, or if one cannot be found,\n// fall back to the default (i.e. in the case of any dependency other than brotli4j)\nconfigurations.configureEach {\n    // if the configuration is being published, don't set the attributes\n    if (isCanBeConsumed)\n        return@configureEach\n\n    attributes {\n        if (OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE !in keySet())\n            attributes.attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, host.operatingSystemFamily)\n        if (MachineArchitecture.ARCHITECTURE_ATTRIBUTE !in keySet())\n            attributes.attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, host.architecture)\n    }\n}\n\ndependencies {\n    components {\n        withModule\u003cBrotli4JRule\u003e(\"com.aayushatharva.brotli4j:natives\")\n    }\n}\n```\n\nIf you are using the shadow gradle plugin, then in your `build.gradle.kts` include:\n\n```kotlin\nval shaded by configurations.registering {\n    extendsFrom(configurations.runtimeClasspath)\n\n    isCanBeConsumed = false\n    isCanBeResolved = true\n    isCanBeDeclared = true\n\n    attributes {\n        attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage.JAVA_RUNTIME))\n        attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category.LIBRARY))\n        attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements.JAR))\n\n        attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named(\"all\"))\n        attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(\"all\"))\n    }\n}\n\ndependencies {\n    shaded(\"com.aayushatharva.brotli4j:natives:1.23.0\")\n}\n\ntasks {\n    shadowJar.configure {\n        // shadow 8.x\n        configurations = listOf(shaded).map { it.get() }\n        // shadow 9.x\n        configurations.add(shaded)\n    }\n}\n```\n\n\u003c/details\u003e\n\n```kotlin\n@CacheableRule\nabstract class Brotli4JRule : ComponentMetadataRule {\n    data class NativeVariant(val os: String, val arch: String, val classifier: String) {\n        fun dependency(version: String) = \"com.aayushatharva.brotli4j:native-${classifier}:${version}\"\n    }\n\n    private val nativeVariants = listOf(\n        NativeVariant(OperatingSystemFamily.WINDOWS, \"aarch64\", \"windows-aarch64\"),\n        NativeVariant(OperatingSystemFamily.WINDOWS, \"x86-64\", \"windows-x86_64\"),\n        NativeVariant(OperatingSystemFamily.MACOS, \"x86-64\", \"osx-x86_64\"),\n        NativeVariant(OperatingSystemFamily.MACOS, \"aarch64\", \"osx-aarch64\"),\n        NativeVariant(OperatingSystemFamily.LINUX, \"x86-64\", \"linux-x86_64\"),\n        NativeVariant(OperatingSystemFamily.LINUX, \"aarch64\", \"linux-aarch64\"),\n        NativeVariant(OperatingSystemFamily.LINUX, \"arm-v7\", \"linux-armv7\"),\n        NativeVariant(OperatingSystemFamily.LINUX, \"s390x\", \"linux-s390x\"),\n        NativeVariant(OperatingSystemFamily.LINUX, \"riscv64\", \"linux-riscv64\"),\n        NativeVariant(OperatingSystemFamily.LINUX, \"ppc64le\", \"linux-ppc64le\"),\n    )\n\n    @get:Inject\n    abstract val objects: ObjectFactory\n\n    override fun execute(context: ComponentMetadataContext) {\n        listOf(\"compile\", \"runtime\").forEach { base -\u003e addVariant(context, base) }\n    }\n\n    private fun addVariant(context: ComponentMetadataContext, base: String) {\n        val version = context.details.id.version\n\n        nativeVariants.forEach { variant -\u003e\n            context.details.addVariant(\"${variant.classifier}-${base}\", base) {\n                attributes {\n                    attributes.attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named(variant.os))\n                    attributes.attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(variant.arch))\n                }\n\n                withDependencies {\n                    add(variant.dependency(version))\n                }\n            }\n        }\n\n        context.details.addVariant(\"all-${base}\", base) {\n            attributes {\n                attributes.attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named(\"all\"))\n                attributes.attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(\"all\"))\n            }\n\n            withDependencies {\n                nativeVariants.forEach { variant -\u003e\n                    add(variant.dependency(version))\n                }\n            }\n        }\n    }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003e\u003ch4\u003eGradle Groovy DSL\u003c/h4\u003e\u003c/summary\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eProject-Wide Configuration\u003c/summary\u003e\n\nTo configure the rule to be used project-wide, in addition to the below `Brotli4JRule` class,\nthis must also be added to the `settings.gradle` file:\n\n```groovy\ngradle.beforeProject {\n    def host = new DefaultTargetMachineFactory(objects).host()\n\n    // This tells gradle that we want an artifact with the correct OperatingSystemFamily and MachineArchitecture\n    // Gradle will then attempt to find the artifact with the best matching value, or if one cannot be found,\n    // fall back to the default (i.e. in the case of any dependency other than brotli4j)\n    configurations.configureEach {\n        // if the configuration is being published, don't set the attributes\n        if (canBeConsumed)\n            return\n\n        attributes {\n            if (OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE !in keySet())\n                attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, host.operatingSystemFamily)\n            if (MachineArchitecture.ARCHITECTURE_ATTRIBUTE !in keySet())\n                attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, host.architecture)\n        }\n    }\n\n    // can be removed if not using shadow plugin\n    pluginManager.withPlugin(\"com.gradleup.shadow\") {\n        configurations.register(\"shaded\") {\n            extendsFrom(configurations.runtimeClasspath)\n\n            canBeConsumed = false\n            canBeResolved = true\n            canBeDeclared = true\n\n            attributes {\n                attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))\n                attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))\n                attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR))\n\n                attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named(OperatingSystemFamily, \"all\"))\n                attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(MachineArchitecture, \"all\"))\n            }\n        }\n    }\n}\n\ndependencyResolutionManagement {\n    components {\n        withModule(\"com.aayushatharva.brotli4j:natives\", Brotli4JRule)\n    }\n}\n```\n\nIf you are using the shadow gradle plugin, then in your `build.gradle` include:\n\n```kotlin\ndependencies {\n    shaded(\"com.aayushatharva.brotli4j:natives:1.23.0\")\n}\n\ntasks {\n    shadowJar.configure {\n        configurations = [project.configurations.shaded]\n    }\n}\n```\n\n\u003c/details\u003e\n\n\u003cdetails\u003e\n\u003csummary\u003eSubproject-Specific Configuration\u003c/summary\u003e\n\nTo configure the rule to be used in a specific subproject, in addition to the below `Brotli4JRule` class,\nthis must also be added to the `build.gradle` file:\n\n```groovy\ndef host = new DefaultTargetMachineFactory(objects).host()\n\n// This tells gradle that we want an artifact with the correct OperatingSystemFamily and MachineArchitecture\n// Gradle will then attempt to find the artifact with the best matching value, or if one cannot be found,\n// fall back to the default (i.e. in the case of any dependency other than brotli4j)\nconfigurations.configureEach {\n    // if the configuration is being published, don't set the attributes\n    if (canBeConsumed)\n        return\n\n    def isShadow = name.containsIgnoreCase(\"shadow\")\n    attributes {\n        if (OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE !in keySet())\n            attributes.attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, host.operatingSystemFamily)\n        if (MachineArchitecture.ARCHITECTURE_ATTRIBUTE !in keySet())\n            attributes.attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, host.architecture)\n    }\n}\n\ndependencies {\n    components {\n        withModule(\"com.aayushatharva.brotli4j:natives\", Brotli4JRule)\n    }\n}\n```\n\nIf you are using the shadow gradle plugin, then in your `build.gradle` include:\n\n```kotlin\nconfigurations.register(\"shaded\") {\n    extendsFrom(configurations.runtimeClasspath)\n\n    canBeConsumed = false\n    canBeResolved = true\n    canBeDeclared = true\n\n    attributes {\n        attribute(Usage.USAGE_ATTRIBUTE, objects.named(Usage, Usage.JAVA_RUNTIME))\n        attribute(Category.CATEGORY_ATTRIBUTE, objects.named(Category, Category.LIBRARY))\n        attribute(LibraryElements.LIBRARY_ELEMENTS_ATTRIBUTE, objects.named(LibraryElements, LibraryElements.JAR))\n\n        attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named(OperatingSystemFamily, \"all\"))\n        attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(MachineArchitecture, \"all\"))\n    }\n}\n\ndependencies {\n    shaded(\"com.aayushatharva.brotli4j:natives:1.23.0\")\n}\n\ntasks {\n    shadowJar.configure {\n        configurations = [project.configurations.shaded]\n    }\n}\n```\n\n\u003c/details\u003e\n\n```groovy\n@CacheableRule\nabstract class Brotli4JRule implements ComponentMetadataRule {\n    @Inject\n    abstract ObjectFactory getObjects()\n\n    void execute(ComponentMetadataContext context) {\n        for (base in [\"compile\", \"runtime\"]) {\n            addVariant(context, base)\n        }\n    }\n\n    void addVariant(ComponentMetadataContext context, String base) {\n        def nativeVariants = [\n            [ os: OperatingSystemFamily.WINDOWS, arch: \"aarch64\", classifier: \"windows-aarch64\" ],\n            [ os: OperatingSystemFamily.WINDOWS, arch: \"x86-64\",  classifier: \"windows-x86_64\"  ],\n            [ os: OperatingSystemFamily.MACOS,   arch: \"x86-64\",  classifier: \"osx-x86_64\"      ],\n            [ os: OperatingSystemFamily.MACOS,   arch: \"aarch64\", classifier: \"osx-aarch64\"     ],\n            [ os: OperatingSystemFamily.LINUX,   arch: \"x86-64\",  classifier: \"linux-x86_64\"    ],\n            [ os: OperatingSystemFamily.LINUX,   arch: \"aarch64\", classifier: \"linux-aarch64\"   ],\n            [ os: OperatingSystemFamily.LINUX,   arch: \"arm-v7\",  classifier: \"linux-armv7\"     ],\n            [ os: OperatingSystemFamily.LINUX,   arch: \"s390x\",   classifier: \"linux-s390x\"     ],\n            [ os: OperatingSystemFamily.LINUX,   arch: \"riscv64\", classifier: \"linux-riscv64\"   ],\n            [ os: OperatingSystemFamily.LINUX,   arch: \"ppc64le\", classifier: \"linux-ppc64le\"   ],\n        ]\n\n        def version = context.details.id.version\n\n        nativeVariants.forEach { variant -\u003e\n            context.details.addVariant(\"${variant.classifier}-${base}\", base) {\n                attributes {\n                    attributes.attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named(OperatingSystemFamily, variant.os))\n                    attributes.attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(MachineArchitecture, variant.arch))\n                }\n\n                withDependencies {\n                    add(\"com.aayushatharva.brotli4j:native-${variant.classifier}:${version}\")\n                }\n            }\n        }\n\n        context.details.addVariant(\"all-${base}\", base) {\n            attributes {\n                attributes.attribute(OperatingSystemFamily.OPERATING_SYSTEM_ATTRIBUTE, objects.named(OperatingSystemFamily, \"all\"))\n                attributes.attribute(MachineArchitecture.ARCHITECTURE_ATTRIBUTE, objects.named(MachineArchitecture, \"all\"))\n            }\n\n            withDependencies {\n                nativeVariants.forEach { variant -\u003e\n                    add(\"com.aayushatharva.brotli4j:native-${variant.classifier}:${version}\")\n                }\n            }\n        }\n    }\n}\n```\n\u003c/details\u003e\n\n## Usage\n\n### Loading native library:\n\n\n\u003e [!WARNING]\n\u003e Call `Brotli4jLoader.ensureAvailability()` in your application once before using Brotli4j. This will load\n\u003e Brotli4j native library automatically using automatic dependency resolution.\n\n\u003e [!TIP]\n\u003e However, its possible to load native library manually from custom path by specifying System Property `\"brotli4j.library.path\"`.\n\n### Direct API\n\n```java\npublic class Example {\n    public static void main(String[] args) {\n        // Load the native library\n        Brotli4jLoader.ensureAvailability();\n\n        // Compress data and get output in byte array\n        byte[] compressed = Encoder.compress(\"Meow\".getBytes());\n\n        // Decompress data and get output in DirectDecompress\n        DirectDecompress directDecompress = Decoder.decompress(compressed); // or DirectDecompress.decompress(compressed);\n\n        if (directDecompress.getResultStatus() == DecoderJNI.Status.DONE) {\n            System.out.println(\"Decompression Successful: \" + new String(directDecompress.getDecompressedData()));\n        } else {\n            System.out.println(\"Some Error Occurred While Decompressing\");\n        }\n    }\n}\n```\n\n### Compressing a stream:\n\n```java\npublic class Example {\n    public static void main(String[] args) {\n        // Load the native library\n        Brotli4jLoader.ensureAvailability();\n\n        FileInputStream inFile = new FileInputStream(filePath);\n        FileOutputStream outFile = new FileOutputStream(filePath + \".br\");\n\n        Encoder.Parameters params = Encoder.Parameters.create(4);\n\n        BrotliOutputStream brotliOutputStream = new BrotliOutputStream(outFile, params);\n\n        int read = inFile.read();\n        while (read \u003e -1) {\n            brotliOutputStream.write(read);\n            read = inFile.read();\n        }\n\n        // Close the BrotliOutputStream. This also closes the FileOutputStream.\n        brotliOutputStream.close();\n        inFile.close();\n    }\n}\n```\n\n### Decompressing a stream:\n\n```java\npublic class Example {\n    public static void main(String[] args) {\n        // Load the native library\n        Brotli4jLoader.ensureAvailability();\n\n        FileInputStream inFile = new FileInputStream(filePath);\n        FileOutputStream outFile = new FileOutputStream(decodedfilePath);\n\n        BrotliInputStream brotliInputStream = new BrotliInputStream(inFile);\n\n        int read = brotliInputStream.read();\n        while (read \u003e -1) {\n            outFile.write(read);\n            read = brotliInputStream.read();\n        }\n\n        // Close the BrotliInputStream. This also closes the FileInputStream.\n        brotliInputStream.close();\n        outFile.close();\n    }\n}\n```\n\n### Additional Notes\n\n\u003e [!NOTE]\n\u003e Windows-AArch64: Brotli4j is compiled with JDK 11 with JDK 8 as target because JDK 8 Windows Aarch64 builds are not available at the moment.\n\u003e However, it should not cause any problem on running it on JDK 8 or plus.\n\n\u003e [!IMPORTANT]\n\u003e RISC-V64: This platform is only supported by JDK 11+ (i.e. JDK 11, JDK 17, JDK 21, atm.).\n\u003e However, Since Brotli4j was always compiled with JDK 8, we're cross-compiling RISC-V64 native module bytecode with JDK 8.\n\u003e This should not break existing application using Broti4j.\n\u003e However, you should use JDK 11+ for using Brotli4j on RISC-V64 platform.\n\n## Projects that use Brotli4j\n\n- [Netty](https://github.com/netty/netty)\n- [reactor-netty](https://github.com/reactor/reactor-netty)\n- [Armeria](https://github.com/line/armeria)\n- [vert.x](https://github.com/eclipse-vertx/vert.x)\n- [gatling](https://github.com/gatling/gatling)\n- [Netflix Zuul](https://github.com/netflix/zuul)\n- [hbase](https://github.com/apache/hbase)\n- [micronaut](https://github.com/micronaut-projects/micronaut-core)\n- [async-http-client](https://github.com/AsyncHttpClient/async-http-client)\n- [Apache NiFi](https://github.com/apache/nifi)\n- [quarkus](https://github.com/quarkusio/quarkus)\n- [sbt-web-brotli](https://github.com/dwickern/sbt-web-brotli)\n- [hardwood](https://github.com/hardwood-hq/hardwood)\n\n## Sponsors\n\nJProfiler is supporting Brotli4J with its full-featured Java Profiler. JProfiler's intuitive UI helps you resolve\nperformance bottlenecks, pin down memory leaks and understand threading issues. Click below to know more:\n\n\u003ca href=\"https://www.ej-technologies.com/products/jprofiler/overview.html\" target=\"_blank\" title=\"File Management\"\u003e\n  \u003cimg src=\"https://www.ej-technologies.com/images/product_banners/jprofiler_large.png\" alt=\"File Management\"\u003e\n\u003c/a\u003e\n","funding_links":["https://github.com/sponsors/hyperxpro"],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperxpro%2Fbrotli4j","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhyperxpro%2Fbrotli4j","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhyperxpro%2Fbrotli4j/lists"}