Alfresco on NetBeans

cancel
Showing results for 
Search instead for 
Did you mean: 

Alfresco on NetBeans

resplin
Intermediate
0 0 2,741

Obsolete Pages{{Obsolete}}

The official documentation is at: http://docs.alfresco.com



Source ControlContributing

Back to: Developer Guide

See also: Developer Runtime Configuration

This page outlines the steps required to checkout the Alfresco Subversion Repository and setup a full development environment using NetBeans.  This allows for the re-build of Alfresco which is useful when extending or bug fixing the Alfresco product itself.


Extracting and Building


Follow the existing Extracting and Building procedure to extract and build Alfresco


Subversion Repository Access


The process for accessing the Alfresco Subversion repository is documented here


NetBeans Setup


  • The preferred versions of NetBeans for Alfresco are 6.0.1 and above. Though previous versions are not supported, a user shouldn't face any hassles following the same steps
  • Firstly, set the NetBeans java compiler compliance level to JDK 5. This can be done by setting the value of “netbeans_jdkhome” property in [NETBEANS_HOME]/etc/netbeans.conf to the home directory of JDK 5. Alternatively, the default location of JDK can be overridden by using --jdkhome <dir> while starting NetBeans from the command line
  • Install the “Eclipse Project Importer” plugin from the netbeans repository. The current version is 1.32.0.1.2.43. This adds the ability to import eclipse projects into NetBeans. Note that from NetBeans version 6.1 onwards this plugin will be available by default. More details can be found here

Importing Alfresco projects into NetBeans


There are 2 possible scenarios:

An Alfresco developer on eclipse who is looking to migrate to NetBeans:


  • Go to File -> Import Projects -> Eclipse Projects
  • Select the option “Import projects from Workspace” and select the eclipse workspace directory which contains the Alfresco projects
  • In the next window, select the projects “3rd Party, Alfresco JLAN, Catalina-virtual, Core, Deployment, Jndi-Client, Link Validation, Mbean, Remote API, Repository, Web Service Client, Web-Client, Web-Framework”, enter the “location of Netbeans projects” and click “finish”
  • Note that NetBeans only creates a reference to the actual sources in Eclipse workspace. This means you can now work in Eclipse and NetBeans at the same time and keep the files at same place

A developer new to Alfresco who is looking to build Alfresco using NetBeans:


  • This requires additional steps. You need to create a pseudo eclipse workspace to make use of the “eclipse project importer plugin” in NetBeans by creating the following directory structure: (A zip file containing the below mentioned resources is available here. Unzip it in the correct location)

[ROOT]
     |
     projects
            |
            .metadata
                    |
                    .plugins
                           |
                           org.eclipse.core.resources
                                                    |
                                                    .projects
                           org.eclipse.core.runtime
                                                  |
                                                  .settings

  • Under the directory [ROOT]/projects/.metadata/.plugins/org.eclipse.core.runtime/.settings create 2 files with the following contents:

File name : org.eclipse.jdt.launching.prefs

Content :
org.eclipse.jdt.launching.PREF_VM_XML=<vmSettings defaultVM\=''>\r\n<vmType id\=''>\r\n<vm id\='' name\='java' path\=''/>\r\n</vmType>\r\n</vmSettings>\r\n

File name : org.eclipse.jdt.core.prefs

Content : Empty file

NOTE: The value of org.eclipse.jdt.launching.PREF_VM_XML should be a on single line, check this if you cut and paste from the above text as some systems might insert additional line feeds


  • After creating the required files and directories, go to File -> Import Projects -> Eclipse Projects. Select the option “Import projects from Workspace” and select the [ROOT]/projects directory which contains the Alfresco projects. In the next window, select the projects “3rd Party, Alfresco JLAN, Catalina-virtual, Core, Deployment, Jndi-Client, Link Validation, Mbean, Remote API, Repository, Web Service Client, Web-Client, Web-Framework”, enter the “location of Netbeans projects” and click “finish”

Screen1.jpg


  • If you are concerned about the warnings (read as red flags) in the projects, consider creating a 'Alfresco3rdParty' library using the NetBeans library manager. This library should contain all the jars in the lib directory of 3rdparty project. Remember to recursively add all the libraries in all the sub directories. Add this library to all the projects. But this step is not a pre-requisite for successfully building a deployable Alfresco war.

Screen2.jpg


Running Ant From NetBeans


  • Open the ROOT/build.xml file in Netbeans. Open the “Navigator” window for this file, right click on the target you wish to run and select “Run Target”.
  • The default target is 'build-tomcat'. It builds and deploys alfresco.war in $TOMCAT_HOME/webapps. Other important targets are :
    • ant incremental-tomcat incrementally builds and deploys Alfresco for Tomcat
    • ant start-tomcat executes the Tomcat startup script
    • ant build-jboss builds and deploys Alfresco for JBoss
    • ant incremental-jboss incrementally builds and deploys Alfresco for JBoss
    • ant start-jboss executes the JBoss startup script
    • ant test runs unit tests for the entire project

Developer Runtime Configuration


Before running Alfresco you may want to check the following common configuration options