cvmocanu
08/06/2018, 4:35 PM<plugin>
<artifactId>kotlin-maven-plugin</artifactId>
<groupId>org.jetbrains.kotlin</groupId>
<executions>
<execution>
<id>kapt</id>
<phase>compile</phase>
<goals>
<goal>kapt</goal>
</goals>
<configuration>
<sourceDirs>
<sourceDir>src/main/kotlin</sourceDir>
<sourceDir>src/main/java</sourceDir>
</sourceDirs>
<annotationProcessorPaths>
<!-- Specify your annotation processors here. -->
<annotationProcessorPath>
<groupId>com.google.dagger</groupId>
<artifactId>dagger-compiler</artifactId>
<version>2.16</version>
</annotationProcessorPath>
</annotationProcessorPaths>
</configuration>
</execution>
</executions>
</plugin>
This works from maven, but IntelliJ is completely clueless. By this, I mean that no additional files are generated in my target directory when I press Ctrl+F9 (or choose to rebuild the module). There is only a "classes" directory there.
(3) as a quick test I also tried a small gradle project. The only way I could get it to work was to delegate compile to gradle (Settings > Build, Execution, Deployment > Build Tools > Gradle > Runner -> enable: "Delegate build/run actions to gradle")
But this means it's gradle that compiles & runs kapt, not IntelliJ.
So now I'm out of ideas.
Is there a way to make IntelliJ automatically run kapt as part of building (Ctrl+F9)?
Or is basically dagger 2 useless on a maven + Kotlin project? If I have to do "mvn clean package" every time I change a class, that makes dagger 2 useless for me (and for anyone that cares about development productivity).
Also, if you use gradle + dagger 2 + kotlin and you delegate build/run actions to gradle, doesn't this make the whole compilation unbearably slow? Especially given the fact that apparently kapt cannot run in gradle incremental mode (https://youtrack.jetbrains.com/issue/KT-11978).carwashi
08/06/2018, 10:46 PMPlease note that kapt is still not supported for IntelliJ IDEA's own build system. Launch the build from the "Maven Projects" toolbar whenever you want to re-run the annotation processing.
cvmocanu
08/07/2018, 9:01 AM