Dagger compiler in Gradle for non-Android project?

295 views
Skip to first unread message

Pablo

unread,
Nov 13, 2015, 9:07:40 PM11/13/15
to Dagger Discuss
Hi friends,

This may seem pretty pedestrian, but I'm not having much success Googling it: how do I declare `dagger-compiler` in my Gradle dependencies so it will operate on the compiler and generate the correct files at compile time?

This

```
compile 'com.google.dagger:dagger:2.0.2'
compile 'com.google.dagger:dagger-compiler:2.0.2'
```

fails because the compiler isn't included early enough in the process to generate the Dagger* component class, and most Googling is focused on Android, where it appears to use a plugin called `apt.` Mine is a vanilla Java project.

I'll keep digging, but this may be something that someone knows quickly/easily. Thanks! :D

-Pablo

John Zeringue

unread,
Dec 31, 2015, 2:44:48 AM12/31/15
to Dagger Discuss
I would recommend

plugins {
    id
'net.ltgt.apt' version '0.5'
}

dependencies {
    apt
'com.google.dagger:dagger-compiler:2.0.2'
    compile 'com.google.dagger:dagger:2.0.2'
}
Reply all
Reply to author
Forward
0 new messages