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.
172 stars 57 forks source link

Failing to load projects that are missing settings.gradle #351

Closed birgersp closed 6 years ago

birgersp commented 7 years ago

Projects missing a settings.gradle file fail to load without a "Project Problem". Is this file really necessary? I can build gradle projects from the command line just fine without this file. The file doesn't actually need anything in it, it just needs to be present for the project to load with the "problem"...

I suggest that projects should be loaded without warning/error even if the settings.gradle file is missing.

kelemen commented 7 years ago

They should load, unless another settings.gradle is mistakenly believed to be its settings.gradle. What does it mean that "without a Project Problem"? Can you describe exactly what happens?

Anyway, altough settings.gradle is not necessary, I would recommend it anyway because it explicitly defines the root directory and prevents Gradle from searching the parent directories for one.

JustGregory-zz commented 6 years ago

@birgersp I think that in this case, adding a blank settings.gradle file would do the trick. You are right in that it probably doesn't need the file in most cases, ... but it's such a minor issue that's easily solvable, so why even hesitate to add it?

Edit: what it is commonly used for is to set the root project's name and to declare subprojects, like so:

rootProject.name='Some Root Project More Beautiful And Lengthy Name'
include ':core', 'core-audio', 'core-image', ':core-input'

Note that in my usage, I prefer manually adding the named subprojects instead of the "default" iterator that is attached. The first line is or should be self-evident; it's useful for providing a more user-friendly meta-project name; I name the parent folder in camelcase style, and provide here a more casual or apropos name.

Edit 2: It is probably a little more necessary for the root project in a parent/child project structure; as subprojects are not likely to need settings.gradle files unless they are themselves parent projects. Best bet is to consult Gradle's docs in the matter.

kelemen commented 6 years ago

@JustGregory You must never add a settings.gradle to child projects (only the root) because then they become a separate build and its behaviour will depend on from where the you call that project. Since, you do not explicitly load projects in NB (opening it is mostly a display thing), you can also expect strange behaviour in NB if you have multiple settings.gradle in the (supposedly) same build.

JustGregory-zz commented 6 years ago

Ah, yes, I stand corrected. Now that I think about it, I should have rethought the second edit comment from my response before posting -- oh well, I live and I learn. Sorry for my mistype....

kelemen commented 6 years ago

No problem, I guess it happens to the most of us :)

birgersp commented 6 years ago

I've been trying to reproduce the error, but I can't. I was certain that opening a gradle project with the plugin without a settings.gradle would produce an error, but it seems I was wrong. Not sure what initially happened. Sorry.

Thanks for a great plugin!