You are here

Creating an All-in-One (AIO) project (WARs)

The All-in-One maven archetype can be used to create a new multi-module project that will produce customized alfresco.war and share.war artifacts. For more information about this project type see All-in-One Archetype
This task assumes that you have completed all instructions in Installing and configuring.
This task shows how you can use the All-in-One archetype of the Alfresco SDK to generate a multi module extension project containing repo-amp, share-amp, and WAR projects.
  1. Create a suitable directory in which to store all your Maven projects (if you have not already done so), such as alfresco-extensions.
  2. Change into your alfresco-extensions directory.
  3. Run the following command:

    mvn archetype:generate -Dfilter=org.alfresco:       
    Important: As the archetypes are available via Maven Central you do not need to specify a catalog.

    You will be prompted to choose an archetype:

                        
    Choose archetype:
    1: remote -> org.alfresco.maven.archetype:alfresco-allinone-archetype (Sample multi-module project for All-in-One development on the Alfresco plaftorm. Includes modules for: Repository WAR overlay, Repository AMP, Share WAR overlay, Solr configuration, and embedded Tomcat runner)
    2: remote -> org.alfresco.maven.archetype:alfresco-amp-archetype (Sample project with full support for lifecycle and rapid development of Repository AMPs (Alfresco Module Packages))
    3: remote -> org.alfresco.maven.archetype:share-amp-archetype (Share project with full support for lifecycle and rapid development of AMPs (Alfresco Module Packages))
    Choose a number or apply filter (format: [groupId:]artifactId, case sensitive contains): : 
    
  4. Enter 1 to have Maven generate an Alfresco All-in-One project.
  5. You will be prompted to choose an archetype version:

    Choose org.alfresco.maven.archetype:alfresco-amp-archetype version: 
    1: 2.0.0-beta-1
    2: 2.0.0-beta-2
    3: 2.0.0-beta-3
    4: 2.0.0-beta-4
    5: 2.0.0
    6: 2.1.0
    7: 2.1.1
    8: 2.2.0
    Choose a number: 8: 
                                                

    Press Enter to select the default (which is the most recent version).

  6. You will then be prompted to enter a value for the property groupId:

    Define value for property 'groupId': : com.acme

    Here we have specified com.acme representing the domain for a fictional company acme.com. Specify a groupId matching your company domain.

  7. You will then be prompted to enter a value for the property artifactId:

    Define value for property 'artifactId': : acme-cms-poc

    Here we have specified acme-cms-poc representing a Proof-of-Concept (PoC) Content Management System (CMS) project to validate Alfresco as a perfect fit. Try and name the All-in-One projects so it is easy to know what they contain/represent. The naming should represent complete projects in contrast to specific AMP extensions that just implements a specific functionality in a larger solution. Note, hyphens are typically used in artifact IDs.

  8. You will then be prompted to enter a value for the property package:

    Define value for property 'package':  com.acme: : com.acme.cmspoc

    Here we have specified com.acme.cmspoc representing the top Java package for this project. This package will be used for any example Java code generated by the archetype. It is good practice to keep all Java code you write under this package so it does not clash with other projects. Any Spring beans generated by this archetype will use this package in the ID.

    Important: Java packages cannot have hyphens in them.
  9. You will then be prompted to enter Y to accept the values you have entered, or n to reject and change. Press Enter to accept the values.

    A new project directory containing a number of sub-directories and support files for the project will be created in the directory acme-cms-poc.

  10. Change into the freshly created acme-cms-poc directory and browse the various files and directories to see what has been created.

    The following directory structure has been created for you:

    acme-cms-poc/
    ├── pom.xml (Maven project file)
    ├── run.sh  (Mac/Linux script to run customized Alfresc WAR and Share WAR together with Solr 4 in Tomcat)
    ├── run.bat (Windows script to run customized Alfresc WAR and Share WAR together with Solr 4 in Tomcat)
    ├── acme-cms-poc-repo-amp  (This is a standard Repository AMP extions project - produces a Repository AMP)
    │   ├── pom.xml (Maven project file for AMP, put dependencies here that are only needed by this AMP)
    │   └── src
    │       ├── main
    │       │   ├── amp  (For more information about the AMP structure see: https://wiki.alfresco.com/wiki/AMP_Files)
    │       │   │   ├── config
    │       │   │   │   └── alfresco
    │       │   │   │       ├── extension
    │       │   │   │       │   └── templates
    │       │   │   │       │       └── webscripts  (Your Web Scripts should go under this directory)
    │       │   │   │       │           ├── webscript.get.desc.xml  (Sample Web Script that you can try out)
    │       │   │   │       │           ├── webscript.get.html.ftl
    │       │   │   │       │           └── webscript.get.js
    │       │   │   │       └── module
    │       │   │   │           └── acme-cms-poc-repo-amp  (AMP Module ID)
    │       │   │   │               ├── alfresco-global.properties (Put default values for properties specific to this extension here)
    │       │   │   │               ├── context
    │       │   │   │               │   ├── bootstrap-context.xml  (Bootstrapping of content models, content, i18n files etc)
    │       │   │   │               │   └── service-context.xml  (Your service beans go here)
    │       │   │   │               │   └── webscript-context.xml (Web Script Java controller beans)
    │       │   │   │               ├── model
    │       │   │   │               │   ├── content-model.xml   (Content model for your files)
    │       │   │   │               │   └── workflow-model.xml  (Content model for workflow implementations)
    │       │   │   │               └── module-context.xml  (Spring context file that is picked up by Alfresco)
    │       │   │   ├── module.properties  (AMP module ID, Version etc)
    │       │   │   └── web  (If your AMP has some UI the files would go here, unlikely now when the Alfresco Explorer UI is gone)
    │       │   │       ├── css
    │       │   │       │   └── demoamp.css
    │       │   │       ├── jsp
    │       │   │       │   └── demoamp.jsp
    │       │   │       ├── licenses
    │       │   │       │   └── README-licenses.txt
    │       │   │       └── scripts
    │       │   │           └── demoamp.js
    │       │   └── java  (Your Java classes go here, this is where most of the module extension implementation code would go, you can remove the demo component)
    │       │       └── com
    │       │           └── acme
    │       │               └── cmspoc
    │       │                   └── demoamp  (Demo module component and Web Script Java controller, can be removed)
    │       │                       ├── DemoComponent.java
    │       │                       └── Demo.java
    │       │                       └── HelloWorldWebScript.java
    │       └── test
    │           ├── java
    │           │   └── com
    │           │       └── acme
    │           │           └── cmspoc
    │           │               └── demoamp
    │           │                   └── test  (Example test of the demo component, can be removed)
    │           │                       └── DemoComponentTest.java
    │           ├── properties
    │           │   └── local
    │           │       └── alfresco-global.properties  (environment specific configuration, the local env is active by default)
    │           └── resources
    │               ├── alfresco
    │               │   └── extension
    │               │       └── disable-webscript-caching-context.xml  (file to disable server side JavaScript compilation to Java code)
    │               └── test-log4j.properties
    ├── acme-cms-poc-share-amp  (This is a standard Share AMP extions project - produces a Share AMP)
    │   ├── pom.xml (Maven project file for AMP, put dependencies here that are only needed by this AMP)
    │   └── src
    │       ├── main
    │       │   ├── amp  (For more information about the AMP structure see: https://wiki.alfresco.com/wiki/AMP_Files)
    │       │   │   ├── config
    │       │   │   │   └── alfresco
    │       │   │   │       └── web-extension
    │       │   │   │           ├── acme-cms-poc-share-amp-slingshot-application-context.xml  (Loads the acme-cms-poc-share-amp.properties file)
    │       │   │   │           ├── messages
    │       │   │   │           │   └── acme-cms-poc-share-amp.properties  (Custom share UI labels, messages etc)
    │       │   │   │           ├── site-data
    │       │   │   │           │   └── extensions
    │       │   │   │           │       └── acme-cms-poc-share-amp-example-widgets.xml  (Dojo package definitions for the Aikau framework, Share config)
    │       │   │   │           └── site-webscripts
    │       │   │   │               ├── com
    │       │   │   │               │   └── example
    │       │   │   │               │       └── pages
    │       │   │   │               │           ├── simple-page.get.desc.xml  (Simple Aikau page for demonstration purpose)
    │       │   │   │               │           ├── simple-page.get.html.ftl
    │       │   │   │               │           └── simple-page.get.js
    │       │   │   │               └── org
    │       │   │   │                   └── alfresco
    │       │   │   │                       └── README.md
    │       │   │   ├── file-mapping.properties
    │       │   │   ├── module.properties
    │       │   │   └── web
    │       │   │       └── js
    │       │   │           └── example
    │       │   │               └── widgets   (Simple Aikau widget for demonstration purpose)
    │       │   │                   ├── css
    │       │   │                   │   └── TemplateWidget.css
    │       │   │                   ├── i18n
    │       │   │                   │   └── TemplateWidget.properties
    │       │   │                   ├── templates
    │       │   │                   │   └── TemplateWidget.html
    │       │   │                   └── TemplateWidget.js
    │       │   ├── java
    │       │   │   └── com
    │       │   │       └── acme
    │       │   │           └── cmspoc
    │       │   └── resources
    │       │       └── META-INF
    │       │           └── share-config-custom.xml.sample
    │       └── test
    │           ├── java
    │           │   └── com
    │           │       └── acme
    │           │           └── cmspoc
    │           │               └── demoamp  (Example of how to use Alfresco Share Page Objects (PO) to create functional tests for your UI customizations)
    │           │                   ├── DemoPageTestIT.java
    │           │                   └── po
    │           │                       └── DemoPage.java
    │           └── resources
    │               └── testng.xml
    ├── repo  (This is the Alfresco WAR project - produces a customized Alfresco.WAR by applying the AMP produced by the /acme-cms-poc-repo-amp project) 
    │   ├── pom.xml (Maven project file for Repository WAR (alfresco.war), add AMP and JAR dependencies and overlay config here)
    │   └── src
    │       └── main
    │           ├── properties
    │           │   └── local
    │           │       └── alfresco-global.properties
    │           └── resources
    │               └── alfresco
    │                   └── extension
    │                       └── dev-log4j.properties
    ├── runner (Tomcat Runner that deploys the WARs produced by the /repo and /share projects, the Solr 4 webapp is deployed directly from maven repo)
    │   ├── pom.xml
    │   ├── src
    │   │   └── main
    │   │       └── webapp
    │   │           └── index.html
    │   └── tomcat   (Virtual Webapp contexts for RAD development)
    │       ├── context-repo.xml
    │       ├── context-share.xml
    │       └── context-solr.xml
    ├── share (This is the Share WAR project - produces a customized Share.WAR by applying the AMP produced by the /acme-cms-poc-share-amp project)
    │   ├── pom.xml (Maven project file for Share WAR (share.war), add AMP and JAR dependencies and overlay config here)
    │   └── src
    │       ├── main
    │       │   └── resources
    │       │       ├── alfresco
    │       │       │   └── web-extension
    │       │       │       ├── custom-slingshot-application-context.xml.sample
    │       │       │       └── share-config-custom.xml.sample
    │       │       └── log4j.properties
    │       └── test
    │           └── resources
    │               ├── alfresco
    │               │   └── web-extension
    │               │       └── share-config-custom.xml
    │               └── log4j.properties
    └── solr-config  (Loads the configuration files necessary for running Apache Solr 4)
        └── pom.xml
    
  11. At this point, before you have made any changes, you can build the project by typing:

    mvn clean install
    Note: Maven will ensure that all requirements are downloaded. This make take some time.

    As the build continues you will see the following artifacts built and installed in your local repository:

    • .m2/repository/com/acme/acme-cms-poc-repo-amp/1.0-SNAPSHOT/acme-cms-poc-repo-amp-1.0-SNAPSHOT.amp
    • .m2/repository/com/acme/acme-cms-poc-share-amp/1.0-SNAPSHOT/acme-cms-poc-share-amp-1.0-SNAPSHOT.amp
    • .m2/repository/com/acme/repo/1.0-SNAPSHOT/repo-1.0-SNAPSHOT.war, contains the acme-cms-poc-repo-amp-1.0-SNAPSHOT.amp
    • .m2/repository/com/acme/share/1.0-SNAPSHOT/share-1.0-SNAPSHOT.war, contains the acme-cms-poc-share-amp-1.0-SNAPSHOT.amp

    The project will return with the message BUILD SUCCESS.

  12. You can build, load RAD requirements, and run your project by typing:

    ./run.sh                                            
    Important: You may first need to make the shell script executable using the command chmod +x run.sh.
  13. Direct your web browser to:

    http://localhost:8080/share

    You can log in using a user name of admin and a password of admin.

  14. Using Alfresco Community version > 5.1.e (Optional)

    It is likely that the latest Alfresco Community version is newer than what is default in the SDK (i.e. 5.1.e). See this article for what do when setting newer version than 5.1.e. It requires a few more steps than just setting the version number.

  15. Configure Enterprise Edition (Optional)

    So far we have used the project with its default configuration, which is using Alfresco Community Edition 5.1.e. If you are going to work with the Enterprise edition, then you need to do the following:

    1. Decide what Enterprise version you will be using, if you are going to use version 5.1.0 then you are set as that is the default Enterprise version. If you want to use another version then open up the acme-cms-poc/pom.xml file and uncomment the <alfresco.version>5.1.e</alfresco.version> property and set the new version number you want to use. See this article for what do when setting newer version than 5.1.0. It requires a few more steps than just setting the version number.
    2. Update the run.sh and run.bat scripts to use the Enterprise edition, this is done by using the enterprise profile in the maven command line: mvn clean install -Prun,enterprise. Note. this automatically sets the version to 5.1.0 if you have not explicitly set it.
    3. And as you might have guessed, if you are not using the run script, you will have to remember to always activate the Enterprise profile when running: mvn clean install -Prun,enterprise
    4. Install an enterprise license, otherwise the server will be in read-only mode. It goes into the following directory:
      acme-cms-poc/
      ├── repo   
      │   ├── pom.xml
      │   └── src
      │       └── main
      │           ├── properties
      │           └── resources
      │               └── alfresco
      │                   └── extension
      │   │   │   │       │   └── license
      │   │   │   │       │       └── acme-5.1.0-enterprise.lic
      

    If the license is properly installed you should see logs as follows when the server starts:

    ...
    2015-05-08 09:52:21,359  INFO  [enterprise.license.AlfrescoLicenseManager] [localhost-startStop-1] Successfully installed license from file [/home/martin/src/alfresco-extensions/acme-cms-poc/runner/target/tomcat/webapps/repo/WEB-INF/classes/alfresco/extension/license/Enterprise-5.0.lic]
    ...
    2015-05-08 09:52:23,614  INFO  [service.descriptor.DescriptorService] [localhost-startStop-1] Alfresco started (Enterprise). Current version: 5.0.1 (r100823-b68) schema 8,022. Originally installed version: 5.0.0 (d r99759-b2) schema 8,022.
    ...
  16. Stopping the Embedded Tomcat Server

    To stop the Alfresco Tomcat server that was started with the mvn clean install -Prun command (either directly or indirectly via the run script), do Ctrl+C in the terminal that was used.

    The Maven embedded tomcat process will terminate after a short wait.

In this tutorial you have learned how to generate, deploy, and run a project using the All-in-One (AIO) archetype.

Sending feedback to the Alfresco documentation team

You don't appear to have JavaScript enabled in your browser. With JavaScript enabled, you can provide feedback to us using our simple form. Here are some instructions on how to enable JavaScript in your web browser.