lukaville / toothpick

A scope tree based Dependency Injection (DI) library for Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Toothpick (a.k.a T.P. like a teepee)






Visit TP wiki !

What is Toothpick ?

Toothpick is a scope tree based Dependency Injection (DI) library for Java.

It is a full-featured, runtime based, but reflection free, implementation of JSR 330.

What does Toothpick offer ?

//a typical Toothpick scope tree during the execution of an Android app.

       @ApplicationSingleton 
         /              |    \  
        /               |     \
       /                |      \
   @PresenterSingleton  |   Service 2
         /              | 
        /            Service 1  
       /            
Activity 1
    /   \
   /   Fragment 2
  /
Fragment 1

Toothpick is :

Hey, Android Devs, you can use TP to create MVP apps so easily !

Examples

Currently Toothpick has 2 sets of examples :

Setup

The latest version of TP is provided by a badge at the top of this page.

For Android :

#android setup using gradle 3.3.0
buildscript {
  repositories {
    google()
    jcenter()
  }
  dependencies {
    classpath 'com.android.tools.build:gradle:3.3.0'
  }
}

...

dependencies {
  implementation 'com.github.stephanenicolas.toothpick:toothpick-runtime:2.x'
  // and for android -> implementation 'com.github.stephanenicolas.toothpick:smoothie-androidx:2.x'
  annotationProcessor 'com.github.stephanenicolas.toothpick:toothpick-compiler:2.x'

  //highly recommended
  testImplementation 'com.github.stephanenicolas.toothpick:toothpick-testing-junit5:2.x'
  testImplementation 'mockito or easymock'
}

For java:

<!--java setup with maven -->
  <dependencies>
    <dependency>
      <groupId>com.github.stephanenicolas.toothpick</groupId>
      <artifactId>toothpick-compiler</artifactId>
      <version>2.x</version>
      <scope>compile</scope>
    </dependency>
    <dependency>
      <groupId>com.github.stephanenicolas.toothpick</groupId>
      <artifactId>toothpick-runtime</artifactId>
      <version>2.x</version>
      <scope>compile</scope>
    </dependency>
    
    <!-- highly recommended-->
    <dependency> 
      <groupId>com.github.stephanenicolas.toothpick</groupId>
      <artifactId>toothpick-testing</artifactId>
      <version>2.x</version>
      <scope>test</scope>
    </dependency>
    <dependency>
    <easymock or mockito>
    </dependency>
  </dependencies>

Support

TP is actively maintained and we provide support to questions via the Toothpick-di tag on Stack Over Flow.

Ask questions on Stack Over Flow while keeping the GitHub issue board for real issues. Thx in advance !

Talks & Articles

Wanna know more ?

Visit Toothpick's wiki !

Alternative Dependency Injection (DI) engines for Android

Libs using TP

  • Okuki is a simple, hierarchical navigation bus and back stack for Android, with optional Rx bindings, and Toothpick DI integration.
  • KotlinWeather is a simple example of using ToothPick with Kotlin and gradle integration using kapt.

Credits

Most of the effort on version 2 has been actively supported by Groupon. Thanks for this awesome OSS commitment !

About

A scope tree based Dependency Injection (DI) library for Java

License:Apache License 2.0


Languages

Language:Java 99.8%Language:Shell 0.2%