{"id":20717375,"url":"https://github.com/cjstehno/polyglot","last_synced_at":"2026-05-02T08:31:34.155Z","repository":{"id":138835424,"uuid":"109023418","full_name":"cjstehno/polyglot","owner":"cjstehno","description":"Some Kotlin code that provides DSL-like support for Kotlin, Java and Groovy without loss of functionalilty.","archived":false,"fork":false,"pushed_at":"2017-12-07T14:33:13.000Z","size":62,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-03-11T07:31:48.544Z","etag":null,"topics":["groovy","java","kotlin"],"latest_commit_sha":null,"homepage":null,"language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cjstehno.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"license_header.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":"2017-10-31T16:32:09.000Z","updated_at":"2017-10-31T18:47:06.000Z","dependencies_parsed_at":"2023-03-21T22:03:12.052Z","dependency_job_id":null,"html_url":"https://github.com/cjstehno/polyglot","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cjstehno/polyglot","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjstehno%2Fpolyglot","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjstehno%2Fpolyglot/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjstehno%2Fpolyglot/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjstehno%2Fpolyglot/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cjstehno","download_url":"https://codeload.github.com/cjstehno/polyglot/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cjstehno%2Fpolyglot/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32528146,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-02T01:12:54.858Z","status":"online","status_checked_at":"2026-05-02T02:00:05.923Z","response_time":132,"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":["groovy","java","kotlin"],"created_at":"2024-11-17T03:08:42.511Z","updated_at":"2026-05-02T08:31:34.147Z","avatar_url":"https://github.com/cjstehno.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Polyglot DSL\n\nSimple project to test an idea I had about using Kotlin to develop a DSL which can be made painlessly available to Kotlin, Java and Groovy.\n\n\u003e Note: I am fairly new to Kotlin, so I make no promises that this is actually _good_ Kotlin code, but it _does_ work.\n\nThe goal was to provide a common code-base and configuration objects, but then allow for more customized configuration methods (DSL-style) as available to the languages.\n\n## Kotlin\n\nSince the base code is written in Kotlin, the Kotlin interface is pretty straight-forward and very DSL-like:\n\n```kotlin\nPolyglotConfig.configure {\n    lang = \"Kotlin\"\n    supported(true)\n}\n```\n\nwhich is implemented as: \n\n```kotlin\nfun configure(config: PolyglotConfig.() -\u003e Unit): PolyglotConfig {\n    val cfg = PolyglotConfig()\n    cfg.config()\n    return cfg\n}\n```\n\n## Java \n\nThe Java configuration is provided using a `Consumer\u003cPolyglotConfig\u003e` which can be inlined for a more DSL-like feel.\n\n```java\nPolyglotConfig.configure(config -\u003e {\n    config.lang(\"Java\");\n    config.supported(true);\n})\n```\n\nwhich is implemented as: \n\n```kotlin\n@JvmStatic\nfun configure(consumer: Consumer\u003cPolyglotConfig\u003e): PolyglotConfig {\n    val config = PolyglotConfig()\n    consumer.accept(config)\n    return config\n}\n```\n\n## Groovy\n\nThe Groovy configuration is exposed as a very Groovy DSL.\n\n```groovy\nPolyglotConfig.configure {\n    lang 'Groovy'\n    supported true\n}\n```\n\nwhich is implemented as: \n\n```kotlin\n@JvmStatic\nfun configure(@DelegatesTo(PolyglotConfig::class) closure: Closure\u003cAny\u003e): PolyglotConfig {\n    val config = PolyglotConfig()\n    closure.delegate = config\n    closure.resolveStrategy = Closure.DELEGATE_FIRST\n    closure.call()\n    return config\n}\n```\n\nNote that this is basically the same code that would be called when doing this in Groovy itself.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjstehno%2Fpolyglot","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcjstehno%2Fpolyglot","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcjstehno%2Fpolyglot/lists"}