Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you change a NetBeans project type after it has been created?

Tags:

netbeans

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.

like image 206
Lance Cleveland Avatar asked Nov 09 '13 01:11

Lance Cleveland


People also ask

How do I rename a Java project in NetBeans?

Navigate to the Project window, right-click on the project name, RenamingElements, and choose Rename…. Under Project Name enter FileSystem and tick Also Rename Project Folder; after that, click on Rename.

Where is project structure in NetBeans?

The project contains all of your sources and project metadata, such as the project's Ant build script. The project opens in the IDE. You can view its logical structure in the Projects window (Ctrl-1) and its file structure in the Files window (Ctrl-2).

How do I open an existing project in NetBeans?

In NetBeans IDE, choose File > Open Project. In the file chooser, select the project and click Open Project.

How do I change the project directory in NetBeans?

Edit the file C:\Users\\AppData\Roaming\NetBeans\8.2. 0\config\Preferences\org\netbeans\modules\projectui\groups\. properties. Change the path entry to the new location.


2 Answers

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.

like image 119
Lance Cleveland Avatar answered Sep 28 '22 01:09

Lance Cleveland


NOTE: I would strongly suggest to create a new project from existing sources to ensure everything will work as expected. In most cases its faster and less problematic.

(If you persist....)

Following the accepted answer may result in an error. Besides what Charleston Software Associates posted, you may need to copy other variables included in "project.properties" file.

For example, these are for PHP: (adjust properly. I suggest to see some of your other projects to prevent mistakes).

auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_create_2e_tests=false
auxiliary.org-netbeans-modules-php-phpunit.bootstrap_2e_path=
auxiliary.org-netbeans-modules-php-phpunit.configuration_2e_path=
auxiliary.org-netbeans-modules-php-phpunit.customSuite_2e_path=
auxiliary.org-netbeans-modules-php-phpunit.test_2e_run_2e_all=false
ignore.path=
include.path=
php.version=PHP_53
source.encoding=UTF-8
src.dir=/var/www/example
tags.asp=false
tags.short=false
web.root=.

These are for HTML5:

auxiliary.org-netbeans-modules-css-prep.less_2e_compiler_2e_options=
auxiliary.org-netbeans-modules-css-prep.less_2e_enabled=false
auxiliary.org-netbeans-modules-css-prep.less_2e_mappings=/less:/css
auxiliary.org-netbeans-modules-css-prep.sass_2e_compiler_2e_options=--style compressed
auxiliary.org-netbeans-modules-css-prep.sass_2e_configured=true
auxiliary.org-netbeans-modules-css-prep.sass_2e_enabled=true
auxiliary.org-netbeans-modules-css-prep.sass_2e_mappings=/scss:/css
auxiliary.org-netbeans-modules-javascript2-requirejs.enabled=true
auxiliary.org-netbeans-modules-web-clientproject-api.js_2e_libs_2e_folder=js
config.folder=${file.reference.example-config}
file.reference.example-config=config
file.reference.example-test=test
file.reference.www-example=/var/www/example
files.encoding=UTF-8
site.root.folder=${file.reference.www-example}
test.folder=${file.reference.example-test}

You can mix both in a single file without any problem.

Using: Netbeans 8.0.1

like image 40
lepe Avatar answered Sep 28 '22 02:09

lepe