Skip to content

Installation

Install the plugin as a dev dependency of the HarmonyOS project:

sh
npm install -D osslibraries-hvigor-plugin
sh
pnpm add -D osslibraries-hvigor-plugin
sh
yarn add -D osslibraries-hvigor-plugin
sh
bun add -D osslibraries-hvigor-plugin
sh
deno add --dev npm:osslibraries-hvigor-plugin
sh
vp add -D osslibraries-hvigor-plugin
sh
vlt install -D osslibraries-hvigor-plugin

Register

Open the hvigorfile.ts of the module whose rawfile should receive the output — typically entry — and add the plugin:

hvigorfile.ts
ts
import { hapTasks } from "@ohos/hvigor-ohos-plugin";
import { ossScanPlugin } from "osslibraries-hvigor-plugin";

export default {
  system: hapTasks,
  plugins: [ossScanPlugin()],
};

The plugin registers a task named ossScanLicenses; via postDependencies it runs after the module's CompileArkTS, ahead of resource packaging. On every build it scans oh_modules/ and writes the metadata to src/main/resources/rawfile/osslibraries.json.

Verify

Run a build and look for the plugin's log lines:

text
[osslibraries] scanning OHPM dependencies at /path/to/project
[osslibraries] wrote 128 libraries to .../rawfile/osslibraries.json (JSON)

The file appears in the module's rawfile directory. From here, install a UI package or the core package to render it — see Quick Start.