Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure IntelliJ/gradle to use dagger 2.0

I have a gradle project and I want to use dagger 2.0 in it. I don't know how to configure IntelliJ and gradle to generate files and let IntelliJ find them?

My build.gradle file looks like:

apply plugin: 'java' apply plugin: 'idea'  version = '1.0'  repositories {     mavenCentral()     maven {         url "https://oss.sonatype.org/content/repositories/snapshots"     } }  dependencies {     compile 'org.slf4j:slf4j-api:1.7.12'     compile 'org.slf4j:slf4j-simple:1.7.12'     compile 'commons-configuration:commons-configuration:1.10'     compile 'commons-collections:commons-collections:3.2.1'     compile 'com.google.dagger:dagger:2.0'     compile 'com.google.dagger:dagger-compiler:2.0:jar-with-dependencies'     compile 'com.pi4j:pi4j-distribution:1.1-SNAPSHOT' } 

In the build directory of my application the file DaggerXmlConfigurationComponent exists, which is a component Dagger creates. But I can't use it in IntelliJ because it can't find the class.

This is not an Android application but an application for the Raspberry Pi.

like image 483
Martijn de Munnik Avatar asked Apr 10 '15 13:04

Martijn de Munnik


People also ask

How do I enable Gradle in IntelliJ?

The Gradle tool window is enabled automatically when you create or open your Gradle project. Click Gradle on the right sidebar to open the tool window. The tool window displays the Gradle linked projects, their tasks, dependencies, and all changes made to the underlying build. gradle file.


1 Answers

You'll have to manually enable annotation processing for IntelliJ: in Settings… → Build, Execution, Deployment → Compiler → Annotation Processors, check Enable annotation processing and Obtain processors from project classpath.

like image 172
robert_difalco Avatar answered Sep 23 '22 13:09

robert_difalco