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

Gradle Project not detected in Netbeans 8.2 #306

Closed ms270169 closed 7 years ago

ms270169 commented 7 years ago

I am using NetBeans IDE 8.2 (Build 201609300101) (full version) on Linux , and Gradle Plugin Version 1.3.9.2 from (Plugin Portal) is activated.

I can create a Gradle project but it does not open in Netbeans. If I try to open it manually, I only can browse inside the project directory. So it seems that Netbeans does not detect this project as a Gradle project.

Looking to the project directory from terminal shows, that the build.gradle file is there, and the project can be build by executing gradle build.

I check also the Options setting for Miscellanouse/Gradle/Installation. I try different settings for Gradle Installation Directory (also download Gradle 2-13 manually), but nothing helps.

Any ideas how to solve the problem?

kelemen commented 7 years ago

What kind of Gradle project and how do you create it? Anyway, can you try if any of the following helps:

ms270169 commented 7 years ago

I create a Project using the Netbeans assistent. File->New Project , Catagory->Gradle, Project->Single Gradle Project, selecting project name and location, Main Class main.Main, Button Finish. Nothing happened. If I look on project location there was a valid gradle Java project created. I can call gradle build from shell ... everything works.

But Netbeans is not able to open this project location as project. It seems, that it does not detect this directory as a project. I also try to create a gradle wrapper inside the project. But it does not help. I have never worked with gradle project up to now, so I have no experience about the normal behavior. I would expect that Netbeans detect such a Java Project like a normal Java Project without gradle (purely based on ant).

Any ideas how to debug whats going wrong?

kelemen commented 7 years ago

NB only checks the presence of the build.gradle file, so it should not be a problem. If NB does not even detect the directory, then try restarting NB. If restarting NB helps, then I have guess what could have went wrong and will try to fix it. If it does not, then I'm not sure, I will probably need more info (logs, the exact project).

ms270169 commented 7 years ago

I try out some additional fact. On my machine Netbeans is installed under /usr/share/netbeans-8.2 with read access for normal user and read/write only for root.

If I start Netbeans as root, Java with Gradle Project can be created, it is opened and it works. If Netbeans is started as normal user, you have the effect described above. There is no gradle project opened.

Gradle project is created (show attached projectAsUser.tar.gz) but there is no .nb-gradle inside. It cannot be opened as project, neither as user nor as root. Also a complete project (created as root and including .nb-gradle) cannot be opened at user.

issue-306.zip

kelemen commented 7 years ago

For the NB install dir, you don't need write right (I personally, don't have one for the user starting NB).

Given your comments above, I suspect that you don't have access to the directory (or something within it). Though, I admit it is strange. However, if you are switching between root and normal user, there is one thing to be aware of: You will start the Gradle daemon with one user and the daemon might create files which the other user won't be able to open. I don't know (because I have never tried) what complications it might cause.

To figure out what is the problem, you might try the following:

  1. Kill all the Gradle daemons (they are simple java processes).
  2. Create a new project into a new directory to which you know have all the rights and see if it still does not work.
ms270169 commented 7 years ago

@kelemen, thank you for your support. Following your recommendations I have checked all rights. In the recent try outs, I have created the gradle/Java project in /tmp (only to test if it works). That causes the problems. If I create the project in ~/NetBeansProjects (or some other directory, except /tmp) it works.

I do not understand the cause. /tmp has root:root as owner/group and the rights are drwxrwxrwt. It makes no difference when I set the rights to drwxrwxrwx or the ownership to me.

kelemen commented 7 years ago

Oh, I forgot about it. You cannot open a project in the temporary directory (because NB sometimes places build.gradle files there and it could fool the plugin). It is in the readme, but I admit that I should clean it up, given all the obsolete issues there.

ms270169 commented 7 years ago

Suggests for further improvements: 1) Maybe you can prevent creating a project in /tmp 2) I miss a Properties -> Categories -> Sources to get the project base directory (like in standard ant project or maven project). At the moment I use the properties of project files to get this info.

kelemen commented 7 years ago
  1. Yes, that is something what should be done. Though, I won't have time this week and even if I did, I wish to complete some other improvements in the plugin. If you want to, you can try adding the check to NewProjectUtils
  2. An information dialog with all kinds of information (copy-pastable) would be nice but it is not top priority for me. If you feel strongly about it, I would gladly merge your improvements.
ms270169 commented 7 years ago

@kelemen, 1) can be solved very fast in my POV. See https://github.com/kelemen/netbeans-gradle-project/compare/master...ms270169:fix%23306.

I am sorry that I am not able to test it, but Clean&Build of the projects fork does not create any nbm module. Building in generally works (with warnings), although Netbeans source assistant shows a lot of errors and warnings.

kelemen commented 7 years ago

Thanks, but can you refactor it so that NbGradleProjectFactory and this code uses the same logic?

Anyway, the build task depends on the nbm task, so if build does not fail it must (barring a bug I have never seen) create an NBM file in netbeans-gradle-plugin/build/nbm. However, if you just want to try the plugin without too much effort, check the Development wiki page.