{"id":16167724,"url":"https://github.com/jlleitschuh/kotlin-guiced","last_synced_at":"2025-07-07T00:36:34.973Z","repository":{"id":144936331,"uuid":"93102479","full_name":"JLLeitschuh/kotlin-guiced","owner":"JLLeitschuh","description":"Convenience Kotlin API over the Google Guice DI Library","archived":false,"fork":false,"pushed_at":"2019-01-03T18:36:28.000Z","size":234,"stargazers_count":18,"open_issues_count":1,"forks_count":6,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-17T00:41:29.278Z","etag":null,"topics":["dependency-injection","google","google-guice","guice","java","jvm","kotlin"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","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/JLLeitschuh.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}},"created_at":"2017-06-01T21:50:10.000Z","updated_at":"2024-10-01T22:14:44.000Z","dependencies_parsed_at":"2024-01-21T11:50:08.574Z","dependency_job_id":"f28c5195-3374-4687-b75f-c74683edbc2d","html_url":"https://github.com/JLLeitschuh/kotlin-guiced","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JLLeitschuh%2Fkotlin-guiced","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JLLeitschuh%2Fkotlin-guiced/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JLLeitschuh%2Fkotlin-guiced/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JLLeitschuh%2Fkotlin-guiced/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JLLeitschuh","download_url":"https://codeload.github.com/JLLeitschuh/kotlin-guiced/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244325201,"owners_count":20435060,"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":["dependency-injection","google","google-guice","guice","java","jvm","kotlin"],"created_at":"2024-10-10T03:09:13.431Z","updated_at":"2025-03-18T23:30:54.614Z","avatar_url":"https://github.com/JLLeitschuh.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kotlin Guiced\n\n[![Build Status](https://travis-ci.org/JLLeitschuh/kotlin-guiced.svg?branch=master)](https://travis-ci.org/JLLeitschuh/kotlin-guiced)\n[ ![Download](https://api.bintray.com/packages/jlleitschuh/maven-artifacts/kotlin-guiced/images/download.svg) ](https://bintray.com/jlleitschuh/maven-artifacts/kotlin-guiced/_latestVersion)\n\nA Kotlin API wrapper over the [Google Guice](https://github.com/google/guice) Dependency Injection library.\n\nThis library aims to encourage the use of Guice with Kotlin by simplifying the Guice API so it is more\nfluent in the Kotlin programming language.\n\n## NOTE:\nProject is in very early stage of development. I plan to add helper functions as needed in a parallel cooperate internal\nproject and this project it may not comprehensively cover all of the methods out of the box.\n\n## Examples:\n\n### TypeLiteral\nBecause of java type erasure, Guice uses some strange java syntax to preserve type at runtime.\nMany of these problems have been solved by Kotlin using inline functions with `reified` types.\n\nIn java you can declare a type literal with:\n```java\nfinal TypeLiteral\u003cMap\u003cInteger, String\u003e\u003e someLiteral = new TypeLiteral\u003cMap\u003cInteger, String\u003e\u003e() {}\n```\nIn Kotlin this syntax becomes even more verbose requiring more characters to write. \n```kotlin\nval someLiteral = object : TypeLiteral\u003cMap\u003cInteger, String\u003e\u003e() {}\n```\nThis library provides helpers like the one below that is much cleaner to read.\n```kotlin\nval someLiteral = typeLiteral\u003cMap\u003cInt, String\u003e\u003e()\n```\n\n### Guice Modules\n\nCreating a module in Java requires quite a bit of extra boilerplate.\n```java\npublic class MyModule extends AbstractModule {\n    @Override\n    void configure() {\n        bind(SomeService.class).to(SomeServiceImpl.class);\n    }\n}\n\nclass Main {\n    public static void main(String... args) {\n        final Injector injector = Guice.createInjector(new MyModule());\n    }\n}\n```\nThis is the equivalent in Kotlin:\n```kotlin\nfun main(vararg args: String) {\n    val myModule = module {\n        bind(SomeService::class).to(SomeServiceImpl::class)\n        // Or, even simpler with reified generics\n        bind\u003cSomeService\u003e().to\u003cSomeServiceImpl\u003e()\n    }\n    val injector = Guice.createInjector(myModule)\n}\n```\n\nThe library also defines a simple way of declaring private modules:\n```kotlin\nfun main(vararg args: String) {\n    val privateModule = privateModule {\n        bind\u003cSomeService\u003e().to\u003cSomeServiceImpl\u003e()\n        expose\u003cSomeService\u003e()\n    }\n    val injector = Guice.createInjector(privateModule)\n}\n```\n\n\n## Project Structure\nThe intention is to structure this project such that Guice Core and each of it's respective extensions will\nbe in their own projects. The reasoning being that a library consumer can choose to depend upon only the Guice \nextensions they need an not get a transitive dependency on a Guice extention they don't need.\n\n\n## Developers\n\n### Requirements\nRequires JDK 8 installed (Kotlin Compiler compiles to JDK 6 bytecode but requires JDK 8 to run).\n\n### Building\n\nThis project uses Gradle to build/test/deploy code.\nRun `./gradlew tasks` to se the various tasks this project supports.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlleitschuh%2Fkotlin-guiced","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjlleitschuh%2Fkotlin-guiced","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjlleitschuh%2Fkotlin-guiced/lists"}