{"id":13787789,"url":"https://github.com/Bisnode/opa-gradle-plugin","last_synced_at":"2025-05-12T01:31:42.514Z","repository":{"id":40306513,"uuid":"221184575","full_name":"Bisnode/opa-gradle-plugin","owner":"Bisnode","description":"Plugin adding various tasks to help out integrating Open Policy Agent (OPA) in Gradle builds.","archived":false,"fork":false,"pushed_at":"2025-03-01T11:34:54.000Z","size":10488,"stargazers_count":12,"open_issues_count":13,"forks_count":5,"subscribers_count":8,"default_branch":"master","last_synced_at":"2025-03-01T12:26:17.781Z","etag":null,"topics":["gradle","gradle-plugin","opa","openpolicyagent","policies","policy","rego"],"latest_commit_sha":null,"homepage":null,"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/Bisnode.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2019-11-12T09:55:16.000Z","updated_at":"2025-03-01T11:34:58.000Z","dependencies_parsed_at":"2024-08-03T21:01:14.602Z","dependency_job_id":null,"html_url":"https://github.com/Bisnode/opa-gradle-plugin","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bisnode%2Fopa-gradle-plugin","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bisnode%2Fopa-gradle-plugin/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bisnode%2Fopa-gradle-plugin/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Bisnode%2Fopa-gradle-plugin/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Bisnode","download_url":"https://codeload.github.com/Bisnode/opa-gradle-plugin/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253659409,"owners_count":21943631,"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":["gradle","gradle-plugin","opa","openpolicyagent","policies","policy","rego"],"created_at":"2024-08-03T21:00:31.090Z","updated_at":"2025-05-12T01:31:42.219Z","avatar_url":"https://github.com/Bisnode.png","language":"Java","readme":"# Open Policy Agent plugin for Gradle\n![](https://github.com/Bisnode/opa-gradle-plugin/workflows/build/badge.svg)\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/Bisnode/opa-gradle-plugin.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/Bisnode/opa-gradle-plugin/alerts/)\n[![Language grade: Java](https://img.shields.io/lgtm/grade/java/g/Bisnode/opa-gradle-plugin.svg?logo=lgtm\u0026logoWidth=18)](https://lgtm.com/projects/g/Bisnode/opa-gradle-plugin/context:java)\n[![codecov](https://codecov.io/gh/Bisnode/opa-gradle-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/Bisnode/opa-gradle-plugin)\n[![Version](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/com/bisnode/opa/opa-gradle-plugin/maven-metadata.xml.svg?label=gradle)](https://plugins.gradle.org/plugin/com.bisnode.opa)\n\nPlugin adding various tasks to help out integrating Open Policy Agent (OPA) in Gradle builds.\n\n## Install\n\nSimply add the plugin to your build.gradle `plugins` declaration:\n\n[![Version](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/com/bisnode/opa/opa-gradle-plugin/maven-metadata.xml.svg?label=gradle)](https://plugins.gradle.org/plugin/com.bisnode.opa)\n\n```\nplugins {\n    id 'com.bisnode.opa' version '\u003csee above\u003e'\n}\n```\nFor legacy versions of Gradle, see instructions in the\n[Gradle plugin directory](https://plugins.gradle.org/plugin/com.bisnode.opa).\n\n**Prerequisites**: OPA installed on same machine as the tasks are run, either on `$PATH` or pointed out by the\n`location` configuration attribute (see Configuration below).\n\n## Configuration\n\nThe following configuration properties are made available by the plugin:\n```\nopa {\n    location    = 'path/opa/executable'     // default: use opa on $PATH\n    srcDir      = 'path/to/rego/src'        // default: src/main/rego\n    testDir     = 'path/to/rego/tests/'     // default: src/test/rego\n}\n```\n\n## Tasks\n\nThe plugin adds the following tasks:\n* `testRego` - Runs `opa test {srcDir} {testDir}` (see below).\n* `testRegoCoverage` - Runs `opa test {srcDir} {testDir} --coverage` saving report in `build/report/opa` directory.\n* `startOpa` - Start OPA in background for subsequent tasks like integration tests.\n* `stopOpa` - Stop OPA process started by `startOpa`.\n\n### testRego\n\nThe `testRego` task runs the unit tests found in `testDir` with all policies provided in `srcDir`. If not provided,\nthese directories default to `src/main/rego` (rego policies) and `src/test/rego` (rego tests) respectively.\n\nWhen invoked with `--info` output similar to `--info` is printed to console.\n\nExample:\n![Example testRego output](docs/resources/summary.png?raw=true)\n\n#### JUnit XML test results\n\nThe `testRego` task automatically converts the OPA test command output into JUnit XML and writes the output to the\n`build/tests-results/opa` directory. This enables any tool or system (such as CI/CD servers) that knows how to parse\nJUnit test results to include the OPA test results when handling test outcomes, like when compiling test reports.\n\nExample test report output in Atlassian Bamboo:\n![Example test report output](docs/resources/bamboo_test_results.png?raw=true)\n\n### Run Rego tests\n\nTo integrate policy tests into your regular Gradle pipeline you may add the `testRego` and/or `testRegoCoverage` tasks\nas dependencies of the `check` task:\n```\ncheck.dependsOn(testRego, testRegoCoverage)\n```\n\n### Run OPA for integration tests\n\nJust start/stop OPA before/after your test suite like this:\n```\nintegrationTest.dependsOn startOpa\nintegrationTest.finalizedBy stopOpa\n```\n\n## Contribution\n\nInterested in contributing? Please, start by reading [this document](https://github.com/Bisnode/opa-gradle-plugin/blob/master/CONTRIBUTING.md).\n","funding_links":[],"categories":["Language and Platform Integrations"],"sub_categories":["Java"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBisnode%2Fopa-gradle-plugin","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FBisnode%2Fopa-gradle-plugin","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FBisnode%2Fopa-gradle-plugin/lists"}