{"id":20019431,"url":"https://github.com/tambapps/groovy-script-compiler","last_synced_at":"2025-10-14T13:32:44.139Z","repository":{"id":130832221,"uuid":"416110959","full_name":"tambapps/groovy-script-compiler","owner":"tambapps","description":"Compiles Groovy script to an executable jar, an appimage or native binary executable","archived":false,"fork":false,"pushed_at":"2021-10-17T19:38:07.000Z","size":139,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-02T03:27:27.869Z","etag":null,"topics":["graalvm-native-image","groovy","groovy-script","jar","native-image"],"latest_commit_sha":null,"homepage":"","language":"Groovy","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/tambapps.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2021-10-11T23:00:50.000Z","updated_at":"2021-10-17T19:38:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"df7d7caf-5fa0-49be-b486-53f2eda0c4ef","html_url":"https://github.com/tambapps/groovy-script-compiler","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/tambapps/groovy-script-compiler","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tambapps%2Fgroovy-script-compiler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tambapps%2Fgroovy-script-compiler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tambapps%2Fgroovy-script-compiler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tambapps%2Fgroovy-script-compiler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tambapps","download_url":"https://codeload.github.com/tambapps/groovy-script-compiler/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tambapps%2Fgroovy-script-compiler/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279018715,"owners_count":26086609,"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-10-14T02:00:06.444Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["graalvm-native-image","groovy","groovy-script","jar","native-image"],"created_at":"2024-11-13T08:27:34.698Z","updated_at":"2025-10-14T13:32:44.121Z","avatar_url":"https://github.com/tambapps.png","language":"Groovy","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Groovy script compiler\n\nThis app allows you to compile a Groovy script (along with it's dependencies) into an executable jar, an appimage or an executable native binary.\n\nIt will compile your script into a `.class` file, fetch the dependencies (including groovy) and build\nan executable jar. With this jar, it can convert it into an appimage using [jpackage](https://docs.oracle.com/en/java/javase/14/docs/specs/man/jpackage.html) or into a \nnative binary executable using [native-image](https://www.graalvm.org/reference-manual/native-image/).\n\n## Why this project\n\nAt first, I wanted to make a tool that converts a groovy script into a binary executable. \nI wanted to have only one compiled file to execute a groovy script fastly. You could put `#!/user/bin/env groovy` at the \nfirst line of your script and then make your script executable (`chmod u+x MyScript.groovy`) but running it\nwould still be a little slow since groovy will have to compile your script everytime you run it.\n\nTo generate an executable file, I first looked at Java `jpackage` that generates appimage, but I saw \nthat it generates other files along with the executable, and if you delete these other files, it doesn't work anymore.\n\nThen I saw GraalVM `native-image`, but its capabilities with Groovy are limited (e.g. you can't use Groovy dynamic features).\n\nSo I decided to focus on generating a jar compatible with any JVM 8+.\n\n\n## How to install\nYou don't need to have Groovy installed in order to generate the jar. You just need Java 8+ and Maven\n\nRun\n```shell\nmvn compile\n```\nThis will generate the executable jar with dependencies in a `target/` folder.\n\n## How to use\nProvide an input file to convert it into an executable jar \n(jar with all the required dependencies), an appimage, or a native binary executable. \n\nNote that if your script use classes from Groovy subprojects (e.g. JsonSlurper from groovy-json) \nyou'll have to tell the program, so that the classes are included in the generated output. If it uses\nother non-groovy libraries, you can also provide the dependencies jars with the `-a` argument.\n\n```text\nUsage: \u003cmain class\u003e [-dh] [-j=\u003cjpackageFile\u003e] [-m=\u003cmainClass\u003e]\n                    [-n=\u003cnativeImageFile\u003e] [-o=\u003coutputDir\u003e] [-t=\u003coutputType\u003e]\n                    [-v=\u003cversion\u003e] [-a=\u003cadditionalJars\u003e[,\n                    \u003cadditionalJars\u003e...]]... [-s=\u003csubProjects\u003e[,\n                    \u003csubProjects\u003e...]]... inputFile\n      inputFile             The script file to compile (can be an executable\n                              jar instead for appimage and native-binary)\n  -a, --additional-jars=\u003cadditionalJars\u003e[,\u003cadditionalJars\u003e...]\n                            Comma-separated list of Additional jars. E.g. if\n                              your script use a non Groovy library, it would be\n                              the jar of the library\n  -d, --debug               Display more logs\n  -h, --help                display usage\n  -j, --jpackage-path=\u003cjpackageFile\u003e\n                            Path of jpackage. Only useful for 'appimage' type\n  -m, --main-class=\u003cmainClass\u003e\n                            Main class. Defaults to the input file's name\n  -n, --native-image-path=\u003cnativeImageFile\u003e\n                            Path of native-image (graalvm). Only useful for\n                              'native-binary' type\n  -o, --output-dir=\u003coutputDir\u003e\n                            Folder in which to put output file. Defaults to\n                              current directory\n  -s, --groovy-subprojects=\u003csubProjects\u003e[,\u003csubProjects\u003e...]\n                            Comma-separated list of Groovy subprojects to\n                              include in the jar\n  -t, --type=\u003coutputType\u003e   The type of output to create\n                              Default: JAR\n  -v, --version=\u003cversion\u003e   Groovy version to use\n                              Default: 3.0.9\n```\n\nfor example\n\n```shell\njava -jar groovyjar.jar -o=native-binary -s=json,templates HelloWorld.groovy\n```\n\n### Generate a JAR\nThis is the default output type. You just have to provide the input script and the compilation can begin\nThe generated JAR is executable from a JVM, you don't even need to have Groovy installed for that.\n\n### Generate an appimage\nYou'll need to a have JDK 14+ installed. This tool will try to find one\nautomatically but if it doesn't succeed, you can still provide the path of your jpackage binary with the `-j` argument\n\n### Generate a native-image (native binary executable)\nYou'll need to have graalvm + native-image installed.\n\nNote that there are a some restrictions for you script to work in binary executable. For example, you can't\nuse Groovy dynamic feature, as the compilation needs to be static. Also, you shouldn't do much Java reflection.\n\nIf the app doesn't find `native-image`, you can provide the path of it with the `-n` argument.\n\n### @Grab dependencies\n\nIf your script contains `@Grab` annotations, it will not include them when compiling the script. The grabbed\ndependencies will be fetched and included in the jar instead, so that your script runs faster at runtime.\n\nNote that the grab annotation needs to be like in the below example\n```groovy\n@Grab('org.springframework:spring-orm:3.2.5.RELEASE')\n```\n\nnot the one with `group=..., module=..., version=...`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftambapps%2Fgroovy-script-compiler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftambapps%2Fgroovy-script-compiler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftambapps%2Fgroovy-script-compiler/lists"}