How to use Dagger in non-Android Gradle Java application?
dagger, dependency-injection, gradle, java
Solution
It should work fine with both defined as `compile`. The error indicates other problem with your code.
If you still want to use provided scope please read this: http://www.sinking.in/blog/provided-scope-in-gradle/
Quick example how to use provided:
apply plugin: 'java'
configurations {
provided
}
sourceSets {
main {
compileClasspath += configurations.provided
}
}
dependencies {
provided 'com.google.guava:guava:18.0'
}
Problem
Dagger is advertised as "A fast dependency injector for Android and Java". But I'm not able to make it run without Gradle 'android' plugin. ``` compile 'com.squareup.dagger:dagger:1.2.1' provided 'com.squareup.dagger:dagger-compiler:1.2.1' ``` There is no `provided` in 'java' or 'application' gradle plugin I'm using. It is even mentioned in this bug report. Making it both 'compile' yelds no result. The same `java.lang.IllegalStateException: Module adapter for class ... could not be loaded.` is thrown. How gradle with 'java' and 'application' can be configured to use dagger annotation processor?