Maven Alfresco SDK – tutorial #2 Share Module

Previously we wrote about Maven Alfresco SDK and creating module for alfresco.war, now we are going to see how to create module for share.war application.

 Maven Alfresco SDKs pre-requisites

  • Download Maven 3.0.3+ version from maven.apache.org and install it using this instuction
  • Add MAVEN_OPTS=“-Xms256m -Xmx1G -XX:PermSize=500m“ ( I could not run jUnit with PermSize=300m ).
  • Check for java version 1.7 typing  java -version in  your console
  • I prefer eclipse you can feel free to use what you like the most

Creating eclipse project

  1. Open console and go to your desired workspace folder
  2. Enter next command using maven
     mvn archetype:generate -DarchetypeCatalog=https://artifacts.alfresco.com/nexus/content/groups/public/archetype-catalog.xml -Dfilter=org.alfresco.maven.archetype:

     

  3. Choose archetype by selecting between amp-archetype(1) and allinone-archetype(2), select first option
  4. Choose amp-archetype version by entering 5 (version 1.1.1)
  5. Define groupId: com.alfrescoblog
  6. Define artifactId: alfrescoBlogAMPArchShare
  7. You will be asked to confirm creating of maven project, if approved you will be creating project for alfresco module and that is  not the goal here, type N( for No )
  8. Wizard will ask you to type values for properties  groupId, artifactId, version, package and most important part alfresco_target_amp_client_war, here you need to enter share. Accept other default values and finish the wizard.
  9. Add created project to eclipse and walla .

Project structure

Most important path here is \src\main\amp\config\alfresco, this is where you would add your share pages, messageswebscripts and so on. Possible folders that can be there are listed bellow and their purpose as well.

  • messages folder, here you can put your custom messages
  • site-data, with subfolders pages and template-instaces is where you can put your custom pages
  • site-webscripts, would contain your webscripts that can be called upon latter in share applications
  •  templates, here you put your templates
  • web-extension, here you can put your custom share-config-custom.xml .

Adding share-config-custom.xml

When you want to search for something , for instance users in the system it is required to type minimum 3 characters long query. Lets override this to zero.

In web-extension folder create file with name share-config-custom.xml, contents of this file should be as it is listed bellow.

<alfresco-config>
   <config evaluator="string-compare" condition="Search" replace="true">
     <search>
      <!-- override minimum length for search terms with 0 -->
      <min-search-term-length>0</min-search-term-length>
     </search>
   </config>
</alfresco-config>

 

Packaging the amp

This is very easy thing to do, in console enter

mvn package

and find your amp in target folder of your project.

Copy this amp file in alfresco/amps_share, and execute alfresco/bin/apply_amps . Then start alfresco to see that custom configuration has been loaded and ready to go.

Another way that will allow you fast development is to start share on port 8080 while alfresco is already running. Share can be quickly started that worked with using next command

mvn integration-test -Pamp-to-war -Dmaven.tomcat.port=8081

Find alfresco share located on http://localhost:8081/share.

This concludes tutorial on how to create alfresco share module, how to package it , deploy.