|
Visit TP wiki ! |
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.
//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 :
- pure java (and Android helped is provided: "Smoothie")
- fast, it doesn't use reflection but annotation processing
- simple, flexible, extensible & powerful, robust & tested
- thread safe
- documented & Open Source
- scope safe : it enforces leak free apps
- test oriented : it makes tests easier
- it works very well with Android or any other context based framework (such as web containers)
Hey, Android Devs, you can use TP to create MVP apps so easily !
Currently Toothpick has 2 sets of examples :
- one in pure Java
- one for Android
For Android :
#android setup using gradle 2.2.3
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
}
...
dependencies {
compile 'com.github.stephanenicolas.toothpick:toothpick-runtime:1.1.3'
// and for android -> compile 'com.github.stephanenicolas.toothpick:smoothie:1.1.3'
annotationProcessor 'com.github.stephanenicolas.toothpick:toothpick-compiler:1.1.3'
//highly recommended
testCompile 'com.github.stephanenicolas.toothpick:toothpick-testing:1.1.3'
testCompile 'mockito or easymock'
}
For java:
<!--java setup with maven -->
<dependencies>
<dependency>
<groupId>com.github.stephanenicolas.toothpick</groupId>
<artifactId>toothpick-compiler</artifactId>
<version>1.1.3</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.github.stephanenicolas.toothpick</groupId>
<artifactId>toothpick-runtime</artifactId>
<version>1.1.3</version>
<scope>compile</scope>
</dependency>
<!-- highly recommended-->
<dependency>
<groupId>com.github.stephanenicolas.toothpick</groupId>
<artifactId>toothpick-testing</artifactId>
<version>1.1.3</version>
<scope>test</scope>
</dependency>
<dependency>
<easymock or mockito>
</dependency>
</dependencies>
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 !
- How I learned to love unit testing with Toothpick - Groupon's medium blog article
- Droidcon, Boston 2017 - Slides & Video
- Migrating off RoboGuice 3 (to Toothpick) - Part 1 & Part 2
- Mobius, Saint Petersburg 2017 - Slides
- Mobius, Saint Petersburg 2017 - DI frameworks & Internals Slides
- Android Makers, Paris 2017 - Slides & Video
- DroidCon, Kaigi 2017 - Slides
- Andevcon, San Francisco 2016 - Slides
- DroidCon, Krakow 2016 - TP Vs Dagger 2 Talk from Danny Preussler slides
- Mobile Era, Oslo 2016 - Slides
- Droidcon, Berlin 2016 - Slides - Sketch notes
- Android Leaks 2016 - podcast in French
- DevFest Belgium 2016 - video in French
Visit Toothpick's wiki !
- 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.