{"id":13760457,"url":"https://github.com/taylorwood/clj.native-image","last_synced_at":"2025-10-07T09:16:19.616Z","repository":{"id":48088380,"uuid":"134888355","full_name":"taylorwood/clj.native-image","owner":"taylorwood","description":"Build GraalVM native images with Clojure Deps and CLI tools","archived":false,"fork":false,"pushed_at":"2021-08-07T12:27:34.000Z","size":30,"stargazers_count":277,"open_issues_count":3,"forks_count":19,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-05-06T20:02:10.844Z","etag":null,"topics":["cli","clojure","graalvm","native-image"],"latest_commit_sha":null,"homepage":"","language":"Clojure","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/taylorwood.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-05-25T17:55:03.000Z","updated_at":"2025-04-25T18:30:40.000Z","dependencies_parsed_at":"2022-08-12T18:20:38.229Z","dependency_job_id":null,"html_url":"https://github.com/taylorwood/clj.native-image","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylorwood%2Fclj.native-image","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylorwood%2Fclj.native-image/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylorwood%2Fclj.native-image/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/taylorwood%2Fclj.native-image/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/taylorwood","download_url":"https://codeload.github.com/taylorwood/clj.native-image/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253402113,"owners_count":21902800,"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":["cli","clojure","graalvm","native-image"],"created_at":"2024-08-03T13:01:10.651Z","updated_at":"2025-10-07T09:16:14.586Z","avatar_url":"https://github.com/taylorwood.png","language":"Clojure","funding_links":[],"categories":["Clojure"],"sub_categories":[],"readme":"# clj.native-image\n\nBuild [GraalVM](https://www.graalvm.org) native images using [Clojure Deps and CLI tools](https://clojure.org/guides/deps_and_cli).\n\nThis should be useful for creating lightweight, native CLI executables using Clojure and `deps.edn`.\nSee [clj.native-cli](https://github.com/taylorwood/clj.native-cli) for a starter project template.\n\n_This project depends on tools.deps.alpha and should be considered alpha itself._\n\n## Prerequisites\n\n- [Clojure CLI tools](https://clojure.org/guides/getting_started#_clojure_installer_and_cli_tools)\n- [GraalVM](https://www.graalvm.org/downloads/)\n\n  **NOTE:** As of GraalVM 19.0.0, `native-image` is no longer included by default:\n  \u003e Native Image was extracted from the base GraalVM distribution. Currently it is available as an early adopter plugin. To install it, run: `gu install native-image`. After this additional step, the `native-image` executable will be in the `bin` directory, as for the previous releases.\n\n  ```\n  ➜ $GRAALVM_HOME/bin/gu install native-image\n  Downloading: Component catalog from www.graalvm.org\n  Processing component archive: Native Image\n  Downloading: Component native-image: Native Image  from github.com\n  Installing new component: Native Image licence files (org.graalvm.native-image, version 19.0.0)\n  ```\n\n## Usage\n\nAssuming a project structure like this:\n```\n.\n├── deps.edn\n└── src\n    └── core.clj\n```\n\nIn your `deps.edn` specify an alias with a dependency on `clj.native-image`:\n```clojure\n{:aliases {:native-image\n           {:main-opts [\"-m\" \"clj.native-image\" \"core\"\n                        \"--initialize-at-build-time\"\n                        ;; optional native image name override\n                        \"-H:Name=core\"]\n            :jvm-opts [\"-Dclojure.compiler.direct-linking=true\"]\n            :extra-deps\n            {clj.native-image/clj.native-image\n             {:git/url \"https://github.com/taylorwood/clj.native-image.git\"\n              :sha \"7708e7fd4572459c81f6a6b8e44c96f41cdd92d4\"}}}}}\n```\n\nWhere `core.clj` is a class with `-main` entrypoint, for example:\n```clojure\n(ns core\n  (:gen-class))\n(defn -main [\u0026 args]\n  (println \"Hello, World!\"))\n```\n\nFrom your project directory, invoke `clojure` with the `native-image` alias, specifying the main namespace\n(`core` in example above):\n```\n➜ clojure -A:native-image\nLoading core\nCompiling core\nBuilding native image 'core' with classpath 'classes:src:etc.'\n\n   classlist:   1,944.26 ms\n   8\u003c----------------------\n     [total]:  38,970.37 ms\n```\nNote: Either `GRAALVM_HOME` environment variable must be set, or GraalVM's `native-image` path must be passed as an argument,\nand any [additional arguments](https://www.graalvm.org/docs/reference-manual/aot-compilation/#image-generation-options)\nwill be passed to `native-image` e.g.:\n```\n➜ clojure -A:native-image --verbose\n```\n\nYou can now execute the native image:\n```\n➜ ./core\nHello, World!\n```\n\nSee [this Gist](https://gist.github.com/taylorwood/23d370f70b8b09dbf6d31cd4f27d31ff) for another example.\n\n### Example Projects\n\nThere are example deps.edn projects in the [lein-native-image](https://github.com/taylorwood/lein-native-image) repo:\n- [jdnsmith](https://github.com/taylorwood/lein-native-image/blob/master/examples/http-api) - CLI JSON-to-EDN transformer\n- [http-api](https://github.com/taylorwood/lein-native-image/blob/master/examples/http-api) - simple HTTP API server\n- [clojurl](https://github.com/taylorwood/clojurl) - cURL-like tool using clojure.spec, HTTPS, hiccup\n\n## Caveats\n\nThe `--no-server` flag is passed to `native-image` by default, to avoid creating orphaned build servers.\n\nAlso see [caveats](https://github.com/taylorwood/lein-native-image#caveats) section of lein-native-image.\n\n## References\n\n[GraalVM Native Image AOT Compilation](https://www.graalvm.org/docs/reference-manual/aot-compilation/)\n\nThis project was inspired by [depstar](https://github.com/healthfinch/depstar).\n\n## Contributing\n\nYou'll need Clojure CLI tooling and GraalVM installed to test locally.\nJust change the source of the `clj.native-image` dependency to a `:local/root` instead of `:git/url`.\n\nIssues, PRs, and suggestions are welcome!\n\n## License\n\nCopyright © 2018 Taylor Wood.\n\nDistributed under the MIT License.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaylorwood%2Fclj.native-image","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftaylorwood%2Fclj.native-image","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftaylorwood%2Fclj.native-image/lists"}