Config Maven for using Dagger2

There are situation that you need to use Dagger2 in a javaSE/javaEE projects. Despite the fact that Dagger2 is a dependency injection built specifically (well….apparently)  for android.

For running Dagger2 in a Maven based project you need to have following lines in your pom.xml

<dependencies>
    <dependency>
        <groupId>com.google.dagger</groupId>
        <artifactId>dagger</artifactId>
        <version>2.9</version>
    </dependency>
    <dependency>
        <groupId>com.google.dagger</groupId>
        <artifactId>dagger-compiler</artifactId>
        <version>2.9</version>
        <optional>true</optional>
    </dependency>
</dependencies>

and also for the build section of pom.xml

<build>
    <plugins>
        <plugin>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.0</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
            <dependencies>
                <dependency>
                    <groupId>com.google.dagger</groupId>
                    <artifactId>dagger-compiler</artifactId>
                    <version>2.9</version>
                    <optional>true</optional>
                </dependency>
            </dependencies>
        </plugin>
    </plugins>
</build>

thats it and you are ready to use Dagger2 in a maven based project.