How do you modify a NetBeans project type after it is created?

advertisements

I created a project from existing sources as a PHP project in an older version of NetBeans.

I now want to change the project type to an HTML5/CSS project in NetBeans 7.4.

Is there any easy way to change the type of an existing project in NetBeans?

I'm trying to avoid creating a new project from existing sources as I have all my server connection variables already configured.


The project data is stored within the main project directory in a subdirectory named nbproject.

The file project.xml contains the main configuration data for the TYPE of the project. The type and data xml namexspace settings determine the basic project type. Here is a PHP version:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
    <type>org.netbeans.modules.php.project</type>
    <configuration>
        <data xmlns="http://www.netbeans.org/ns/php-project/1">
            <name>codex-slp</name>
        </data>
    </configuration>
</project>

Here is an HTML5 project version:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://www.netbeans.org/ns/project/1">
    <type>org.netbeans.modules.web.clientproject</type>
    <configuration>
        <data xmlns="http://www.netbeans.org/ns/clientside-project/1">
            <name>csa</name>
        </data>
    </configuration>
</project>

Note the line is different. The HTML 5 project uses the namespace org.netbeans.modules.web.clientproject. The PHP version is at org.netbeans.modules.php.project.

Also of note is the data xmlns entry with HTML5 pointing to the clientside-project directory while PHP points to the php-project directory.

How to change the project? Not easily. Your best bet:

  • Close out the NetBeans IDE.
  • Go to the project directory.
  • Remove (or rename) the nbproject subdirectory.
  • Open NetBeans.
  • Create a new HTML5 project from existing sources.

That will switch the project type from PHP to HTML5 and give you the corresponding dialogue boxes.

The reason I decided to take this approach is there are a lot of other things that hang off this namespace specification. The project.properties file, for example, has very different entries for a PHP project, thinks like the PHP version, that do not exist for the HTML5 project. The HTML5 project has new properties that are not present in PHP projects.

There is also an entire private subdirectory that has a plethora of options set in the private.properties file that contains things like the source remote connection for a PHP project that does not exist nor seem to even be SUPPORTED for an HTML5 project.

There are far too many disparities between the two project types to simply hack up the nbproject directory files and hope it works.

IMO your best option is to follow the steps above to recreate the project.

Sadly, it does not appear as though HTML5 project types have matured to the point of the PHP project types with things like supporting remote pull/push of changed files. For this particular project I've reverted back to the PHP project type even though this is not really a PHP project. I heavily rely upon the automatic remote server push via FTP. How did I restore the project? I renamed my nbproject directory to saved_nbproject, so to revert:

  • Close Netbeans.
  • Go to project directory.
  • Rename my saved_nbproject directory back to nbproject.
  • Restart NetBeans.

Maybe changing project types AND HTML5 remote server support will be available in the future. For now, with NetBeans 7.4 it does not appear this transition is readily available.

If anyone else has input or other feedback I'd love to hear it as NetBeans has become my go-to tool for complex code projects.