Code Monkey home page Code Monkey logo

kotlin-compiler-dagger-plugin's Introduction

What is this?

An experiment on the idea of Google's Dagger using different means of code generation: Kotlin compiler.

For now I continue working on implementing richer feature-set. Most of the code is generated in frontend using KotlinPoet. IDE support works out of the box (at least for JB products) thanks to gradle integration. As a side effect of this project, I am exploring how DI can be done better using Kotlin (in compile time safe way).

If you, for any reason, want to look through this:

  • The plugin files are in: buildSrc/compiler-plugin/kotlin-plugin (this is what attaches to compiler)
  • The test project files is in src/main/kotlin (this is what gets compiled)

Right now I have implemented the concept of:

  • exposing dependencies through Component.
  • providing them through Module implemented as object or class instance.
  • providing using @Inject annotated constructor
  • inject dependencies into @Inject annotated fields
  • inject dependencies into @Inject annotated functions (one param only)
  • local scoping inside component using @Scope annotations
  • provide external dependencies using @Factory
  • Support of @BindsInstance for components
  • Support for @Qualifier
  • external dependencies through @Builder
  • Default builder
  • Type mapping using @Binds
  • Lazy and Provider support

TODO (in any order):

  • Default module instantiation when class has an empty constructor
  • Reusable support
  • IntoSet / IntoMap
  • Subcomponents
  • Proper scope support
  • ... the rest

To launch test file

Use ./gradlew run. It will build and install plugin to maven local, after it will compile the test project using freshly built plugin and run it. Yay!

Now publishing to gradle plugin portal!

To get the plugin, follow instructions here.

kotlin-compiler-dagger-plugin's People

Contributors

shikasd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kotlin-compiler-dagger-plugin's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.