Closed Chris2011 closed 6 years ago
The problem is that NB cannot load your project at all. Given the error message, I would expect that you need to set some variables in your global gradle.properties but you should ask someone who knows the build on how to setup the project.
Ok, yeah someone said that to me too, with the gradle.properties. Maybe there needs a better explanation for those, who is working for the first time. Sure I had to read stuff before, but I was wondering, I cloned the repo and it works but not as expected plus the message. Will try to fix the global variables. Thx.
Sadly, the plugin can't really distinguish what the problem is when the build file fails to get evaluated. It would be nice if there was a standard way for the build to communicate to the IDE that "Show this message to the user" but currently there is nothing like that.
The problem you encountered is the reason I would advise everyone to never fail during script evaluation time but only when executing a task (that way, people can start working on the project easily).
The thing, with the gradle.properties is one problem, correct, the other thin is that I expect, to see the right folder structure as in a java project. Why is there the gradle.properties file needed? Because there is a src/main and src/test folder so I expect to see the same structure under the project view, by default, as I've seen it in your plugin page.
The gradle.properties is not needed by the plugin. It is needed by the build script of your project. The problem is that from the plugin point's of view, the whole build script is broken (i.e., Gradle just reports an exception and nothing else about the structure). If I was Gradle inc., I would advise officially that you shouldn't write a build script which needs some setup otherwise blows up. Though it is not the end of the world, it is discouraging (as it gives an immediate negative feedback). Some luck in your circumstance is that, even though the build blows up, NB will at least let you do some common things from the IDE like creating the global gradle.properties (by right clicking the on the Gradle home node, I probably should have also said this earlies).
Yes, I did this, but in my point of view, why is the project structure broken, even when the build script or build pipeline is broken? That doesn't make sense. This will not happen to a Java or maven project afaik. If the ant script or pom.xml or whatever is broken, it will let you knows it, while build time and not while open it and to see a broken project structure. Of course, I had to fix this, because I had to add a gradle.properties file with my credentials to our company repo.
After I added this file and added my credentials, I see the correct project structure, but again, this doesn't make sense. I didn't know this, because this is not my all day work and I didn't think, that adding the global gradle.properties file, will fix the project view. Why and where should I knew this?.
Maybe this will give you a better a understanding. This is what happens:
You are wrong with the Maven comparison, if you create a syntax error in the POM (say add \<X> somewhere), then you will experience something similar with a Maven project. That is, the build script throwing an exception is the equivalent of an unparseable pom.xml in the Gradle world.
As for how could you have known this: The one who wrote the build script of the project you were trying to open should have told you, as this is not something Gradle (or the plugin) requires. That is why I would recommend people to never throw an exception in the build script during evaluation time (otherwise people like you gets fooled).
I opened a project, which has some gradle stuff inside. It was not created by me, it was created by a collague and I think with IntelliJ. After cloning, NetBeans can figure out, that I can open the project and it opens. I see the project with the gradle icon. The problem is, when I open the folder/package structure, there is no sources inside as you can see in my screenshot:
But when you open files, it is already there:
I got an warning/error/exception on the project:
So the Project was not opened properly. The other problem is, when I wanted to change the sources folder to get a better structure, I can't. There is no option for doing this. So I never see this project structure: http://plugins.netbeans.org/data/images/1346532324_gradle_screenshot.png
Cheers
Chris