{"id":18418372,"url":"https://github.com/cachedjdk/cjdk-pre-commit","last_synced_at":"2026-05-16T18:37:00.245Z","repository":{"id":44362883,"uuid":"512232503","full_name":"cachedjdk/cjdk-pre-commit","owner":"cachedjdk","description":"JVM-based pre-commit hooks using cjdk","archived":false,"fork":false,"pushed_at":"2023-10-17T21:49:22.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-13T08:56:04.560Z","etag":null,"topics":["java","jvm","jvm-languages","pre-commit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cachedjdk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2022-07-09T16:24:54.000Z","updated_at":"2022-07-09T18:11:07.000Z","dependencies_parsed_at":"2024-12-24T17:33:39.552Z","dependency_job_id":null,"html_url":"https://github.com/cachedjdk/cjdk-pre-commit","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/cachedjdk/cjdk-pre-commit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachedjdk%2Fcjdk-pre-commit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachedjdk%2Fcjdk-pre-commit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachedjdk%2Fcjdk-pre-commit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachedjdk%2Fcjdk-pre-commit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cachedjdk","download_url":"https://codeload.github.com/cachedjdk/cjdk-pre-commit/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cachedjdk%2Fcjdk-pre-commit/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266763968,"owners_count":23980498,"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","status":"online","status_checked_at":"2025-07-23T02:00:09.312Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":["java","jvm","jvm-languages","pre-commit"],"created_at":"2024-11-06T04:13:27.010Z","updated_at":"2026-05-16T18:36:55.214Z","avatar_url":"https://github.com/cachedjdk.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!--\nThis file is part of cjdk-pre-commit.\nCopyright 2022 Board of Regents of the University of Wisconsin System\nSPDX-License-Identifier: MIT\n---\u003e\n\n# pre-commit hooks for Java tools\n\nThis repository contains [pre-commit](https://pre-commit.com/) hooks for\nrunning tools that require a Java Virtual Machine to run.\n\n(The tools may be applicable to languages other than Java.)\n\nThese hooks use [cjdk](https://cachedjdk.github.io/cjdk/latest/) to download\nand cache both the JVM and the tool packages, so that there is no need for\n`java` to be available on the `PATH` or for `JAVA_HOME` to be configured\ncorrectly for the tools. You can run the hooks using a different JDK from your\n`JAVA_HOME`.\n\nAvailable hooks:\n\n- [`checkstyle`](#checkstyle) - run [Checkstyle](https://checkstyle.org/)\n- [`pmd`](#pmd) - run the [PMD](https://pmd.github.io/) static analyzer\n- [`cpd`](#cpd) - run PMD's\n  [CPD](https://pmd.github.io/latest/pmd_userdocs_cpd.html) (copy-paste\n  detector)\n- [`google-java-format`](#google-java-format) - run\n  [google-java-format](https://github.com/google/google-java-format)\n\n## Requirements\n\nPython \u003e= 3.8; pre-commit \u003e= 2.0.0.\n\n## `checkstyle`\n\nRuns [Checkstyle](https://checkstyle.org/) on Java source files.\n\nArguments:\n\n- `--jdk=temruin-jre:17`: set the JDK or JRE to use, using **cjdk** syntax\n- `--tool-version=10.3.1`: set the Checkstyle version to use\n- `--jvm-arg=\u003carg\u003e`: any argument to pass to `java` (can be given multiple\n  times)\n- `--`: pass all subsequent arguments to Checkstyle\n\nSee also: Checkstyle [command line usage](https://checkstyle.org/cmdline.html).\n\nIf you override `args`, you need to include the `-c` option.\n\nBy default, the \"Sun\" style checks (`/sun_checks.xml`) included with Checkstyle\nare used.\n\n`.pre-commit-config.yaml` examples:\n\n```yaml\n- repo: https://github.com/cachedjdk/cjdk-pre-commit\n  rev: v0.1.0\n  hooks:\n    - id: checkstyle\n      args: [\"-c\", \"/google_checks.xml\"]\n      verbose: true  # /google_checks.xml only issues warnings.\n```\n\n```yaml\n- repo: https://github.com/cachedjdk/cjdk-pre-commit\n  rev: v0.1.0\n  hooks:\n    - id: checkstyle\n      args:\n        - --jdk=temurin-jre:17.0.3\n        - --tool-version=10.3.1\n        - --jvm-arg=-Xmx2048M\n        - --\n        - -c\n        - /sun_checks.xml\n```\n\n## `pmd`\n\nRuns the [PMD](https://pmd.github.io/) static code analyzer on source files\n(Java source files by default).\n\nArguments:\n\n- `--jdk=temurin-jre:17`: set the JDK or JRE to use, using **cjdk** syntax\n- `--tool-version=6.47.0`: set the PMD version to use\n- `--jvm-args=\"\u003cargs\u003e\"`: set `PMD_JAVA_OPTS` to `\u003cargs\u003e`\n- `--`: pass all subsequent arguments to PMD's command-line interface\n\nSee also: PMD command line\n[usage](https://pmd.github.io/latest/pmd_userdocs_installation.html#running-pmd-via-command-line)\nand [reference](https://pmd.github.io/latest/pmd_userdocs_cli_reference.html).\n\nIf you override `args`, you need to include the `-R` and `-d` options.\n\nBy default, the `rulesets/java/quickstart.xml` ruleset is run on the directory\n`src/main/java`.\n\n`.pre-commit-config.yaml` example:\n\n```yaml\n- repo: https://github.com/cachedjdk/cjdk-pre-commit\n  rev: v0.1.0\n  hooks:\n    - id: pmd\n      args:\n        - --\n        - -R\n        - my_ruleset.xml\n        - -d\n        - src/main/java\n```\n\n## `cpd`\n\nRuns [PMD](https://pmd.github.io/)'s copy-paste detector\n[CPD](https://pmd.github.io/latest/pmd_userdocs_cpd.html) on source files (Java\nsource files by default).\n\nArguments:\n\n- `--jdk=temurin-jre:17`: set the JDK or JRE to use, using **cjdk** syntax\n- `--tool-version=6.47.0`: set the PMD version to use\n- `--jvm-args=\"\u003cargs\u003e\"`: set `PMD_JAVA_OPTS` to `\u003cargs\u003e`\n- `--`: pass all subsequent arguments to CPD's command-line interface\n\nSee also: CPD command line\n[usage](https://pmd.github.io/latest/pmd_userdocs_installation.html#running-cpd-via-command-line)\nand [reference](https://pmd.github.io/latest/pmd_userdocs_cpd.html#cli-usage).\n\nIf you override `args`, you need to include the `--minimum-tokens` and\n`--files` options.\n\nBy default, the minimum token count is set to `100` and CPD is run on the files\nin `src/main/java`.\n\n`.pre-commit-config.yaml` example:\n\n```yaml\n- repo: https://github.com/cachedjdk/cjdk-pre-commit\n  rev: v0.1.0\n  hooks:\n    - id: cpd\n```\n\n`.pre-commit-config.yaml` example for running CPD on Python source files:\n\n```yaml\n- repo: https://github.com/cachedjdk/cjdk-pre-commit\n  rev: v0.1.0\n  hooks:\n    - id: cpd\n      types: [python]\n      args:\n        - --\n        - --language\n        - python\n        - --minimum-tokens\n        - \"100\"\n        - --files\n        - src\n```\n\n## `google-java-format`\n\nFormats Java source files using\n[google-java-format](https://github.com/google/google-java-format).\n\nArguments:\n\n- `--jdk=temruin:17`: set the JDK to use, using **cjdk** syntax\n- `--tool-version=1.15.0`: set the google-java-format version to use\n- `--jvm-arg=\u003carg\u003e`: any argument to pass to `java` (can be given multiple\n  times)\n- `--`: pass all subsequent arguments to google-java-format\n\nSee also: google-java-format command line usage, produced by running\n`cjdk_pre_commit google-java-format -- --help`.\n\nNote that google-java-format requires a full JDK and will not run with a JRE.\n\nIf you override `args`, you will probably want to include `--replace`.\n\n`.pre-commit-config.yaml` example:\n\n```yaml\n- repo: https://github.com/cachedjdk/cjdk-pre-commit\n  rev: v0.1.0\n  hooks:\n    - id: google-java-format\n      args:\n        - --\n        - --replace\n        - --skip-reflowing-long-strings\n```\n\n## Development\n\n```sh\ngit clone https://github.com/cachedjdk/cjdk-pre-commit.git\ncd cjdk-pre-commit\npython -m venv venv\necho '*' \u003evenv/.gitignore\nsource venv/bin/activate\npip install -e .[dev,testing]\npre-commit install\n```\n\nRun unit tests:\n\n```sh\npytest\n```\n\nRun system tests:\n\n```sh\npytest systemtests\n```\n\nRun tests as done by the CI:\n\n```sh\nnox\nnox -s systemtest\n```\n\n## Changelog\n\n### [0.1.0] - 2022-07-12\n\n- First release.\n\n[0.1.0]: https://github.com/cachedjdk/cjdk-pre-commit/tree/v0.1.0\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcachedjdk%2Fcjdk-pre-commit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcachedjdk%2Fcjdk-pre-commit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcachedjdk%2Fcjdk-pre-commit/lists"}