kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
170 stars 57 forks source link

Dagger 2 + netbeans-gradle: NetBeans complains "cannot find symbol" #353

Closed gtheimer closed 7 years ago

gtheimer commented 7 years ago

I am using NetBeans 8.2, Gradle 4.1, netbeans-gradle 1.4.2, and Dagger 2.

Building a Java program that uses Dagger 2 with Gradle works on the command line. Running the build in NetBeans also produces executuable code, however, the problem is that NB marks symbols defined in the Dagger-generated code with red underlines ("error parsing file"). Apparently, NB does not see the generated Java code. Is there a work-around for this problem?

kelemen commented 7 years ago

Can you link me a sample project with which I can reproduce this issue with?

gtheimer commented 7 years ago

Sample project: https://www.dropbox.com/sh/eijy3x6fk3iz5vm/AAD6937qgXIGEqoxcLaujNzoa?dl=0

kelemen commented 7 years ago

Thanks, I have downloaded and took a look at your project. It seems that the net.ltgt.apt plugin is abusing Gradle. You can work around the issue by adding this:

if (project.hasProperty('evaluatingIDE') && project.property('evaluatingIDE') == 'NetBeans') {
    sourceSets {
        main {
            java {
                srcDir compileJava.generatedSourcesDestinationDir
            }
        }
    }
}
gtheimer commented 7 years ago

This works. Many thanks to Attila.