Closed alamakih closed 6 years ago
NetBeans can't handle changing the project type on the fly. The only safe way is to close NetBeans, then change the project type (i.e., move from Maven to Gradle), then restart NB.
@kelemen I'm not trying to change project type. It has been gradle project from the start and works as such from the command line.
I assume restaring NB didn't help. Can you paste the whole stack trace of the exception?
@kelemen Yeah restarting NB hasn't helped. This is maybe unrelated weirdness, but I noticed that right-clicking project's top folder in Files view gives "Close 2 Projects" as the only option.
java.lang.IllegalArgumentException: Already a org.netbeans.gradle.project.NbGradleProject in /home/username/projects/projectname2@89d2f673:581ef911
at org.netbeans.spi.project.support.ant.ProjectGenerator$1.run(ProjectGenerator.java:145)
at org.netbeans.spi.project.support.ant.ProjectGenerator$1.run(ProjectGenerator.java:123)
at org.netbeans.modules.openide.util.DefaultMutexImplementation.writeAccess(DefaultMutexImplementation.java:250)
at org.openide.util.Mutex.writeAccess(Mutex.java:299)
at org.netbeans.spi.project.support.ant.ProjectGenerator.createProject0(ProjectGenerator.java:123)
at org.netbeans.spi.project.support.ant.ProjectGenerator.createProject(ProjectGenerator.java:104)
at org.netbeans.modules.web.clientproject.ant.AntServices.createProject(AntServices.java:78)
at org.netbeans.modules.web.clientproject.util.ClientSideProjectUtilities.setupProject(ClientSideProjectUtilities.java:155)
at org.netbeans.modules.web.clientproject.createprojectapi.ClientSideProjectGenerator.createProject(ClientSideProjectGenerator.java:83)
at org.netbeans.modules.web.clientproject.ClientSideProjectConvertor$Factory.call(ClientSideProjectConvertor.java:180)
at org.netbeans.modules.web.clientproject.ClientSideProjectConvertor$Factory.call(ClientSideProjectConvertor.java:143)
at org.netbeans.spi.project.ui.ProjectConvertor$Result.createProject(ProjectConvertor.java:141)
Caused: java.io.IOException
at org.netbeans.spi.project.ui.ProjectConvertor$Result.createProject(ProjectConvertor.java:146)
at org.netbeans.modules.project.ui.convertor.ProjectConvertorFactory$ConvertorProject$1.run(ProjectConvertorFactory.java:266)
at org.netbeans.modules.project.ui.convertor.ProjectConvertorFactory$ConvertorProject$1.run(ProjectConvertorFactory.java:260)
at org.netbeans.modules.openide.util.DefaultMutexImplementation.writeAccess(DefaultMutexImplementation.java:250)
at org.openide.util.Mutex.writeAccess(Mutex.java:299)
at org.netbeans.modules.project.ui.convertor.ProjectConvertorFactory$ConvertorProject.createProject(ProjectConvertorFactory.java:260)
at org.netbeans.modules.project.ui.convertor.ProjectConvertorFactory$ConvertorProject.access$700(ProjectConvertorFactory.java:171)
[catch] at org.netbeans.modules.project.ui.convertor.ProjectConvertorFactory$ConvertorProject$OpenHook.projectOpened(ProjectConvertorFactory.java:306)
at org.netbeans.spi.project.ui.ProjectOpenedHook$1.projectOpened(ProjectOpenedHook.java:85)
at org.netbeans.modules.project.ui.OpenProjectList.notifyOpened(OpenProjectList.java:1298)
at org.netbeans.modules.project.ui.OpenProjectList.access$1600(OpenProjectList.java:137)
at org.netbeans.modules.project.ui.OpenProjectList$LoadOpenProjects.loadOnBackground(OpenProjectList.java:516)
at org.netbeans.modules.project.ui.OpenProjectList$LoadOpenProjects.run(OpenProjectList.java:394)
at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:1443)
at org.netbeans.modules.openide.util.GlobalLookup.execute(GlobalLookup.java:68)
at org.openide.util.lookup.Lookups.executeWith(Lookups.java:303)
at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:2058)
I think there is a file in your project directory causing some part of NB to think that this is an Ant project. I will have a better look at why NB would believe that tonight.
This seems to be a problem in NB itself (or rather the web.clientproject subproject) not this plugin. This is what happens:
ClientSideProjectConvertor
sees a bower.json or package.json in the directoryClientSideProjectConvertor
NB will try to create a project in the directory.My recommendation for a fix would to have ClientSideProjectConvertor
check if a project is already there or better: whoever tries to create a project based on the request should not do so, if a project is already there.
You should report this issue here: https://issues.apache.org/jira/projects/NETBEANS
@kelemen Although this issue is 1 year old, I'm having the same issue (I have a package.json
in the project root repository, I don't know if this is the cause).
Whenever I open Netbeans, the project is not recognized as a gradle project, so I have to close the project and open again (it works, but I need to do this whenever I open the IDE).
I don't understand about ClientSideProjectConvertor
, is this some netbeans specific stuff?
For most project types there is an option to create from existing sources (so as to define the project type upon its creation, to avoid conflicts with other project types that could possibly be applied to the project). There will be one for creating a Gradle Project from Existing Sources in the near future?
I don't think I can do anything about this (someone could correct me if there is something to help this). It seems to me that this ClientSideProjectConvertor wants to convert the project to a JS project because of the presence of bower.json or package.json. Maybe ClientSideProjectConvertor
could be adjusted not to convert a project if it is already owned.
@kelemen I ended up disabling the HTML5 Kit plugin, that gives support to create javascript projects.
This way, Netbeans doesn't try to verify if the project is a javascript project, so even if it has a package.json
file won't be a problem.
I don't use Netbeans for javascript projects, so this solution worked fine for me.
Netbeans fails to open a project as a gradle project and give this exception.
Environment:
On a hunch, I renamed settings.gradle and got the project recognized as a gradle project for a little while.