netbeans-gradle-project icon indicating copy to clipboard operation
netbeans-gradle-project copied to clipboard

Netbeans view of griffon gradle projects is confusing at best.

Open Richard-Cranium opened this issue 8 years ago • 13 comments

See https://github.com/griffon/griffon/issues/152

Richard-Cranium avatar Apr 13 '16 04:04 Richard-Cranium

Can you link a project with which I can reproduce your issue?

I have tried opening griffon/samples/sample-javafx-java and it seems fine to me. Anyway, I don't think that NB should not display source directories just because compilation was disabled at the time the project was evaluated. If Griffon wants a project not to have Groovy sources for a particular source set, it should just remove the groovy source directories instead of simply disabling (though it can also disable the compilation, it doesn't matter much) compileGroovy. To remove the source directories it could add:

sourceSets {
    main {
        groovy.srcDirs = []
    }
}

The only time - I believe - NB will display the same source roots twice if you include the source roots in multiple source sets. However, if the project is not using a particular source root, it should just not add it (or remove it).

kelemen avatar Apr 13 '16 08:04 kelemen

Here you go: https://github.com/Richard-Cranium/sample

Config.java shows up in both "Source Packages [Groovy] in [conf]" as well as "Source Packages [Java] in [conf]" for one example. The model, view, and controller classes show up in both. I don't doubt that any services would also show up in both.

The test packages are the only ones that appear to do the right thing.

Richard-Cranium avatar Apr 14 '16 01:04 Richard-Cranium

I have checked the sample project and the directories are listed twice because they are added to multiple source groups. In my opinion Griffon is at fault for adding the same directories to all source groups. See the Griffon plugin's code. For what purpose does Griffon add the same directories to multiple source groups? Especially since they are in the same source set (which means that they even share the same class path).

kelemen avatar Apr 14 '16 08:04 kelemen

Beats me. I had originally opened the bug over there, but it wasn't especially easy for me to tell how the Netbeans gradle plugin worked so I did not have much of a leg to stand on in order to complain over there.

From aalmiray's comments at the referenced link, I assume that both IntellJ and Eclipse lump all groovy and java sourcesets together when compileGroovy.enabled = false. That seems reasonable at first glance, but I'm not certain that covers all the edge cases.

Richard-Cranium avatar Apr 14 '16 12:04 Richard-Cranium

I don't think Eclipse or Idea cares about compileGroovy.enabled = false (I would be very surprised). My guess is that they don't display those directories twice because they provide the structure of the project in their own format and simply won't display the same directory twice. In NB however, I retain the structure of the Gradle project and don't check if different source groups contain the same directory or not.

Regardless, I think the Griffon plugin has to be fixed. Also, for better IDE integration, it shouldn't add source directories based on their existence because in this case you are forced to create that directory outside of the IDE if you need it.

kelemen avatar Apr 14 '16 12:04 kelemen

I was just playing with the griffon multiproject tutorial calculator (can be downloaded here: https://dl.dropboxusercontent.com/u/7707848/calculator.zip). If you download the project and navigate to client->calculator-client-javafx you will notice how weird the representation of the actual project (folders) is. If you double click to open a file under the java sources, it will open it but expand the groovy node and select the file (but it has .java extension, not .groovy). If compileGroovy.enabled = false is problematic to detect, maybe checking if the directories actually exist (they do not for groovy) before creating the nodes could avoid confusion. Do you think that improvement is possible?

MarceloRuiz avatar Aug 16 '16 04:08 MarceloRuiz

@kelemen Hi Attila, do you think my previous comment would be a possible solution for this issue?

MarceloRuiz avatar Aug 22 '16 20:08 MarceloRuiz

They actually exist for the groovy source set. That is, the same directory is configured for both groovy sources and java sources (it is hard for me to determine which to hide). I consider this as a Griffon bug. You can workaround the issue by manually removing those source directories from under Groovy with something like: sourceSets.main.groovy.srcDirs = []. If you want to be extra safe, you can do this within an if (project.hasProperty('evaluatingIDE') && project.property('evaluatingIDE') == 'NetBeans').

kelemen avatar Aug 22 '16 20:08 kelemen

Thanks for your answer. Any idea why this problem does not show up with the test classes?

MarceloRuiz avatar Aug 23 '16 03:08 MarceloRuiz

Because the griffon plugin only adds such source directories for the main source set and not for test.

kelemen avatar Aug 23 '16 08:08 kelemen

One last question Attila, so I can contact the Griffon developers with all the information. Is the evaluatingIDE property set by the Gradle plugin or is it something the user should add to the properties file? If the Griffon guys rely on compileGroovy.enabled = false would it be fine to add something like the following to their build script? I want to file a bug there and give them the solution if possible so they include it with the next release.

if (!compileGroovy.enabled) {
    sourceSets.main.groovy.srcDirs = []
}

Thanks!

MarceloRuiz avatar Aug 23 '16 12:08 MarceloRuiz

evaluatingIDE is set by this plugin when it is evaluating the scripts for the project model.

I would assume that would be fine but I'm not familiar with Griffon to be sure. What I would report is that it shouldn't add the same source dirs to multiple groups: namely java and groovy.

kelemen avatar Aug 23 '16 13:08 kelemen

Thanks for your answer. I see what I can do...

MarceloRuiz avatar Aug 23 '16 19:08 MarceloRuiz