{"id":19693153,"url":"https://github.com/breadrock1/adblock-coffee","last_synced_at":"2025-03-04T15:26:22.172Z","repository":{"id":246894355,"uuid":"824577350","full_name":"breadrock1/adblock-coffee","owner":"breadrock1","description":"There is the simplest Java wrapper for the adblock-rust library.","archived":false,"fork":false,"pushed_at":"2025-01-07T10:02:23.000Z","size":1050,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T21:16:10.312Z","etag":null,"topics":["adblock","adblock-rust","java","java-native-interface","jni","jni-rust","maven","rust"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/breadrock1.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-07-05T12:33:53.000Z","updated_at":"2025-01-07T09:59:34.000Z","dependencies_parsed_at":"2024-07-16T16:06:07.606Z","dependency_job_id":null,"html_url":"https://github.com/breadrock1/adblock-coffee","commit_stats":null,"previous_names":["breadrock1/adblock-coffee"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breadrock1%2Fadblock-coffee","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breadrock1%2Fadblock-coffee/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breadrock1%2Fadblock-coffee/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/breadrock1%2Fadblock-coffee/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/breadrock1","download_url":"https://codeload.github.com/breadrock1/adblock-coffee/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241870662,"owners_count":20034334,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["adblock","adblock-rust","java","java-native-interface","jni","jni-rust","maven","rust"],"created_at":"2024-11-11T19:15:53.629Z","updated_at":"2025-03-04T15:26:22.164Z","avatar_url":"https://github.com/breadrock1.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# adblock-coffee\n[![Create release](https://github.com/breadrock1/Adblock-coffee/actions/workflows/release.yml/badge.svg)](https://github.com/breadrock1/Adblock-coffee/actions/workflows/release.yml)\n[![Pipelines](https://img.shields.io/github/actions/workflow/status/breadrock1/adblock-coffee/build.yml?branch=master)](https://img.shields.io/github/actions/workflow/status/breadrock1/adblock-coffee/build.yml?branch=master)\n[![Last release: ](https://img.shields.io/github/v/release/breadrock1/adblock-coffee?display_name=release)](https://img.shields.io/github/v/release/breadrock1/adblock-coffee?display_name=release)\n\nThis project is the simplest Java wrapper for the `adblock-rust` library, allowing you to use the powerful ad-blocking capabilities of `adblock-rust` in your Java applications.\n\n## Table of Contents\n\n- [Introduction](#introduction)\n- [Features](#features)\n- [Installation](#installation)\n- [Usage](#usage)\n\n## Introduction\n\n`adblock-rust` is a high-performance ad-blocking library written in Rust. This project provides a Java wrapper around `adblock-rust`, enabling Java developers to integrate ad-blocking functionality into their applications seamlessly.\n\n## Features\n\n- High-performance ad-blocking using `adblock-rust`.\n- Easy-to-use Java API.\n- Cross-platform support.\n\n## Installation\n\n### Prerequisites\n\n- Java Development Kit (JDK) 8 or higher.\n- Rust and Cargo (for building the native library).\n\n### Building the Native Library\n\nFirst, you need to build the `adblock-rust` library and generate the shared library file (`.so`, `.dll`, or `.dylib` depending on your OS).\n\n1. Clone the `adblock-rust` repository:\n2. Build the library: \n```shell \ncargo build --release --manifest-path adblock-rs/Cargo.toml\nmvn install\n```\n\nTo build it for Android platforms, just use NDK (see installation on official site):\n```shell\n cargo ndk -t aarch64-linux-android -o ./target build --release\n mv arm64-v8 release \n```\n\nGo back to project root and enter:\n```shell\nmvn install\n```\n\nIf you want to build library to another platform add option `--target` with needed platform like `aarch64-unknown-linux-gnu`, .\nAfter that, check the path of the built library exists in `pom.xml` `maven-resources-plugin` section. By default, `rustup` uses the current platform and creates `target/{debug,release}` directories.\nAfter switching the target platform using `rustup`, these directories are created as `targer/{target-platform}/{debug,release}` directories.\n\nExample of building the library for the `aarch64-unknown-linux-gnu` target: \n```shell\ncargo build --release --target aarch64-unknown-linux-gnu --manifest-path adblock-rs/Cargo.toml\n```\n\nYou alse need to update the `pom.xml` file:\n```xml\n\u003cplugin\u003e\n  \u003cgroupId\u003eorg.apache.maven.plugins\u003c/groupId\u003e\n  \u003cartifactId\u003emaven-resources-plugin\u003c/artifactId\u003e\n  \u003cversion\u003e3.2.0\u003c/version\u003e\n  \u003cexecutions\u003e\n    \u003cexecution\u003e\n      \u003cid\u003ecopy-native-libs\u003c/id\u003e\n      \u003cphase\u003eprocess-resources\u003c/phase\u003e\n      \u003cgoals\u003e\n        \u003cgoal\u003ecopy-resources\u003c/goal\u003e\n      \u003c/goals\u003e\n      \u003cconfiguration\u003e\n        \u003coutputDirectory\u003e${project.basedir}/target/lib\u003c/outputDirectory\u003e\n        \u003cresources\u003e\n          \u003cresource\u003e\n            \u003cdirectory\u003e${project.basedir}/adblock-rs/target/aarch64-linux-android/debug/\u003c/directory\u003e\n            \u003cincludes\u003e\n              \u003cinclude\u003e**/*.dylib\u003c/include\u003e\n              \u003cinclude\u003e**/*.so\u003c/include\u003e\n              \u003cinclude\u003e**/*.dll\u003c/include\u003e\n            \u003c/includes\u003e\n          \u003c/resource\u003e\n          \u003cresource\u003e\n            \u003cdirectory\u003e${project.basedir}/adblock-rs/target/aarch64-linux-android/release/\u003c/directory\u003e\n            \u003cincludes\u003e\n              \u003cinclude\u003e**/*.dylib\u003c/include\u003e\n              \u003cinclude\u003e**/*.so\u003c/include\u003e\n              \u003cinclude\u003e**/*.dll\u003c/include\u003e\n            \u003c/includes\u003e\n          \u003c/resource\u003e\n        \u003c/resources\u003e\n      \u003c/configuration\u003e\n    \u003c/execution\u003e\n  \u003c/executions\u003e\n\u003c/plugin\u003e\n```\n\nAnd build jar:\n```shell\nmvn install\n```\n\n3. Locate the generated shared library file in the `target/release` directory.\n```java\npublic class Main {    \n    public static void main(String[] args) {\n        List\u003cString\u003e rules = new ArrayList\u003c\u003e(List.of(\n            \"-advertisement-icon.\",\n            \"-advertisement-management/\",\n            \"-advertisement.\",\n            \"-advertisement/script.\"\n        ));\n        \n        AdvtBlocker blocker = AdvtBlocker.createInstance(rules);\n    }\n}\n```\n\n### Integrating with Your Java Project\n\n1. Copy the shared library file to a directory accessible by your Java application.\n\n2. Add the Java wrapper library to your project. You can do this by including the JAR file or adding the source code directly to your project.\n\n## Usage\n\n### Loading the Native Library\n\nBefore using the wrapper, you need to load the native library. This can be done using `System.loadLibrary` or `System.load`.\n\n### Using the Wrapper\n\nHere is an example of how to use the Java wrapper to block ads:\n\n```java\nimport com.example.adblock.AdblockEngine;\n\npublic class Main {\n    public static void main(String[] args) {\n        List\u003cString\u003e rules = new ArrayList\u003c\u003e(List.of(\n            \"-advertisement-icon.\",\n            \"-advertisement-management/\",\n            \"-advertisement.\",\n            \"-advertisement/script.\"\n        ));\n        \n        AdvtBlocker blocker = AdvtBlocker.createInstance(rules);\n        boolean result = blocker.checkUrls(\n            \"http://example.com/-advertisement-icon.\",\n            \"http://example.com/helloworld\",\n            \"image\"\n        );\n        \n        System.out.println(result);\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreadrock1%2Fadblock-coffee","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbreadrock1%2Fadblock-coffee","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbreadrock1%2Fadblock-coffee/lists"}