Building and Running Alfresco

Document created by tpage Employee on Nov 23, 2015Last modified by resplin on Aug 25, 2017
Version 2Show Document
  • View in full screen mode

Building and running Alfresco

 

This information applies to versions of Alfresco above 5.0.

 

Note: As of Alfresco Content Services 5.2.0, code checkout should be done from Git instead of SVN.

 

Prerequisites

 

To build and run Alfresco on a development machine the following tools should be installed and working:

 

  • Java development kit (JDK), version 8
  • Apache Maven (version 3)
  • A database server. The default is PostgreSQL but any supported database may be used. A suitable user or schema owner must be created, as required by any Alfresco server (the default expectation is a user named alfresco)
  • Subversion (client) - to obtain the code.

Please see this blog post on how to obtain the new Share code base.

This article will refer to the $PLATFORM and $SHARE code bases as appropriate.

 

Building and running Share

 

It is now possible to build Share without having first checked out the $PLATFORM code base. To do this, firstly check out the $SHARE code:

  svn checkout https://svn.alfresco.com/repos/alfresco-open-mirror/web-apps/Share/trunk/ code-base

 

Then, from within the new code-base directory:

  mvn install

 

This will build the Share web application (share.war). In addition this will build a share-enabled Alfresco server web application (alfresco.war). To do this, the maven build process will download the Alfresco platform war file (the Alfresco server without Share support built-in), build an amp (Alfresco server add-on package) containing the Share extensions and apply the amp to the Alfresco platform war file. The result is a war file that may be deployed in an application server — however, the Alfresco maven development environment also provides a method for automatically downloading and configuring an Apache Tomcat application server and deploying the Alfresco repository war file in it. It will also start a Solr server instance that will provide indexing and search capabilities.

After the build is complete you will see the following war files have been created:

  alfresco/target/alfresco.war
  share/target/share.war

 

To run the Alfresco server (complete with Solr search services), from within the code-base directory:

  cd alfresco
  mvn install -Prun

 

This will start Tomcat with Solr and Alfresco deployed and configured. When startup has finished, you should be able to see the repository on the following URL in a browser:

http://localhost:8080/alfresco/

Note that upon the first run, a standard Alfresco repository configuration file named alfresco-global.properties will be created in tomcat/shared/classes (where 'tomcat' is a sibling of the 'alfresco' directory). The file assumes the default setup of using a PostgreSQL database. To set up a different database, it is possible to create the file (allowing you to tweak the contents) without running the server:

  mvn generate-resources -Prun

 

To run the Share UI, use a separate terminal window:

  cd ../share
  mvn install -Prun

 

You should then be able to view the Share UI at the following URL:

http://localhost:8081/share

Log in to Share using the username admin and password admin and from there you will be able to create sites, drag-and-drop files into the repository etc.

The content you create in the running repository will all be stored in the code-base/alfresco/runtime directory, along with entries in the chosen database. To start the server in a clean state (e.g. remove the binary content files, the Solr indexes and the database data), run the command as above, but with the addition of the purge profile:

  mvn install -Ppurge,run

 

After stopping the tomcat process, it is possible to start it without rebuilding the project using the command:

  mvn tomcat7:run

 

Building and running the platform

 

To build just the platform (without any Share support) you will need to checkout the $PLATFORM code base:

  svn checkout https://svn.alfresco.com/repos/alfresco-open-mirror/alfresco/HEAD code-base

 

Then, from within the new code-base/root directory:

  mvn install

 

After the build is complete you will see the following war file has been created:

  projects/web-client/target/alfresco.war

 

To run the Alfresco server (complete with Solr search services), from within the root directory:

  cd projects/web-client
  mvn install -Prun

 

This will start Tomcat with Solr and Alfresco deployed and configured. When startup has finished, you should be able to see the repository on the following URL in a browser:

http://localhost:8080/alfresco

Note that upon the first run, a standard Alfresco repository configuration file named alfresco-global.properties will be created in root/tomcat/shared/classes. The file assumes the default setup of using a PostgreSQL database. To set up a different database or override other settings change the properties in the file appropriately.

 

Debugging

 

It is possible to run the embedded Tomcat with debugging enabled so that a debugger may be attached to the process (for example, using Eclipse). To do this, run mvnDebug instead of mvn when running the Tomcat instance. For example:

 mvnDebug install -Prun

 

Debugging in Eclipse:

 

  • Create a debug profile
  • Select the appropriate project, e.g. for debugging the repository select that project.
  • Connection type: standard (socket attach)
  • Host: localhost
  • Port: 8000
  • Click 'debug'

You should now be able to halt on specific breakpoints.

Other IDEs will have similar mechanisms, please refer to their documentation for specific instructions.

1 person found this helpful

Attachments

    Outcomes