I want use Dagger2 and MVP in a project Gradle but without Android, in native Java. But i can't build my project, the class DaggerAppComponent is never generated. This class is automatically generated by Dagger lib in compile time.
build.gradle :
plugins {
id "net.ltgt.apt" version "0.11"
}
apply plugin: 'java'
apply plugin: 'idea'
sourceCompatibility = 1.8
repositories {
mavenCentral()
}
compileJava {
options.annotationProcessorPath = configurations.apt
}
configurations {
apt
}
dependencies {
testCompile group: 'junit', name: 'junit', version: '4.12'
compile "com.google.dagger:dagger:2.11"
apt "com.google.dagger:dagger-compiler:2.11"
apt "com.google.dagger:dagger-producers:2.11"
compileOnly "com.google.auto.factory:auto-factory:1.0-beta3"
apt "com.google.auto.factory:auto-factory:1.0-beta3"
compileOnly "org.immutables:value:2.2.10:annotations"
apt "org.immutables:value:2.2.10"
provided 'javax.annotation:jsr250-api:1.0'
compile 'org.glassfish:javax.annotation:10.0-b28'
}
Main.java
public class Main {
private static AppComponent appComponent;
public static void main(String[] args) {
/**
* Launch the application.
*/
EventQueue.invokeLater(new Runnable() {
public void run() {
appComponent = initDagger();
try {
MainViewImpl mainView = new MainViewImpl();
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
public AppComponent getAppComponent() {
return appComponent;
}
public static AppComponent initDagger() {
return DaggerAppComponent.builder().appModule(new AppModule())
.build();
}
}
When i build my project i have this error :
Error:(38, 16) java: cannot find symbol
symbol: variable DaggerAppComponent
location: class main.Main
The class DaggerAppComponent is never build. Do you have an idea ?