With this SDK you can develop, package, test, run, document and release your Alfresco extension project. It is important to note that while previous versions of the Alfresco SDK were based around Ant, the latest versions of the SDK are based on Maven.
Links to documentation for previous versions are available on this page [1].
The Alfresco SDK 2.1 includes a number of Maven archetypes. These archetypes aim to provide a standardized approach to development, release, and deployment of Alfresco extensions.
From version 2.0 and up, releases for the Alfresco SDK are available in Maven Central.
The Alfresco SDK source code is hosted on GitHub [2].
The Alfresco SDK issue tracking is hosted on GitHub [3].
The Alfresco SDK forum for support is hosted on Alfresco Forums [4].
You will learn about the different Maven Archetypes that can be used to generate Alfresco extension projects. This section also walks through what SDK version is compatible with what Alfresco version. And you will find links to some useful community resources.
The following project types, and archetypes, are available:
You can view these archetypes when you obtain a list of archetypes from Maven Central:
mvn archetype:generate -Dfilter=org.alfresco:
This archetype should be used to extend the Alfresco Repository web application (alfresco.war).
The main features of this archetype are:
This archetype should be used to extend the Alfresco Share web application (share.war).
The main features of this archetype are:
The main features of the AIO archetype are:
It is recommended you use the latest version of the Alfresco SDK where possible.
The following table shows compatibility between Alfresco SDK and versions of Alfresco.
Alfresco version | Maven Alfresco Lifecycle (deprecated) | Maven SDK 1.0.x (deprecated) | Maven SDK 1.1.x | Alfresco SDK 2.0.x | Alfresco SDK 2.1.x |
---|---|---|---|---|---|
3.2.2 - 4.1.1.x | Compatible (but not supported) | Not available | Not available | Not available | Not available |
4.1.x (x >= 2) | Not available | Compatible (but not supported) | Not available (SDK 1.1.0 does not work with Alfresco 4.1.2-4.1.5 using Solr Search Subsystem [23]. It is possible to use Alfresco 4.1.6 and greater, or use Lucene Search Subsystem) | Not available | Not available |
4.2.x | Not available | Not available | Compatible and supported | Not available | Not available |
5.0 and 5.0.c | Not available | Not available | Not available | Compatible and supported | Not available |
5.0.1+ and 5.0.d+ | Not available | Not available | Not available | Compatible and supported | Compatible and supported |
Some community resources that are worth trying out:
Link | Description |
---|---|
Alfresco SDK on GitHub [2] | Where you can clone the code, submit issues and read community documentation. |
Order of the Bee [24] | Quoting from the site: We are an independent organization of the Alfresco community. We are here to promote Alfresco Community Edition and aggregate the best from the community for you. |
Mind the Gab [25] | News, thoughts and tutorials from one of the main developers behind the Alfresco SDK. |
Alfresco SDK 2.0 Deep Dive [26] | Article that takes a look at the "behind the scenes" stuff used by the Alfresco SDK 2.0. |
Ole Hejlskov's Alfresco SDK 2.0 Beta screencast [27] | Screencast showing use of the three main archetypes of the SDK in Eclipse. Also demonstrates some important features of the SDK such as hot reloading of code. |
Some things to do and note before you start:
You'll need to download and install the following tools and libraries, if you don't already have them:
There is no specific installation needed, just copy the JAR to a permanent place where you can refer to it.
Checking for the availability of the JDK.
javac -version
You will see a message such as the following, if you have the JDK installed:
javac 1.8.0_45
If you get "command not found" you need to install the JDK. Also if you have a version of the JDK prior to 1.8 you will need to install 1.8 or above. It is possible to have multiple versions of the JDK installed (and multiple Java run-times). You will later see how you can configure your JAVA_HOME variable so that Maven uses the correct version of the JDK.
Downloading the JDK.
Installing the JDK.
Verifying the JDK is successfully installed.
javac -version
This will display information such as the following:
javac 1.8.0_45
To be extra sure you should also check your Java run-time by entering the following command:
java -version
This will display information such as the following:
java version "1.8.0_45" Java(TM) SE Runtime Environment (build 1.8.0_45-b14) Java HotSpot(TM) 64-Bit Server VM (build 25.45-b02, mixed mode)
Double check that the version of Java installed is correct (1.8 or above).
export JAVA_HOME=/Library/Java/JavaVirtualMachines/jdk1.8.0_45.jdk/Contents/Home
Restart the terminal session or run source .bash_profile to activate the environment variable.
export JAVA_HOME=/usr/lib/jvm/java-8-oracle
Restart the terminal session or run source .bashrc to activate the environment variable.
$ env |grep JAVA_HOME JAVA_HOME=/usr/lib/jvm/java-8-oracle
You will see the value that JAVA_HOME has been set to.
Ensure that the result matches the value you specified in your shell configuration file (such as .bashrc).
If you are on Windows you can use a command such as SET J to display environment variables starting with 'J'.
Check for the availability of Maven.
mvn --version
If you get "command not found", or you have a version of Maven less than 3.2.5, you will need to install Maven or upgrade to 3.2.5 or above. In this case it is recommended you download the correct version of Maven (3.2.5+) from the official Maven website.
Downloading Maven.
Installing Maven.
Verifying Maven is correctly installed.
mvn --version
This will display information such as the following:
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00) Maven home: /usr/local/apache-maven-3.2.5 Java version: 1.8.0_45, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-oracle/jre Default locale: en_GB, platform encoding: UTF-8 OS name: "linux", version: "3.13.0-51-generic", arch: "amd64", family: "unix"
Check that the correct versions of Maven and the JDK are being used. If Maven is not using the correct version of the JDK, make sure you have set your JAVA_HOME environment variable, as described in the previous tutorial.
Setting Variables.
export M2_HOME=/opt/apache-maven-3.2.5 export MAVEN_OPTS="-Xms1024m -Xmx1G -javaagent:/home/martin/libs/springloaded-1.2.3.RELEASE.jar -noverify"
Restart the terminal session or run source .bash_profile to activate the environment variables.
See step 1 for Mac OS, do the same thing for Linux.
Restart the terminal session or run source .bashrc to activate the environment variable.
set M2_HOME=C:\Tools\apache-maven-3.3.1 set MAVEN_OPTS=-Xms256m -Xmx1G -javaagent:C:\Tools\spring-loaded\springloaded-1.2.3.RELEASE.jar -noverify
Restart the Windows terminal/console session.
Verifying Variables.
$ env|egrep "M2|MAV" MAVEN_OPTS=-Xms256m -Xmx1G -javaagent:/home/martin/libs/springloaded-1.2.3.RELEASE.jar -noverify M2_HOME=/usr/local/apache-maven-3.2.5
Ensure that the result matches the value you specified in your shell configuration file (such as .bashrc).
If you are on Windows you can use a command such as set M to display environment variables starting with 'M'.
C:\Users\mbergljung>set M M2_HOME=C:\Tools\apache-maven-3.3.1 MAVEN_OPTS=-Xms256m -Xmx1G -javaagent:C:\Tools\spring-loaded\springloaded-1.2.3.RELEASE.jar -noverify
The first matter to consider is to ensure that you have credentials for the Alfresco Private Repository, where the Enterprise artifacts are stored. In fact the private repository also includes all public artifacts too. Once you have suitable credentials you need to add support for Alfresco private repository to your configuration. This would typically be done by adding your access credentials to the settings.xml contained in your ~/.m2 directory (for Linux and OS X). On Windows 7 and Vista this resolves to <root>\Users\<username> and on XP it is <root>\Documents and Settings\<username>\.m2.
This procedure is explained in detail in the tutorial Configuring access to the Alfresco Private Repository [51].
<server> <id>alfresco-private-repository</id> <username>username</username> <password>password</password> </server>
At this point you have configured Maven to have access to the Alfresco Private Repository.
Apache Maven 3.2.5 (12a6b3acb947671f09b81f49094c53f426d8cea1; 2014-12-14T17:29:23+00:00) Maven home: /usr/local/apache-maven-3.2.5 Java version: 1.8.0_45, vendor: Oracle Corporation Java home: /usr/lib/jvm/java-8-oracle/jre Default locale: en_GB, platform encoding: UTF-8 OS name: "linux", version: "3.13.0-51-generic", arch: "amd64", family: "unix"
Make sure that the correct version of Maven is installed (3.2.5+) and that the correct version of the JDK is installed (1.8+). If you have multiple JDKs installed double check that Maven is using the correct version of the JDK. If you do not see this kind of output, and your operating system cannot find the mvn command, make sure that your PATH environment variable and M2_HOME environment variable have been properly set.
The tutorials show creation of projects using:
mvn archetype:generate -Dfilter=org.alfresco:
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): :
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 Choose a number: 6: 
Press Enter to select the default (the most recent version).
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.
Define value for property 'artifactId': : componentX-repo
Here we have specified componentX-repo representing an X component with a specific extension for the Alfresco Repository. Try and name the Repository extensions in a way so it is easy to see what kind of extension it is for the alfresco.war application. Here are some example names for repo extensions so you get the idea: zip-and-download-action-repo, digital-signature-repo, business-reporting-repo, these repository extensions would typically have corresponding Share extensions if they also include user interface functionality. It is good practice to use the following naming convention for repository extensions: {name}-repo, where -repo indicates that this is an Alfresco Repository extension. Note, hyphens are typically used in artifact IDs.
Define value for property 'package': com.acme: : com.acme.componentX
Here we have specified com.acme.componentX representing an X component Java package. 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 components/extensions. Any Spring beans generated by this archetype will use this package in the ID.
A new project directory containing a number of sub-directories and support files for the AMP will be created in the directory componentX-repo.
The following directory structure has been created for you:
componentX-repo/ ├── pom.xml (Maven project file) ├── run.sh (Mac/Linux script to have this AMP applied to the Alfresco WAR and run in Tomcat) ├── run.bat (Windows script to have this AMP applied to the Alfresco WAR and run in Tomcat) ├── src │  ├── main │  │  ├── amp (For more information about the AMP structure see: http://docs.alfresco.com/community/concepts/dev-extensions-modules-intro.html) │  │  │  ├── 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 │  │  │  │  └── componentX-repo (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) │  │  │  │  ├── log4j.properties │  │  │  │  ├── 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 │  │  └── componentX │  │  └── demoamp (Demo module component, can be removed) │  │  ├── DemoComponent.java │  │  └── Demo.java │  └── test │  ├── java │  │  └── com │  │  └── acme │  │  └── componentX │  │  └── 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) │  └── log4j.properties └── tomcat └── context.xml (Virtual Webapp context for RAD development)
mvn install
The project will return with the message BUILD SUCCESS. You should see the AMP artifact installed in your local repository .m2/repository/com/acme/componentX-repo/1.0-SNAPSHOT/componentX-repo-1.0-SNAPSHOT.amp
Let's start Tomcat via the script as follows (use run.bat on Windows):
./run.sh ... INFO: WSSERVLET12: JAX-WS context listener initializing Apr 30, 2015 10:04:39 AM com.sun.xml.ws.transport.http.servlet.WSServletDelegate <init> INFO: WSSERVLET14: JAX-WS servlet initializing 2015-04-30 10:04:39,152 WARN [shared_impl.util.LocaleUtils] [localhost-startStop-1] Locale name in faces-config.xml null or empty, setting locale to default locale : en_GB Apr 30, 2015 10:04:39 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] 2015-04-30 10:05:24,545 INFO [management.subsystems.ChildApplicationContextFactory] [SearchScheduler_Worker-1] Starting 'Transformers' subsystem, ID: [Transformers, default] 2015-04-30 10:05:24,741 INFO [management.subsystems.ChildApplicationContextFactory] [SearchScheduler_Worker-1] Startup of 'Transformers' subsystem, ID: [Transformers, default] complete
So far we have used the project with its default configuration, which is using Alfresco Community edition 5.0.d. If you are going to work with the Enterprise edition then you need to do the following:
componentX-repo/ ├── src │  ├── main │  │  ├── amp │  │  │  ├── config │  │  │  │  └── alfresco │  │  │  │  ├── extension │  │  │  │  │  └── license │  │  │  │  │  └── acme-5.0.1-enterprise.lic
mvn archetype:generate -Dfilter=org.alfresco:
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): :
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 Choose a number: 6:
Press Enter to select the default (which is the most recent version).
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.
Define value for property 'artifactId': : componentX-share
Here we have specified componentX-share representing an X component with a specific extension for the Alfersco Share UI. Try and name the Share extensions in a way so it is easy to see what kind of extension it is for the share.war application. Here are some example names for share extensions so you get the idea: zip-and-download-action-share, digital-signature-share, business-reporting-share, these share extensions would typically have corresponding Repo extensions if they also include server side business logic as part of the implementation. It is good practice to use the following naming convention for share extensions: {name}-share, where -share indicates that this is an Alfresco Share extension. Note, hyphens are typically used in artifact IDs.
Define value for property 'package': com.acme: : com.acme.componentX
Here we have specified com.acme.componentX representing an X component Java package. 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 components/extensions. Any Spring beans generated by this archetype will use this package in the ID.
A new project directory containing a number of sub-directories and support files for the AMP will be created in the directory componentX-share.
The following directory structure has been created for you:
componentX-share/ ├── pom.xml (Maven project file) ├── run.sh (Mac/Linux script to have this AMP applied to the Share WAR and run in Tomcat) ├── run.bat (Windows script to have this AMP applied to the Share WAR and run in Tomcat) ├── src │  ├── main │  │  ├── amp (For more information about the AMP structure see: https://wiki.alfresco.com/wiki/AMP_Files) │  │  │  ├── config │  │  │  │  └── alfresco │  │  │  │  └── web-extension │  │  │  │  ├── custom-slingshot-application-context.xml (Loads custom.properties) │  │  │  │  ├── messages │  │  │  │  │  └── custom.properties (Custom share UI labels, messages etc) │  │  │  │  ├── site-data │  │  │  │  │  └── extensions │  │  │  │  │  └── example-widgets.xml (Dojo package definitions for the Aikau framework) │  │  │  │  └── 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 demonstraion purpose) │  │  │  ├── css │  │  │  │  └── TemplateWidget.css │  │  │  ├── i18n │  │  │  │  └── TemplateWidget.properties │  │  │  ├── templates │  │  │  │  └── TemplateWidget.html │  │  │  └── TemplateWidget.js │  │  ├── java │  │  │  └── com │  │  │  └── acme │  │  │  └── componentX │  │  └── resources │  │  └── META-INF │  │  ├── resources │  │  │  └── test.html │  │  └── share-config-custom.xml.sample (Remove .sample to use and keep extension specific stuff in this config) │  └── test │  ├── java │  │  └── com │  │  └── acme │  │  └── componentX │  ├── properties │  └── resources │  ├── alfresco │  │  └── web-extension │  │  └── share-config-custom.xml (Configures where the Repository is running) │  └── log4j.properties └── tomcat └── context.xml (Virtual Webapp context for RAD development)
mvn install
The project will return with the message BUILD SUCCESS. You should see the AMP artifact installed in your local repository .m2/repository/com/acme/componentX-share/1.0-SNAPSHOT/componentX-share-1.0-SNAPSHOT.amp
Let's start Tomcat via the script as follows (use run.bat on Windows):
./run.sh ... Apr 30, 2015 11:40:42 AM org.apache.catalina.core.ApplicationContext log INFO: org.tuckey.web.filters.urlrewrite.UrlRewriteFilter INFO: loaded (conf ok) Apr 30, 2015 11:40:42 AM org.apache.catalina.core.ApplicationContext log INFO: Initializing Spring FrameworkServlet 'Spring Surf Dispatcher Servlet' Apr 30, 2015 11:40:42 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8081"]
So far we have used the project with its default configuration, which is using Alfresco Community edition 5.0.d. If you are going to work with the Enterprise edition then you need to do the following:
mvn archetype:generate -Dfilter=org.alfresco:
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): :
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 Choose a number: 6:
Press Enter to select the default (which is the most recent version).
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.
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.
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.
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.
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 Solr4 in Tomcat) ├── run.bat (Windows script to run customized Alfresc WAR and Share WAR together with Solr4 in Tomcat) ├── repo (This is the Alfresco WAR project - produces a customized Alfresco.WAR by applying the AMP produced by the /repo-amp project) │  ├── pom.xml │  └── src │  └── main │  ├── properties │  │  └── local │  │  └── alfresco-global.properties │  └── resources │  └── alfresco │  └── extension │  └── dev-log4j.properties ├── repo-amp (This is a standard Repository AMP extions project - produces a Repository AMP) │  ├── pom.xml │  └── 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 │  │  │  │  └── 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) │  │  │  │  ├── 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, can be removed) │  │  ├── DemoComponent.java │  │  └── Demo.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 ├── runner (Tomcat Runner that deploys the WARs produced by the /repo and /share projects, the Solr4 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 ├── run.sh ├── share (This is the Share WAR project - produces a customized Share.WAR by applying the AMP produced by the /share-amp project) │  ├── pom.xml │  └── src │  └── main │  └── resources │  ├── alfresco │  │  └── web-extension │  │  ├── custom-slingshot-application-context.xml.sample │  │  └── share-config-custom.xml.sample │  └── log4j.properties ├── share-amp (This is a standard Share AMP extions project - produces a Share AMP) │  ├── pom.xml │  └── src │  ├── main │  │  ├── amp (For more information about the AMP structure see: https://wiki.alfresco.com/wiki/AMP_Files) │  │  │  ├── config │  │  │  │  └── alfresco │  │  │  │  └── web-extension │  │  │  │  ├── custom-slingshot-application-context.xml (Loads the custom.properties file) │  │  │  │  ├── messages │  │  │  │  │ └── custom.properties (Custom share UI labels, messages etc) │  │  │  │  ├── site-data │  │  │  │  │ └── extensions │  │  │  │  │ └── example-widgets.xml (Dojo package definitions for the Aikau framework) │  │  │  │  └── 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 └── solr-config (Loads the configuration files necessary for running Apache Solr4) └── pom.xml
mvn install
As the builds goes on you will se the following artifacts built and installed in your local repository:
The project will return with the message BUILD SUCCESS.
./run.sh
http://localhost:8080/share
You can log in using a user name of admin and a password of admin.
So far we have used the project with its default configuration, which is using Alfresco Community edition 5.0.d. If you are going to work with the Enterprise edition then you need to do the following:
acme-cms-poc/ ├── repo │  ├── pom.xml │  └── src │  └── main │  ├── properties │  └── resources │  └── alfresco │  └── extension │  │  │  │  │  └── license │  │  │  │  │  └── acme-5.0.1-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. ...
Scripts and commands:
Command | Description |
---|---|
./run.sh and run.bat | Linux/Mac and Windows scripts for running an embedded Tomcat with the
customized alfresco.war (that is, with the Repo AMP applied) and the
flat file database H2. Access to Alfresco UI is via
http://localhost:8080/alfresco. The username/password is admin/admin.
This script will also configure JVM memory and automatically setup Spring Loaded for hot
reloading of classes (it basically sets up MAVEN_OPTS for you). See
inside the script for further details. Warning: This script assumes that you
are developing for the Alfresco Community Edition. If you use an Enterprise Edition you
need to update the maven command in this script so it uses the
enterprise profile: mvn integration-test
-Pamp-to-war,enterprise.
|
mvn compile alfresco:refresh-repo | Compiles the source code and puts the class files and resources under
/target. Then makes a POST call to the Alfresco Repository web
application (alfresco.war) to refresh the web script container. So
any changes that were made to web scripts should be visible after a page refresh.
Note: This command is typically used together with the
run.sh/bat script for Rapid Application Development
(RAD). The RAD process can be described like this:
|
mvn package | Runs unit tests and packages AMP in ${project.build.directory}/${project.build.finalName}.amp. |
mvn install | Like mvn package but also installs AMP in local Maven repository to be depended upon. |
mvn test | Runs unit tests. |
mvn install -DskipTests=true | Like mvn install but skips unit tests. |
mvn install -Pamp-to-war | Like run.sh or run.bat but does not configure JVM memory and Spring Loaded if you have not configured it in MAVEN_OPTS. See set up MAVEN_OPTS [38]. If you use the Enterprise edition see the next command. |
mvn install -Pamp-to-war,enterprise | Like mvn install -Pamp-to-war but uses Enterprise artifacts. Note you need to have set up access to the private repository [51] containing the Enterprise artifacts. |
mvn clean -Ppurge | Removes H2 database (with metadata), alf_data (with content files and index files),
and log files. Useful to purge the development repo (by default self contained in
${project.basedir}/alf_data_dev. Note: This is an important command
to use if you change significant settings in your project. For example, if you change
the Alfresco edition from Community to Enterprise. It is important to purge databases
and other data that might otherwise be persisted.
|
Scripts and commands:
Command | Description |
---|---|
./run.sh and run.bat | Linux/Mac and Windows scripts for running an embedded Tomcat with the
customized share.war (that is, with the Share AMP applied). Access to
Alfresco Share UI is via http://localhost:8081/share. The
username/password is admin/admin. This script will also configure JVM memory and
automatically setup Spring Loaded for hot reloading of classes (it basically sets up
MAVEN_OPTS for you). See inside script for further details. Warning: This script assumes that you are developing for the Alfresco Community
Edition. If you use an Enterprise Edition you need to update the maven command in this
script so it uses the enterprise profile: mvn integration-test
-Pamp-to-war,enterprise.
Warning: This script also assumes
that another Tomcat is running locally on port 8080 with the Alfresco Repository
(alfresco.war) web application deployed.
|
mvn compile alfresco:refresh-share | Compiles the source code and puts the class files and resources under
/target. Then makes POST calls to the Alfresco Share web
application (share.war) to refresh the Spring Surf web script
container and clear dependency caches. So any changes that was made to web scripts, Aikau
pages, Aikau Widgets, Dashlets, and so on, should be visible after a page refresh.
Note: This command is typically used together with the run.sh/bat script for Rapid
Application Development (RAD). The RAD process can be described like this:
|
mvn package | Runs unit tests and packages AMP in ${project.build.directory}/${project.build.finalName}.amp. |
mvn install | Like mvn package but also installs AMP in local Maven repository to be depended upon. |
mvn test | Runs unit tests. |
mvn install -DskipTests=true | Like mvn install but skips unit tests. |
mvn install -Pamp-to-war | Like run.sh or run.bat but does not configure JVM memory and Spring Loaded if you have not configured it in MAVEN_OPTS. See set up MAVEN_OPTS [38]. If you use the Enterprise edition see next command. |
mvn install -Pamp-to-war,enterprise | Like mvn install -Pamp-to-war but uses Enterprise artifacts. Note you need to have set up access to the private repository [51] containing the Enterprise artifacts. |
The All-in-One Alfresco project contains the following modules:
Scripts and commands:
Command | Description |
---|---|
./run.sh and run.bat | Linux/Mac and Windows scripts for running an embedded Tomcat with the
customized alfresco.war (repo-amp applied), custom share.war
(share-amp applied), and solr4.war. Access to Alfresco Share UI is via
http://localhost:8080/share. Username/pwd is admin/admin. This script
will also configure JVM memory and automatically setup Spring Loaded for hot reloading of
classes (it basically sets up MAVEN_OPTS for you). See inside script for
further details. Warning: This script assumes that you are developing for the
Alfresco Community edition. If you use an Enterprise Edition you need to update the
maven command in this script so it uses the 'enterprise' profile: mvn install
-Prun,enterprise.
|
repo-amp/mvn compile alfresco:refresh-repo | Compiles the source code for the Repository AMP and puts the class files and
resources under repo-amp/target. Then makes a POST call to the Alfresco Repository web
application (alfresco.war) to refresh the web script container. So any changes that was
made to Web scripts should be visible after a page refresh. Note: This command is
typically used together with the run.sh/bat script for Rapid Application Development
(RAD). The RAD process can be described like this:
|
share-amp/mvn compile alfresco:refresh-share | Compiles the source code for the Share AMP and puts the class files and
resources under share-amp/target. Then makes POST calls to the
Alfresco Share web application (share.war) to refresh the Spring Surf
web script container and clear dependency caches. So any changes that was made to web
scripts, Aikau pages, Aikau widgets, dashlets, and so on, should be visible after a page
refresh. Note: This command is typically used together with the
run.sh/bat script for Rapid Application
Development (RAD). The RAD process can be described like this:
|
mvn package | Runs unit tests and packages modules in their respective target directories, for example:
Note: This does not apply these newly packaged AMPs to their respective WARs, use
mvn install for that.
|
mvn install | Like mvn package but also installs artifacts in local Maven
repository, for example:
|
mvn install -DskipTests=true | Like mvn install but skips unit tests. |
mvn install -Prun | Like run.sh or run.bat but does not configure JVM memory and Spring Loaded if you have not configured it in MAVEN_OPTS, see set up MAVEN_OPTS [38]. If you use the Enterprise edition, see the next command. |
mvn install -Prun,enterprise | Like mvn install -Prun but uses Enterprise artifacts. Note you need to have set up access to the private repository [51] containing the Enterprise artifacts. |
mvn clean install -Prun,regression-testing | Runs regression testing of the Alfresco Share UI (share.war).
Uses the Alfresco internal Selenium Page Object (PO) based tests. This is very useful when
you have developed a lot of customizations for the Share UI and you want to make sure you
have not broken any standard Share UI functionality. Typically run this from a CI server
(or better a Selenium-Grid) to test for regression of the standard Alfresco Share UI.
Important: The Selenium WebDriver is configured to use FireFox (FF) by
default, so you need to have FF installed for the regression tests to be able to run.
Use version 35 or newer.
Important: It is also highly recommended that the workstation that is running
the regression tests is not being worked on at the same time as the tests are running,
as that can affect the outcome of the tests.
Warning: This command assumes that you are developing for the Alfresco
Community Edition. If you use an Enterprise Edition you need to update the maven command
so it uses the 'enterprise' profile and the Enterprise share-po
library: mvn clean install -Prun,enterprise,regression-testing. Also,
make sure that you have installed an enterprise license in the repo
project, otherwise the system will be in read-only mode and loads of tests will not
pass.
|
mvn clean install -Prun,functional-testing | Runs functional testing of the Alfresco Share UI customizations that you have
developed, such as pages and Dashlets. For information about how to write these tests, see
the example test called
share-amp/src/test/java/{package-path}/demoamp/DemoPageTestIT and
its Page Object class called
share-amp/src/test/java/{package-path}/demoamp/po/DemoPage.java.
Important: The Selenium WebDriver is configured to use FireFox (FF) by
default, so you need to have FF installed for the functional tests to be able to run.
Use version 35 or newer.
Important: It is also highly recommended that the workstation that is running
the functional tests is not being worked on at the same time as the tests are running,
as that can affect the outcome of the tests.
Warning: This command assumes that you are developing for the Alfresco
Community Edition. If you use an Enterprise Edition you need to update the maven command
so it uses the 'enterprise' profile and the Enterprise share-po
library: mvn clean install -Prun,enterprise,functional-testing.
|
mvn clean -Ppurge | Removes H2 database (with metadata), alf_data (with content files and index files),
and log files. Useful to purge the development repo (by default self contained in
${project.basedir}/alf_data_dev. Note: This is an important command
to use if you change significant settings in your project. For example, if you change
the Alfresco Edition from Community to Enterprise. It is important to purge databases
and other data that might otherwise be persisted.
|
Rapid Application Development (RAD) and Test Driven Development (TDD) are big goals for the Alfresco SDK. The SDK is designed to support the hot reloading of code (via Spring Loaded) so that you can modify JavaScript, FreeMarker and Java code, and have the changes take effect without having to click the Refresh Web Scripts button, restart Alfresco Tomcat, or restart anything else.
For example, in your SDK project, you can change test code, re-run your test, and the results will be displayed immediately. This allows for Test Driven Development (TDD).
The hot reloading above all saves you time as a developer. No more waiting around for Alfresco Tomcat restarts to see your code changes take effect.
You should see a dialog looking something like this when importing an All-in-One (AIO) project:
The project, and any sub-projects, will now be imported.
If your project is using the Enterprise edition of Alfresco you also want Eclipse to load the enterprise versions of the Alfresco WARs and related libraries. You can do this by enable the enterprise profile. In the Package Explorer view to the left, right click on the all-in-one project, then select Maven from the popup menu. Now in the next popup menu choose Select Maven Profiles.... In the dialog that appears select the enterprise profile, you should see a dialog looking something like this now:
Start an instance of Alfresco Tomcat that will be used for hot-reloading.
alfresco-extensions/all-in-one$ ./run.sh
The All-in-One project (and the Repository AMP project) have a sample Web Script included. You can invoke it by pointing your web browser at http://localhost:8080/alfresco/service/sample/helloworld. If you need to login then use admin with password admin. Running this Web Script produces the output "Message: Hello World from JS! HelloFromJava".
The All-in-One project (and the Share AMP project) have a sample Aikau page included. You can display it by pointing your web browser at http://localhost:8080/share/page/hdp/ws/simple-page. If you need to login then use admin with password admin. The page should display as follows:
Enabling Rapid Application Development (RAD) in Eclipse.
Testing RAD when doing Repository customizations (alfresco.war).
This is the controller for the Web Script that we tried after starting the server. Update the controller code by adding an 'UPDATED' string as follows:
model["fromJS"] = "Hello World from JS! UPDATED";
The application server log should display messages about the web scripts being refreshed:
2015-05-12 11:13:40,652 INFO [extensions.webscripts.DeclarativeRegistry] [http-bio-8080-exec-9] Registered 407 Web Scripts (+0 failed), 549 URLs 2015-05-12 11:13:40,653 INFO [extensions.webscripts.DeclarativeRegistry] [http-bio-8080-exec-9] Registered 1 Package Description Documents (+0 failed) 2015-05-12 11:13:40,653 INFO [extensions.webscripts.DeclarativeRegistry] [http-bio-8080-exec-9] Registered 0 Schema Description Documents (+0 failed) 2015-05-12 11:13:40,656 INFO [extensions.webscripts.AbstractRuntimeContainer] [http-bio-8080-exec-9] Initialised Repository Web Script Container (in 2215.1865ms) 2015-05-12 11:13:42,414 INFO [extensions.webscripts.DeclarativeRegistry] [asynchronouslyRefreshedCacheThreadPool1] Registered 407 Web Scripts (+0 failed), 549 URLs 2015-05-12 11:13:42,414 INFO [extensions.webscripts.DeclarativeRegistry] [asynchronouslyRefreshedCacheThreadPool1] Registered 1 Package Description Documents (+0 failed) 2015-05-12 11:13:42,414 INFO [extensions.webscripts.DeclarativeRegistry] [asynchronouslyRefreshedCacheThreadPool1] Registered 0 Schema Description Documents (+0 failed)Note that there is no output in the Eclipse console, or other window. Also, it is only the Repository Application (i.e. alfresco.war) that is being refreshed, the Share application is not touched.
The output from the Web Script should change to "Message: Hello World from JS! UPDATED HelloFromJava". Note that there is no need to restart the application server, just a Make of the project, and a refresh of the Web Script page from the browser (you are basically invoking the Web Script again and the update should be immediately visible).
This is the FreeMarker template for the Web Script. Update the template by adding an 'ExtraTemplateText' string as follows:
Message: ${fromJS} ${fromJava} ExtraTemplateText
The application server log should display messages about the web scripts being refreshed.
The output from the Web Script should change to "Message: Hello World from JS! UPDATED HelloFromJava ExtraTemplateText ". Again, note that there is no need to restart the application server, only a Make of the project and a refresh of the Web Script page are necessary.
The properties file should have one property as follows:
hello.word.extras=Extra Stuff From Props
The FreeMarker template should now look like this:
Message: ${fromJS} ${fromJava} ExtraTemplateText ${msg("hello.word.extras")}
The application server log should display messages about the web scripts being refreshed.
The output of the Web Script should change to "Message: Hello World from JS! UPDATED HelloFromJava ExtraTemplateText Extra Stuff From Props". No restart of application server should be needed, just a Make of the project and a refresh of the Web Script page from the browser.
Change the property text as follows:
public class HelloWorldWebScript extends DeclarativeWebScript { protected Map<String, Object> executeImpl( WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); model.put("fromJava", "HelloFromJavaUPDATED"); return model; } }
The application server log should display messages about the web scripts being refreshed.
The output of the Web Script should change to "Message: Hello World from JS! UPDATED HelloFromJavaUPDATED ExtraTemplateText Extra Stuff From Props". No restart of application server should be needed, just a Make of the project and a refresh of the Web Script page from the browser.
Test Driven Development (TDD) and RAD when doing Repository customizations (alfresco.war).
The test will run, and three tests will pass, the Console will have logs as follows:
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Alfresco Repository AMP Module 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:set-version (default-set-version) @ repo-amp --- [INFO] Removed -SNAPSHOT suffix from version - 1.0 [INFO] Added timestamp to version - 1.0.1505121136 [INFO] [INFO] --- build-helper-maven-plugin:1.9.1:add-test-resource (add-env-test-properties) @ repo-amp --- [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/martin/src/alfresco-extensions/all-in-one/repo-amp/src/main/resources [INFO] Copying 16 resources to ../repo-amp [INFO] [INFO] --- yuicompressor-maven-plugin:1.5.1:compress (compress-js) @ repo-amp --- [INFO] nothing to do, /home/martin/src/alfresco-extensions/all-in-one/repo-amp/target/classes/../repo-amp/web/scripts/demoamp-min.js is younger than original, use 'force' option or clean your target [INFO] nb warnings: 0, nb errors: 0 [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh (refresh-webscripts-repo-and-share) @ repo-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Repository [INFO] [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ repo-amp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] Copying 1 resource [INFO] [INFO] --- maven-resources-plugin:2.7:copy-resources (add-module-properties-to-test-classpath) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource to alfresco/module/repo-amp [INFO] [INFO] --- maven-resources-plugin:2.7:copy-resources (add-module-config-to-test-classpath) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 11 resources [INFO] [INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ repo-amp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.18:test (default-test) @ repo-amp --- [INFO] Surefire report directory: /home/martin/src/alfresco-extensions/all-in-one/repo-amp/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.alfresco.allinone.demoamp.test.DemoComponentTest Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.088 sec - in org.alfresco.allinone.demoamp.test.DemoComponentTest Results : Tests run: 3, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 7.232 s [INFO] Finished at: 2015-05-12T11:36:13+01:00 [INFO] Final Memory: 27M/338M [INFO] ------------------------------------------------------------------------
Note the test will run again and this time fail. But you did not need to restart Alfresco. This demonstrates hot reloading of Java code.
Now you will see that all tests pass. The code has re-run without any reloading of Alfresco! This allows for Test Driven Development with very low overhead.
Testing RAD when doing Share customizations (share.war).
This is the controller for the Aikau Page Web Script that we tried after starting the server. Update the controller code by adding an 'UPDATED' string as follows to the page title, also change the layout from HorizontalWidgets to VerticalWidgets:
model.jsonModel = { widgets: [{ id: "SET_PAGE_TITLE", name: "alfresco/header/SetTitle", config: { title: "This is a simple page UPDATED" } }, { id: "MY_HORIZONTAL_WIDGET_LAYOUT", name: "alfresco/layout/VerticalWidgets", config: { widgetWidth: 50, widgets: [ { id: "DEMO_SIMPLE_LOGO", name: "alfresco/logo/Logo", config: { logoClasses: "alfresco-logo-only" } }, { id: "DEMO_SIMPLE_MSG", name: "example/widgets/TemplateWidget" } ] } }] };
The Share web application will now have the web script container refreshed and the resouce cache cleared.
The page should now display as follows:
This is the Stylesheet for the Aikau Widget. Update the widget style as follows:
.my-template-widget { border: 2px #000000 solid; padding: 1em; width: 100px; color: white; background-color: blue; }
This is the resource file for the the Aikau Widget. Update the properties as follows:
hello-label=Hello from i18n UPDATED! hello-test=Going to use this label too now!
This is the HTML template file for the the Aikau Widget. Update so it looks as follows:
<div class="my-template-widget">${greeting} and ${greeting2}</div>
This is the main JavaScript implementation for the Aikau Widget. Update so it also sets the new property used in template:
define(["dojo/_base/declare", "dijit/_WidgetBase", "alfresco/core/Core", "dijit/_TemplatedMixin", "dojo/text!./templates/TemplateWidget.html" ], function(declare, _Widget, Core, _Templated, template) { return declare([_Widget, Core, _Templated], { templateString: template, i18nRequirements: [ {i18nFile: "./i18n/TemplateWidget.properties"} ], cssRequirements: [{cssFile:"./css/TemplateWidget.css"}], buildRendering: function example_widgets_TemplateWidget__buildRendering() { this.greeting = this.message('hello-label'); this.greeting2 = this.message('hello-test'); this.inherited(arguments); } }); });
The page should now display as follows:
Enabling RAD in Eclipse with Run Configurations.
In this article we have seen how we can achieve Rapid Application Development within Eclipse by having the alfresco maven plugin refresh goals executed automatically (magically) after a Make, which is triggered by saving the file. This auto-refresh feature is enabled by default when you use Eclipse. If you don't want that, and instead want to have more control over when web application refreshs happens etc, then you can use a Run Configuration instead and disable auto-refresh. In the following tutorial you will see how run configurations can be used for better control of when the refresh call is being made.
... <share.client.url>http://localhost:8080/share</share.client.url> <!-- Turn off auto-refresh of web applications --> <maven.alfresco.refresh.mode>none</maven.alfresco.refresh.mode> </properties>Besides none, the other values for this property are:
The build will run with the following result, the Eclipse Console will output:
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Alfresco Repository AMP Module 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:set-version (default-set-version) @ repo-amp --- [INFO] Removed -SNAPSHOT suffix from version - 1.0 [INFO] Added timestamp to version - 1.0.1505121201 [INFO] [INFO] --- build-helper-maven-plugin:1.9.1:add-test-resource (add-env-test-properties) @ repo-amp --- [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/martin/src/alfresco-extensions/all-in-one/repo-amp/src/main/resources [INFO] Copying 16 resources to ../repo-amp [INFO] [INFO] --- yuicompressor-maven-plugin:1.5.1:compress (compress-js) @ repo-amp --- [INFO] nothing to do, /home/martin/src/alfresco-extensions/all-in-one/repo-amp/target/classes/../repo-amp/web/scripts/demoamp-min.js is younger than original, use 'force' option or clean your target [INFO] nb warnings: 0, nb errors: 0 [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh (refresh-webscripts-repo-and-share) @ repo-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Repository [INFO] [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ repo-amp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh-repo (default-cli) @ repo-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Repository [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 8.440 s [INFO] Finished at: 2015-05-12T12:01:13+01:00 [INFO] Final Memory: 29M/342M [INFO] ------------------------------------------------------------------------
In the IDEA Settings dialog you should see something like this:
In the IDEA Project Structure dialog you should see something like this:
You should see a dialog looking something like this when you have located an All-in-One (AIO) project:
If your project is using the Enterprise edition of Alfresco you also want IDEA to load the enterprise versions of the Alfresco WARs and related libraries. You can do this by enable the enterprise profile. In the Maven Projects tool view to the right expand the Profiles folder, then check the enterprise profile. You should see a dialog looking something like this:
You should see a dialog looking something like this:
The project will build, and information will be displayed in the Console. You will see a message similar to the following, indicating that the project was successfully built.
/usr/lib/jvm/java-8-oracle/bin/java -Xms256m -Xmx1G -XX:PermSize=500m -javaagent:/home/martin/libs/springloaded-1.2.3.RELEASE.jar -noverify -Dmaven.home=/usr/local/apache-maven-3.2.5 ...... install [INFO] Reactor Summary: [INFO] [INFO] Alfresco Repository and Share Quickstart with database and an embedded Tomcat runner. SUCCESS [ 0.387 s] [INFO] Alfresco Repository AMP Module ..................... SUCCESS [ 38.368 s] [INFO] Alfresco Share AMP Module .......................... SUCCESS [ 0.734 s] [INFO] Alfresco Repository WAR Aggregator ................. SUCCESS [ 11.000 s] [INFO] Alfresco Solr 4 Configuration ...................... SUCCESS [ 0.028 s] [INFO] Alfresco Share WAR Aggregator ...................... SUCCESS [ 9.903 s] [INFO] Alfresco, Share and Solr4 Tomcat Runner ............ SUCCESS [ 0.007 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 01:01 min [INFO] Finished at: 2015-05-06T11:28:02+01:00 [INFO] Final Memory: 61M/503M [INFO] ------------------------------------------------------------------------ Process finished with exit code 0
Start an instance of Alfresco Tomcat that will be used for hot-reloading.
alfresco-extensions/all-in-one$ ./run.sh
The All-in-One project (and the repository AMP project) have a sample web script included. You can invoke it by pointing your web browser at http://localhost:8080/alfresco/service/sample/helloworld. If you need to login then use admin with password admin. Running this web script produces the output "Message: Hello World from JS! HelloFromJava".
The All-in-One project (and the Share AMP project) have a sample Aikau page included. You can display it by pointing your web browser at http://localhost:8080/share/page/hdp/ws/simple-page. If you need to login then use admin with password admin. The page should display as follows:
Enabling Rapid Application Development (RAD) in IDEA.
The All-in-One project has one Repository AMP project by default (all-in-one/repo-amp), we need to set up IDEA so that when we build via IDEA (that is, not via Maven) a script runs that will refresh the Repo Web Script container. In the Maven Projects tool view to the right expand the Alfresco Repository AMP Module folder, then expand the Plugins folder. Now expand the alfresco plugin folder. Right click on the alfresco:refresh-repo goal of the plugin. In the drop down menu select Execute After Make. You should now see a dialog looking something like this:
The All-in-One project has one Share AMP project by default (all-in-one/share-amp), we need to set up IDEA so that when we build via IDEA (that is, not via Maven) a script runs that will refresh the Surf Web Script container and clear dependency caches. In the Maven Projects tool view to the right expand the Alfresco Share AMP Module folder, then expand the Plugins folder. Now expand the alfresco plugin folder. Right click on the alfresco:refresh-share goal of the plugin. In the drop down menu select Execute After Make. You should now see a dialog looking something like this:
Testing RAD when doing repository customizations (alfresco.war).
This is the controller for the web script that we tried after starting the server. Update the controller code by adding an 'UPDATED' string as follows:
model["fromJS"] = "Hello World from JS! UPDATED";
The message console in IDEA should display BUILD SUCCESS for both the repo-amp and share-amp modules as follows:
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Alfresco Repository AMP Module 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh-repo (default-cli) @ repo-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Repository [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.854 s [INFO] Finished at: 2015-05-11T10:20:17+01:00 [INFO] Final Memory: 15M/315M [INFO] ------------------------------------------------------------------------ [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Alfresco Share AMP Module 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh-share (default-cli) @ share-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Share [INFO] Successfull Clear Dependency Caches for Alfresco Share [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.173 s [INFO] Finished at: 2015-05-11T10:20:24+01:00 [INFO] Final Memory: 18M/309M [INFO] ------------------------------------------------------------------------ [INFO] Maven execution finishedNote the refresh calls to the web applications. If you would prefer to only refresh the repository webapp (that is, alfresco.war) have a look later on in this article for a different approach to refreshing the webapp via run configurations.
The output from the web script should change to "Message: Hello World from JS! UPDATED HelloFromJava". Note that there is no need to restart the application server, just a Make of the project, and a refresh of the web script page from the browser (you are basically invoking the web script again and the update should be immediately visible).
This is the FreeMarker template for the web script. Update the template by adding an 'ExtraTemplateText' string as follows:
Message: ${fromJS} ${fromJava} ExtraTemplateText
The message console in IDEA should display BUILD SUCCESS
The output from the web script should change to "Message: Hello World from JS! UPDATED HelloFromJava ExtraTemplateText ". Again, note that there is no need to restart the application server, only a Make of the project and a refresh of the web script page are necessary.
The properties file should have one property as follows:
hello.word.extras=Extra Stuff From Props
The FreeMarker template should now look like this:
Message: ${fromJS} ${fromJava} ExtraTemplateText ${msg("hello.word.extras")}
The message console in IDEA should display BUILD SUCCESS.
The output of the web script should change to "Message: Hello World from JS! UPDATED HelloFromJava ExtraTemplateText Extra Stuff From Props". No restart of application server should be needed, just a Make of the project and a refresh of the web script page from the browser.
Change the property text as follows:
public class HelloWorldWebScript extends DeclarativeWebScript { protected Map<String, Object> executeImpl( WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); model.put("fromJava", "HelloFromJavaUPDATED"); return model; } }
The message console in IDEA should display BUILD SUCCESS.
The output of the web script should change to "Message: Hello World from JS! UPDATED HelloFromJavaUPDATED ExtraTemplateText Extra Stuff From Props". No restart of application server should be needed, just a Make of the project and a refresh of the web script page from the browser.
Test Driven Development (TDD) and RAD when doing Repository customizations (alfresco.war).
The test will run, and three tests will pass:
/usr/lib/jvm/java-8-oracle/bin/java -Xms256m -Xmx1G -javaagent:/home/martin/libs/springloaded-1.2.3.RELEASE.jar -noverify -Dmaven.home=/usr/local/apache-maven-3.2.5 .... [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Alfresco Repository AMP Module 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:set-version (default-set-version) @ repo-amp --- [INFO] Removed -SNAPSHOT suffix from version - 1.0 [INFO] Added timestamp to version - 1.0.1505120757 [INFO] [INFO] --- build-helper-maven-plugin:1.9.1:add-test-resource (add-env-test-properties) @ repo-amp --- [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/martin/src/alfresco-extensions/all-in-one/repo-amp/src/main/resources [INFO] Copying 14 resources to ../repo-amp [INFO] [INFO] --- yuicompressor-maven-plugin:1.5.1:compress (compress-js) @ repo-amp --- [INFO] nothing to do, /home/martin/src/alfresco-extensions/all-in-one/repo-amp/target/classes/../repo-amp/web/scripts/demoamp-min.js is younger than original, use 'force' option or clean your target [INFO] nb warnings: 0, nb errors: 0 [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh (refresh-webscripts-repo-and-share) @ repo-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Repository [INFO] [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ repo-amp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 2 resources [INFO] Copying 1 resource [INFO] [INFO] --- maven-resources-plugin:2.7:copy-resources (add-module-properties-to-test-classpath) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 1 resource to alfresco/module/repo-amp [INFO] [INFO] --- maven-resources-plugin:2.7:copy-resources (add-module-config-to-test-classpath) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] Copying 9 resources [INFO] [INFO] --- maven-compiler-plugin:3.2:testCompile (default-testCompile) @ repo-amp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- maven-surefire-plugin:2.18:test (default-test) @ repo-amp --- [INFO] Surefire report directory: /home/martin/src/alfresco-extensions/all-in-one/repo-amp/target/surefire-reports ------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.alfresco.allinone.demoamp.test.DemoComponentTest Tests run: 3, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.085 sec - in org.alfresco.allinone.demoamp.test.DemoComponentTest Results : Tests run: 3, Failures: 0, Errors: 0, Skipped: 0 [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6.946 s [INFO] Finished at: 2015-05-12T07:57:24+01:00 [INFO] Final Memory: 25M/443M [INFO] ------------------------------------------------------------------------
Note the test will run again and this time fail. But you did not need to restart Alfresco. This demonstrates hot reloading of Java code.
Now you will see that all tests pass. The code has re-run without any reloading of Alfresco! This allows for Test Driven Development with very low overhead.
Testing RAD when doing Share customizations (share.war).
This is the controller for the Aikau Page web script that we tried after starting the server. Update the controller code by adding an 'UPDATED' string as follows to the page title, also change the layout from HorizontalWidgets to VerticalWidgets:
model.jsonModel = { widgets: [{ id: "SET_PAGE_TITLE", name: "alfresco/header/SetTitle", config: { title: "This is a simple page UPDATED" } }, { id: "MY_HORIZONTAL_WIDGET_LAYOUT", name: "alfresco/layout/VerticalWidgets", config: { widgetWidth: 50, widgets: [ { id: "DEMO_SIMPLE_LOGO", name: "alfresco/logo/Logo", config: { logoClasses: "alfresco-logo-only" } }, { id: "DEMO_SIMPLE_MSG", name: "example/widgets/TemplateWidget" } ] } }] };
The message console in IDEA should display BUILD SUCCESS for both the repo-amp and share-amp modules as follows:
[INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Alfresco Repository AMP Module 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh-repo (default-cli) @ repo-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Repository [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 3.854 s [INFO] Finished at: 2015-05-11T10:20:17+01:00 [INFO] Final Memory: 15M/315M [INFO] ------------------------------------------------------------------------ [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Alfresco Share AMP Module 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh-share (default-cli) @ share-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Share [INFO] Successfull Clear Dependency Caches for Alfresco Share [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 4.173 s [INFO] Finished at: 2015-05-11T10:20:24+01:00 [INFO] Final Memory: 18M/309M [INFO] ------------------------------------------------------------------------ [INFO] Maven execution finishedAlso, note the refresh calls to the Web Applications to refresh. If you would prefer to only refresh the Share webapp (that is, share.war) have a look later on in this article for a different approach to refreshing the webapp via run configurations.
The page should now display as follows:
This is the Stylesheet for the Aikau Widget. Update the widget style as follows:
.my-template-widget { border: 2px #000000 solid; padding: 1em; width: 100px; color: white; background-color: blue; }
This is the resource file for the the Aikau Widget. Update the properties as follows:
hello-label=Hello from i18n UPDATED! hello-test=Going to use this label too now!
This is the HTML template file for the the Aikau Widget. Update so it looks as follows:
<div class="my-template-widget">${greeting} and ${greeting2}</div>
This is the main JavaScript implementation for the Aikau Widget. Update so it also sets the new property used in template:
define(["dojo/_base/declare", "dijit/_WidgetBase", "alfresco/core/Core", "dijit/_TemplatedMixin", "dojo/text!./templates/TemplateWidget.html" ], function(declare, _Widget, Core, _Templated, template) { return declare([_Widget, Core, _Templated], { templateString: template, i18nRequirements: [ {i18nFile: "./i18n/TemplateWidget.properties"} ], cssRequirements: [{cssFile:"./css/TemplateWidget.css"}], buildRendering: function example_widgets_TemplateWidget__buildRendering() { this.greeting = this.message('hello-label'); this.greeting2 = this.message('hello-test'); this.inherited(arguments); } }); });
The page should now display as follows:
Enabling RAD in IDEA with run configurations.
In this article we have seen how we can achieve Rapid Application Development within IDEA by executing alfresco maven plugin refresh goals after a Make. This is an easy way to configure RAD in IDEA when you are only working with 1 or 2 AMPs. However, when you start to get a number of AMPs that you are working on simultaneously, then there will be a lot of refresh calls going on as every AMP's alfresco plugin goal config will be executed. This could be seen in the tutorials above where the refresh-share and refresh-repo goals were always executed even if we were just working with one of the associated AMPs. In the following tutorial you will see how run configurations can be used for better control of when the refresh call is being made.
The build will run with the following result:
/usr/lib/jvm/java-8-oracle/bin/java -Xms256m -Xmx1G -javaagent:/home/martin/libs/springloaded-1.2.3.RELEASE.jar -noverify -Dmaven.home=/usr/local/apache-maven-3.2.5 .... [INFO] Scanning for projects... [INFO] [INFO] ------------------------------------------------------------------------ [INFO] Building Alfresco Repository AMP Module 1.0-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:set-version (default-set-version) @ repo-amp --- [INFO] Removed -SNAPSHOT suffix from version - 1.0 [INFO] Added timestamp to version - 1.0.1505120823 [INFO] [INFO] --- build-helper-maven-plugin:1.9.1:add-test-resource (add-env-test-properties) @ repo-amp --- [INFO] [INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ repo-amp --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory /home/martin/src/alfresco-extensions/all-in-one/repo-amp/src/main/resources [INFO] Copying 14 resources to ../repo-amp [INFO] [INFO] --- yuicompressor-maven-plugin:1.5.1:compress (compress-js) @ repo-amp --- [INFO] nothing to do, /home/martin/src/alfresco-extensions/all-in-one/repo-amp/target/classes/../repo-amp/web/scripts/demoamp-min.js is younger than original, use 'force' option or clean your target [INFO] nb warnings: 0, nb errors: 0 [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh (refresh-webscripts-repo-and-share) @ repo-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Repository [INFO] [INFO] --- maven-compiler-plugin:3.2:compile (default-compile) @ repo-amp --- [INFO] Nothing to compile - all classes are up to date [INFO] [INFO] --- alfresco-maven-plugin:2.1.0-SNAPSHOT:refresh-repo (default-cli) @ repo-amp --- [INFO] Successfull Refresh Web Scripts for Alfresco Repository [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ [INFO] Total time: 6.389 s [INFO] Finished at: 2015-05-12T08:23:57+01:00 [INFO] Final Memory: 30M/490M [INFO] ------------------------------------------------------------------------
Start the AIO project in debug mode.
$ mvnDebug clean install -Prun Preparing to Execute Maven in Debug Mode Listening for transport dt_socket at address: 8000 ...The Maven project will start and listen for a remote debugger on port 8000.
Connect to the running application process from Eclipse
You should now see the process stopping in the debugger as follows:
Execute the following command to copy the keystore into the runner project:
{ALFRESCO_INSTALL_DIR}/alf_data$ cp -R keystore/ {AIO_PARENT_DIR}/runner/We can now configure the embedded Tomcat instace to use this keystore.
Execute the following command to copy the tomcat users file into the runner project:
{AIO_PARENT_DIR}/runner/tomcat$ mkdir conf {ALFRESCO_INSTALL_DIR}/tomcat/conf$ cp tomcat-users.xml {AIO_PARENT_DIR}/runner/tomcat/conf/What we do here is first create a directory to hold the tomcat users file. And then we copy the tomcat users file from the Alfresco installation to this new directory in the runner project. This file contains identities for the Repository and Solr applications when setting up SSL connections.
Open up the alfresco-global.properties file located in the {AIO_PARENT_DIR}/repo/src/main/properties/local directory. Then update the section about Solr configuration:
index.subsystem.name=solr4 dir.keystore={AIO_PARENT_DIR}/runner/keystore solr.host=localhost solr.port=8080 solr.port.ssl=8443 #solr.secureComms=noneNote. You have to change {AIO_PARENT_DIR} to whatever the parent directory is for your AIO project.
Open up the pom.xml file located in the {AIO_PARENT_DIR}/runner directory. Then update the plugin configuration as follows:
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <executions> <execution> <id>run-wars</id> <goals> <goal>run</goal> </goals> <phase>pre-integration-test</phase> </execution> </executions> <configuration> <httpsPort>8443</httpsPort> <keystoreFile>${project.basedir}/keystore/ssl.keystore</keystoreFile> <keystorePass>kT9X6oe68t</keystorePass> <keystoreType>JCEKS</keystoreType> <truststoreFile>${project.basedir}/keystore/ssl.truststore</truststoreFile> <truststorePass>kT9X6oe68t</truststorePass> <truststoreType>JCEKS</truststoreType> <tomcatUsers>${project.basedir}/tomcat/conf/tomcat-users.xml</tomcatUsers>
Open up the pom.xml file located in the {AIO_PARENT_DIR}/solr-config directory. Then update the dependency and plugin configuration as follows:
<dependencies> <dependency> <groupId>org.alfresco</groupId> <artifactId>alfresco-solr4</artifactId> <version>${alfresco.version}</version> <classifier>config-ssl</classifier> <type>zip</type> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-dependency-plugin</artifactId> <executions> <execution> <id>unpack-alfresco-config</id> <goals> <goal>unpack</goal> </goals> <phase>generate-resources</phase> <configuration> <outputDirectory>${alfresco.solr.home.dir}</outputDirectory> <artifactItems> <artifactItem> <groupId>org.alfresco</groupId> <artifactId>alfresco-solr4</artifactId> <version>${alfresco.version}</version> <classifier>config-ssl</classifier> <type>zip</type> </artifactItem> </artifactItems>This Solr4 configuration comes preconfigured with SSL enabled, keystore and truststore, including the keystores themselves.
{AIO_PARENT_DIR}/alf_data_dev/solr4$ rm -rf config/This is so the new SSL enabled configuration is downloaded and installed correctly under alf_data_dev.
Open up the pom.xml file located in the {AIO_PARENT_DIR}/repo directory. Then update the maven-war-plugin configuration as follows:
<plugin> <artifactId>maven-war-plugin</artifactId> <executions> <execution> <id>prepare-exploded-war</id> <goals> <goal>exploded</goal> </goals> <phase>prepare-package</phase> </execution> <execution> <id>default-war</id> <!-- <configuration> <webXml>${project.build.directory}/${project.build.finalName}-nossl/WEB-INF/web.xml</webXml> </configuration>--> </execution> </executions>What we do here is just commenting out the web.xml file that we normally use when we don't want to use SSL.
You should see something like this in the logs:
{AIO_PARENT_DIR}$ mvn clean install -Prun ... Jun 05, 2015 10:56:33 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8080"] Jun 05, 2015 10:56:33 AM org.apache.coyote.AbstractProtocol start INFO: Starting ProtocolHandler ["http-bio-8443"]Try accessing Share securely: https://localhost:8443/share. Make sure search works by adding a text file with a unique word, then search for it. Then access Solr4 securely: https://localhost:8443/solr4.
Sometimes when you are developing a Repository AMP you need to include external libraries (JARs) that are not part/are not available in the tomcat/webapps/alfresco/WEBÂINF/lib​directory. Being able to do this is one of the benefits of AMPs compared to other extension models. The Repository AMP might also start to grow to a size where it would make sense to move some of the functionality over to separate JAR projects, and have the AMP depend on them. This article goes through how to do these things.
Adding an external JAR to a Repository AMP project.
In the following example we will update the Hello World Web Script code (it is part of the Repository AMP source code) so that it can send emails. However, when we select a Mail library to use for this, we forget to check if the library is already available as part of the Alfresco Repository WAR. We will see what happens then and how to fix it:
We know that the Java Mail library can be used for this, so we look up the maven dependency for it and add it to the componentX-repo/pom.xml:
... <dependencies> <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-repository</artifactId> </dependency> <!-- Added a new dependency for Java Mail --> <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> <version>1.5.3</version> </dependency> </dependencies> ...We can now start implementing some code that uses the Java Mail library.
The implementation can be done as follows in the Java controller (componentX-repo/src/main/java/com/acme/componentX/demoamp/HelloWorldWebScript.java):
import javax.mail.*; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeBodyPart; import javax.mail.internet.MimeMessage; import javax.mail.internet.MimeMultipart; import java.util.HashMap; import java.util.Map; import java.util.Properties; /** * A demonstration Java controller for the Hello World Web Script. * * @author martin.bergljung@alfresco.com * @since 2.1.0 */ public class HelloWorldWebScript extends DeclarativeWebScript { protected Map<String, Object> executeImpl( WebScriptRequest req, Status status, Cache cache) { Map<String, Object> model = new HashMap<String, Object>(); model.put("fromJava", "HelloFromJava"); sendEmail(); return model; } private void sendEmail() { String to = "somebody@example.com"; String subject = "Test email from Web Script"; String body = "Hello World!"; try { // Create mail session Properties props = new Properties(); props.put("mail.smtp.host", "<yourhost>"); // localhost will not work props.put("mail.smtp.port", "2525"); // non-privileged port Session session = Session.getDefaultInstance(props, null); session.setDebug(false); // Define message Message message = new MimeMessage(session); String fromAddress = "no-reply@alfresco.com"; message.setFrom(new InternetAddress(fromAddress)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject(subject); // Create the message part with body text BodyPart messageBodyPart = new MimeBodyPart(); messageBodyPart.setText(body); Multipart multipart = new MimeMultipart(); multipart.addBodyPart(messageBodyPart); // Put parts in message message.setContent(multipart); // Send the message Transport.send(message); } catch (MessagingException me) { me.printStackTrace(); } } }For the code to work you will need to update <yourhost> to whatever hostname your machine has. The code uses standard Java Mail classes to send a simple email without attachments.
Standing in the Repo AMP project directory, type the following Maven command:
componentX-repo$ mvn clean install -DskipTests=trueWhat we end up with now is a Repository AMP with the following JARs:
Open up the componentX-repo/pom.xml and update the Java Mail dependency as follows:
... <dependencies> <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-repository</artifactId> </dependency> <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> <version>1.5.3</version> <scope>provided</scope> </dependency> ... </dependencies>This will mean that the Java Mail JAR is not included in the AMP but we can still compile and build against it, which is what we want.
So to summarize, if the JAR is not in tomcat/webapps/alfresco/WEB-INF/lib, then do not use provided scope as you want it included with the AMP. On the other hand, if the JAR is available, then use provided scope to exclude it from the AMP deliverable.
Adding an internal JAR to a Repository AMP project.
To achieve what we want, we will have to turn the Repository AMP project into a multi-module project, and for this we need a parent project. Create a new directory called componentX-parent and then copy the Repository AMP directory into it:
componentX-repo$ cd .. ~/src/$ mkdir componentX-parent ~/src/$ mv componentX-repo/ componentX-parent/
Add the following pom.xml to the componentX-parent directory:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.acme</groupId> <artifactId>componentX-parent</artifactId> <version>1.0-SNAPSHOT</version> <name>componentX-repo Repository AMP parent</name> <description>This is the parent project for the multi-module componentX-repo Repository AMP project</description> <packaging>pom</packaging> <parent> <groupId>org.alfresco.maven</groupId> <artifactId>alfresco-sdk-parent</artifactId> <version>2.1.0</version> </parent> <modules> <module>componentX-repo</module> </modules> </project>Note how this parent project now has the SDK Project as a parent. And it includes the Repository AMP project as a sub-module. The parent project packaging is pom, which means it is not producing an artefact like a JAR, AMP, or WAR, it just acts as a parent for other sub-modules.
Open up the componentX-parent/componentX-repo/pom.xml file. Then update the parent definition as follows:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>componentX-repo</artifactId> <name>componentX-repo Repository AMP project</name> <packaging>amp</packaging> <description>Manages the lifecycle of the componentX-repo Repository AMP (Alfresco Module Package)</description> <parent> <groupId>com.acme</groupId> <artifactId>componentX-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> ...Note the parent section and how it now points to our new parent. Also, we have removed the version and groupId properties from the AMP project as they are inherited from the parent project.
You should see something like this in the logs:
componentX-parent$ mvn clean install -DskipTests=true . . . [INFO] Reactor Summary: [INFO] [INFO] componentX-repo Repository AMP parent .............. SUCCESS [ 0.607 s] [INFO] componentX-repo Repository AMP project ............. SUCCESS [ 6.850 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSSo we now got a parent project that can contain more sub-projects then just the Repository AMP project.
We are going to create a new JAR sub-project and then move the Hello World Web Script code over to it from the AMP. Let’s start by adding a new JAR project. Stand in the parent directory and issue the following command, which will generate a starting point for a JAR module:
componentX-parent$ mvn archetype:generate -DgroupId=com.acme -DartifactId=componentX-web-script -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=falseWe are using the Maven Quickstart archetype to generate the JAR module. Our parent directory now looks like this:
componentX-parent$ ls -l total 16 drwxrwxr-x 6 martin martin 4096 Jun 5 15:27 componentX-repo drwxrwxr-x 3 martin martin 4096 Jun 5 15:35 componentX-web-script -rw-rw-r-- 1 martin martin 881 Jun 5 15:35 pom.xmlWhen we generate a new module from the parent directory it is automatically added to the modules section of the parent POM as follows:
... <modules> <module>componentX-repo</module> <module>componentX-web-script</module> </modules> </project>And the parent section is setup correctly also in the new JAR module, open up componentX-parent/componentX-web-script/pom.xml and have a look:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.acme</groupId> <artifactId>componentX-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>componentX-web-script</artifactId> <name>componentX-web-script JAR project</name> <url>http://maven.apache.org</url> ...You might notice that I have removed the version and groupId properties from the JAR project as they are inherited from our parent project. I also updated the name so it is easy to see what type of artefact that is produced.
You should see something like this in the logs:
componentX-parent$ mvn clean install -DskipTests=true . . . [INFO] Reactor Summary: [INFO] [INFO] componentX-repo Repository AMP parent .............. SUCCESS [ 0.685 s] [INFO] componentX-repo Repository AMP project ............. SUCCESS [ 7.131 s] [INFO] componentX-web-script JAR project .................. SUCCESS [ 0.539 s] [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS
Here we are doing this via command line:
componentX-parent$ cd componentX-web-script/ componentX-parent/componentX-web-script$ cd src/main/java/com/acme/ componentX-parent/componentX-web-script/src/main/java/com/acme$ mkdir componentX componentX-parent/componentX-web-script/src/main/java/com/acme$ cd componentX/ componentX-parent/componentX-web-script/src/main/java/com/acme/componentX$ mkdir demoamp componentX-parent/componentX-web-script/src/main/java/com/acme/componentX$ cd demoamp/ componentX-parent/componentX-web-script/src/main/java/com/acme/componentX/demoamp$ mv ~/src/componentX-parent/componentX-repo/src/main/java/com/acme/componentX/demoamp/HelloWorldWebScript.java . componentX-parent/componentX-web-script/src/main/java/com/acme/componentX/demoamp$ cd ../../../../../ componentX-parent/componentX-web-script/src/main$ mkdir resources componentX-parent/componentX-web-script/src/main$ cd resources/ componentX-parent/componentX-web-script/src/main/resources$ mkdir alfresco componentX-parent/componentX-web-script/src/main/resources$ cd alfresco/ componentX-parent/componentX-web-script/src/main/resources/alfresco$ mkdir extension componentX-parent/componentX-web-script/src/main/resources/alfresco$ cd extension/ componentX-parent/componentX-web-script/src/main/resources/alfresco/extension$ mkdir templates componentX-parent/componentX-web-script/src/main/resources/alfresco/extension$ cd templates/ componentX-parent/componentX-web-script/src/main/resources/alfresco/extension/templates$ mkdir webscripts componentX-parent/componentX-web-script/src/main/resources/alfresco/extension/templates$ cd webscripts/ componentX-parent/componentX-web-script/src/main/resources/alfresco/extension/templates/webscripts$ mv ~/src/componentX-parent/componentX-repo/src/main/amp/config/alfresco/extension/templates/webscripts/* .If you have followed along, then you should see something like this in your IDE now:
Open up the componentX-parent/componentX-web-script/pom.xml file and update it so it looks like this:
<?xml version="1.0"?> <project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <modelVersion>4.0.0</modelVersion> <parent> <groupId>com.acme</groupId> <artifactId>componentX-parent</artifactId> <version>1.0-SNAPSHOT</version> </parent> <artifactId>componentX-web-script</artifactId> <name>componentX-web-script JAR project</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-repository</artifactId> </dependency> <dependency> <groupId>com.sun.mail</groupId> <artifactId>javax.mail</artifactId> <version>1.5.3</version> <scope>provided</scope> </dependency> </dependencies> </project>We also needed to add the alfresco-repository dependency as the Java Web Script controller uses Declarative Web Script classes. It does not have version specified as part of dependency definition, so we need to make sure it works anyway.
Open up the componentX-parent/pom.xml file and update it so it looks like this:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.acme</groupId> <artifactId>componentX-parent</artifactId> <version>1.0-SNAPSHOT</version> <name>componentX-repo Repository AMP parent</name> <description>This is the parent project for the multi-module componentX-repo Repository AMP project</description> <packaging>pom</packaging> <parent> <groupId>org.alfresco.maven</groupId> <artifactId>alfresco-sdk-parent</artifactId> <version>2.1.0</version> </parent> <modules> <module>componentX-repo</module> <module>componentX-web-script</module> </modules> <dependencyManagement> <dependencies> <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-platform-distribution</artifactId> <version>${alfresco.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> </project>It’s a good idea to move the Dependency Management section to the parent POM as you might have more JAR extensions added that needs Alfresco libraries, and then you want to be consitent with what version of these libraries you are using. The Repository AMP POM now looks like this (i.e. componentX-parent/componentX-repo/pom.xml) after removing the Java Mail dependency, moving Dependency Management, and putting in the Web Script JAR dependency:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.acme</groupId> <artifactId>componentX-parent</artifactId> <version>1.0-SNAPSHOT</version> <name>componentX-repo Repository AMP parent</name> <description>This is the parent project for the multi-module componentX-repo Repository AMP project</description> <packaging>pom</packaging> <parent> <groupId>org.alfresco.maven</groupId> <artifactId>alfresco-sdk-parent</artifactId> <version>2.1.0</version> </parent> <modules> <module>componentX-repo</module> <module>componentX-web-script</module> </modules> <dependencyManagement> <dependencies> <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-platform-distribution</artifactId> <version>${alfresco.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> </project>We are now ready to build the project again.
You should see something like this in the logs:
componentX-parent$ mvn clean install -DskipTests=true [INFO] Reactor Summary: [INFO] [INFO] componentX-repo Repository AMP parent .............. SUCCESS [ 0.556 s] [INFO] componentX-web-script JAR project .................. SUCCESS [ 2.662 s] [INFO] componentX-repo Repository AMP project ............. SUCCESS [ 4.688 s]The Repository AMP now contains the following libraries:
To make sure this really works we need to try out the Web Script. Step into the AMP directory and do run.sh:
componentX-parent$ cd componentX-repo/ componentX-parent/componentX-repo$ chmod +x run.sh componentX-parent/componentX-repo$ ./run.shYou can test the Web Script as follows from a web browser:
2015-06-05 16:43:00,105 INFO [alfresco.util.OpenOfficeConnectionTester] [DefaultScheduler_Worker-1] The OpenOffice connection was re-established. com.sun.mail.util.MailConnectException: Couldn't connect to host, port: brutor, 2525; timeout -1; nested exception is: java.net.ConnectException: Connection timed out
Linking the RM repository AMP to the alfresco.war.
In the IDE, open up the alfresco-extensions/acme-cms-poc/repo/pom.xml. Scroll down so you see the dependencies section:
The RM repository AMP will not be automatically added to the alfresco.war by just adding the dependency. We need to add some configuration to the war plugin. Scroll further down in the alfresco-extensions/acme-cms-poc/repo/pom.xml file until you see the maven-war-plugin section:
Linking the RM Share AMP to the share.war.
In the IDE, open up the alfresco-extensions/acme-cms-poc/share/pom.xml. Scroll down so you see the dependencies section:
The RM Share AMP will not be automatically added to the share.war by just adding the dependency. We need to add some configuration to the war plugin. Scroll further down in the alfresco-extensions/acme-cms-poc/share/pom.xml file until you see the maven-war-plugin section:
Verify that the AIO project has been configured with the RM module.
Use the acme-cms-poc/run.sh script to run Alfresco Tomcat with the customized WARs.
2015-05-07 10:30:17,004 INFO [repo.module.ModuleServiceImpl] [localhost-startStop-1] Found 2 module(s). 2015-05-07 10:30:17,082 INFO [repo.module.ModuleServiceImpl] [localhost-startStop-1] Installing module 'org_alfresco_module_rm' version 2.3. 2015-05-07 10:30:18,560 INFO [repo.module.ModuleServiceImpl] [localhost-startStop-1] Upgrading module 'repo-amp' version 1.0.1505071028 (was 1.0.1505070918). .... INFO: Starting ProtocolHandler ["http-bio-8080"]
Login to Share via http://localhost:8080/share and then create a new site. When you create the site select Records Management Site from the Type drop down. If this type is not available then something is not configured correctly, go back and verify that you have followed all the steps correctly.
The are many benefits to this:
Generating a new custom Repository AMP and linking it to the Alfresco.war.
Follow instructions in the create Respository extension project (AMP) [58] section. Give the new Repo AMP a unique artifact id that does not clash with any other ids or the one that is part of the AIO project (i.e. repo-amp). For this example I have used the id component-a-repo. Use the same group id as for the rest of your project artifacts, I'm using com.acme. The AMP is stored in the alfresco-extensions/component-a-repo folder and is not part of the AIO build.
It is best to avoid SNAPSHOTS when this AMP is included in the All-in-One project. So, use the maven-release-plugin and release and tag the AMP so it is ready to be include in the main AIO project.
In the IDE, open up the alfresco-extensions/acme-cms-poc/repo/pom.xml project file. Scroll down so you see the dependencies section. Then add a dependency to component-a-repo:
The Repository AMP will not be automatically added to the alfresco.war by just adding the dependency. We need to add some configuration to the war plugin. Scroll further down in the alfresco-extensions/acme-cms-poc/repo/pom.xml file until you see the maven-war-plugin section. Then add a overlay for the component-a-repo:
... 2015-05-07 14:18:44,770 INFO [repo.module.ModuleServiceImpl] [localhost-startStop-1] Found 2 module(s). 2015-05-07 14:18:44,791 INFO [repo.module.ModuleServiceImpl] [localhost-startStop-1] Installing module 'component-a-repo' version 1.0.0. 2015-05-07 14:18:44,808 INFO [repo.module.ModuleServiceImpl] [localhost-startStop-1] Installing module 'repo-amp' version 1.0.1505071417. ....
Generating a new custom Share AMP and adding it to the Share.war.
Follow instructions in the create Share extension project (AMP) [76] section. Give the new Share AMP a unique artifact id that does not clash with any other ids or the one that is part of the AIO project (i.e. share-amp). For this example I have used the id component-a-share. Use the same group id as for the rest of your project artifacts, I'm using com.acme. The AMP is stored in the alfresco-extensions/component-a-share folder and is not part of the AIO build.
It is best to avoid SNAPSHOTS when this AMP is included in the All-in-One project. So, use the maven-release-plugin and release and tag the AMP so it is ready to be include in the main AIO project.
In the IDE, open up the alfresco-extensions/acme-cms-poc/share/pom.xml project file. Scroll down so you see the dependencies section. Then add a dependency to component-a-share:
The Share AMP will not be automatically added to the share.war by just adding the dependency. We need to add some configuration to the war plugin. Scroll further down in the alfresco-extensions/acme-cms-poc/share/pom.xml file until you see the maven-war-plugin section. Then add a overlay for the component-a-share:
Generating a new custom Repository AMP and linking it to the Alfresco.war.
Follow instructions in the create Respository extension project (AMP) [58] section. Give the new Repo AMP a unique artifact id that does not clash with any other ids or the one that is part of the AIO project (i.e. repo-amp). For this example I have used the id component-a-repo. Use the same group id as for the rest of your project artifacts, I'm using com.acme. The AMP is generated and stored in the alfresco-extensions/acme-cms-poc/component-a-repo folder and is going to be part of the AIO multi module project.
By default the Repository AMP will be generated with the SDK Parent set. We need to change it to be the AIO project parent instead. You can grab a parent defintion from one of the other sub-projects, such as the repo-amp project. The alfresco-extensions/acme-cms-poc/component-a-repo/pom.xml file should now start like this:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>component-a-repo</artifactId> <name>component-a-repo Repository AMP project</name> <packaging>amp</packaging> <description>Manages the lifecycle of the component-a-repo Repository AMP (Alfresco Module Package)</description> <parent> <groupId>com.acme</groupId> <artifactId>acme-cms-poc</artifactId> <version>1.0-SNAPSHOT</version> </parent> ...You should also remove <groupId> and <version> as these values will be picked up from the AIO parent.
This should happen automatically when you generate the new project in a sub-directory to the parent AIO project directory. Open up the alfresco-extensions/acme-cms-poc/pom.xml file and verify that the component-a-repo module is there:
... <modules> <module>repo-amp</module> <module>share-amp</module> <module>repo</module> <module>solr-config</module> <module>share</module> <module>runner</module> <module>component-a-repo</module> </modules> </project>
In the IDE, open up the alfresco-extensions/acme-cms-poc/repo/pom.xml project file. Scroll down so you see the dependencies section. Then add a dependency to component-a-repo:
The Repository AMP will not be automatically added to the alfresco.war by just adding the dependency. We need to add some configuration to the war plugin. Scroll further down in the alfresco-extensions/acme-cms-poc/repo/pom.xml file until you see the maven-war-plugin section. Then add a overlay for the component-a-repo:
To be able to have hot-reloading work for the code that is going to be part of the new component-a-repo AMP, we need to update the virtual webapp context for the Repository webapp (i.e. for the alfresco.war webapp). In the IDE, open up the alfresco-extensions/acme-cms-poc/runner/tomcat/context-repo.xml file. Update the Resource section configuration with the new AMP's resource path:
<!-- IMPORTANT! The extraResourcePaths string need to be on one continues line --> <Resources className="org.apache.naming.resources.VirtualDirContext" extraResourcePaths="/=${project.parent.basedir}/repo-amp/target/repo-amp/web,/=${project.parent.basedir}/component-a-repo/target/component-a-repo/web" />And update the Loader section configuration with the new AMP's classpaths:
<Loader className="org.apache.catalina.loader.VirtualWebappLoader" searchVirtualFirst="true" virtualClasspath="${project.parent.basedir}/repo-amp/target/classes; ${project.parent.basedir}/repo-amp/target/repo-amp/config; ${project.parent.basedir}/repo-amp/target/test-classes; ${project.parent.basedir}/component-a-repo/target/classes; ${project.parent.basedir}/component-a-repo/target/component-a-repo/config; ${project.parent.basedir}/component-a-repo/target/test-classes" />
... 2015-05-08 13:40:37,688 INFO [repo.module.ModuleServiceImpl] [localhost-startStop-1] Found 2 module(s). 2015-05-08 13:40:37,713 INFO [repo.module.ModuleServiceImpl] [localhost-startStop-1] Upgrading module 'component-a-repo' version 1.0.1505081338 (was 1.0.1505071304). 2015-05-08 13:40:37,746 INFO [repo.module.ModuleServiceImpl] [localhost-startStop-1] Upgrading module 'repo-amp' version 1.0.1505081338 (was 1.0.1505081106). ...
Generating a new custom Share AMP and and linking it to the Share.war.
Follow instructions in the create Share extension project (AMP) [76] section. Give the new Share AMP a unique artifact id that does not clash with any other ids or the one that is part of the AIO project (i.e. share-amp). For this example I have used the id component-a-share. Use the same group id as for the rest of your project artifacts, I'm using com.acme. The AMP is generated and stored in the alfresco-extensions/acme-cms-poc/component-a-share folder and is going to be part of the AIO multi module project.
By default the Share AMP will be generated with the SDK Parent set. We need to change it to be the AIO project parent instead. You can grab a parent defintion from one of the other sub-projects, such as the share-amp project. The alfresco-extensions/acme-cms-poc/component-a-share/pom.xml file should now start like this:
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <artifactId>component-a-share</artifactId> <name>component-a-share AMP project</name> <packaging>amp</packaging> <description>Manages the lifecycle of the component-a-share AMP (Alfresco Module Package)</description> <parent> <groupId>com.acme</groupId> <artifactId>acme-cms-poc</artifactId> <version>1.0-SNAPSHOT</version> </parent> ...You should also remove <groupId> and <version> as these values will be picked up from the AIO parent.
This should happen automatically when you generate the new project in a sub-directory to the parent AIO project directory. Open up the alfresco-extensions/acme-cms-poc/pom.xml file and verify that the component-a-share module is there:
... <modules> <module>repo-amp</module> <module>share-amp</module> <module>repo</module> <module>solr-config</module> <module>share</module> <module>runner</module> <module>component-a-repo</module> <module>component-a-share</module> </modules> </project>
In the IDE, open up the alfresco-extensions/acme-cms-poc/share/pom.xml project file. Scroll down so you see the dependencies section. Then add a dependency to component-a-share:
The Share AMP will not be automatically added to the share.war by just adding the dependency. We need to add some configuration to the war plugin. Scroll further down in the alfresco-extensions/acme-cms-poc/share/pom.xml file until you see the maven-war-plugin section. Then add a overlay for the component-a-share:
To be able to have hot-reloading work for the code that is going to be part of the new component-a-share AMP, we need to update the virtual webapp context for the Share webapp (i.e. for the share.war webapp). Also, if we don't do this any web resources such as CSS, Images, JS etc located under /web in the AMP will not be available when we use the run profile (this is because during hot reloading we only want them in one place, our project). In the IDE, open up the alfresco-extensions/acme-cms-poc/runner/tomcat/context-share.xml file. Update the Resource section configuration with the new AMP's resource path:
<!-- IMPORTANT! The extraResourcePaths string need to be on one continues line --> <Resources className="org.apache.naming.resources.VirtualDirContext" extraResourcePaths="/=${project.parent.basedir}/share-amp/target/share-amp/web,/=${project.parent.basedir}/component-a-share/target/component-a-share/web" />And update the Loader section configuration with the new AMP's classpaths:
<Loader className="org.apache.catalina.loader.VirtualWebappLoader" searchVirtualFirst="true" virtualClasspath="${project.parent.basedir}/share-amp/target/classes; ${project.parent.basedir}/share-amp/target/share-amp/config; ${project.parent.basedir}/share-amp/target/test-classes; ${project.parent.basedir}/component-a-share/target/classes; ${project.parent.basedir}/component-a-share/target/component-a-share/config; ${project.parent.basedir}/component-a-share/target/test-classes; ${project.parent.basedir}/share/target/test-classes" />
Upgrading Alfresco version for a Repository AMP project.
In the IDE, open up the Repository AMP project that you are working on. Then open the project file for it, for example alfresco-extensions/component-a-repo/pom.xml. Scroll down so you see the properties section:
<properties> <!-- The following are default values for data location and Alfresco Community version. Uncomment if you need to change (Note. current default version for Enterprise edition is 5.0.1) --> <alfresco.version>5.0.e</alfresco.version> <!--<alfresco.data.location>alf_data_dev</alfresco.data.location> -->What you need to do here is uncomment the alfresco.version property, and then update the version to desired latest version. In this case we are upgrading to a newer Community Edition (default is 5.0.d). It would be the same procedure to upgrade to a newer Enterprise version.
After setting a newer Alfresco version you will need to clean out current database (with metadata), content files, and indexes. It currently does not work to do an incremental upgrade with the SDK and the H2 database. You can clean the DB and conten files by running the following command: alfresco-extensions/component-a-repo/mvn clean -Ppurge
Upgrading Alfresco version for a Share AMP project.
In the IDE, open up the Share AMP project that you are working on. Then open the project file for it, for example alfresco-extensions/component-a-share/pom.xml. Scroll down so you see the properties section:
<properties> <!-- The following are default values for data location and Alfresco version. Uncomment if you need to change--> <alfresco.version>5.0.e</alfresco.version> ...What you need to do here is uncomment the alfresco.version property, and then update the version to desired latest version. In this case we are upgrading to a newer Community Edition (default is 5.0.d). It would be the same procedure to upgrade to a newer Enterprise version.
When upgrading the Alfresco Share AMP it is not necessary to clean out a database or clean content because these are related to the Alfresco Repository application (alfresco.war) and not the Share Application (share.war).
Upgrading Alfresco version for an All-in-One (AIO) project.
In the IDE, open up the All-in-One project that you are working on. Then open the project file for it, for example alfresco-extensions/all-in-one/pom.xml. Scroll down so you see the properties section:
<properties> <!-- The following are default values for data location, Alfresco Community version, and Records Management Module version. Uncomment if you need to change (Note. current default version for Enterprise edition is 5.0.1) --> <alfresco.version>5.0.e</alfresco.version> <alfresco.rm.version>2.3.b</alfresco.rm.version>What you need to do here is uncomment the alfresco.version property, and then update the version to desired latest version. In this case we are upgrading to a newer Community edition (default is 5.0.d). It would be the same procedure to upgrade to a newer Enterprise edition. Note also that in this case I'm using the Records Management module and I am updating the version for it at the same time by uncommenting the alfresco.rm.version property and setting new version.
After setting a newer Alfresco version you will need to clean out current database (with metadata), content files, and indexes. It currently does not work to do an incremental upgrade with the SDK and the H2 database. You can clean the DB and conten files by running the following command: alfresco-extensions/component-a-repo/mvn clean -Ppurge
These instructions include information about how to upgrade projects generated from each one of the artifacts. Make sure you are following upgrade instructions for the correct project type and "From version -> To version".
A 3 digit versioning scheme is used, major.minor.patch (e.g. 2.1.0). The following is a list of changes that can go into each one of these releases:
Note that in addition to this there can be beta releases to give early access to features.
These instructions include information about how to upgrade projects generated from each one of the Maven artifacts. Make sure you are following upgrade instructions for the correct project type.
In the IDE, open up the {REPO_AMP_PROJECT_PATH}/pom.xml project file. Scroll down so you see the parent section. Then update it to look as follows:
<parent> <groupId>org.alfresco.maven</groupId> <artifactId>alfresco-sdk-parent</artifactId> <version>2.1.0</version> </parent>
In the project file {REPO_AMP_PROJECT_PATH}/pom.xml scroll down to the properties section. Then remove the property called alfresco.client.contextPath. This property is already set to /alfresco in the SDK parent POM so no need to set it here.
In the IDE, open up the {REPO_AMP_PROJECT_PATH}/pom.xml project file. Scroll down so you see the profiles section. Then add the following profile to it:
<!-- If the 'amp-to-war' profile is enabled then make sure to bring in the alfresco-rad module, which has the H2 scripts and other RAD features. --> <profile> <id>amp-to-war</id> <dependencies> <dependency> <groupId>org.alfresco.maven</groupId> <artifactId>alfresco-rad</artifactId> <version>${maven.alfresco.version}</version> </dependency> </dependencies> </profile>
Open the {REPO_AMP_PROJECT_PATH}/tomcat/context.xml file. Change it to look like this for best RAD experience:
<?xml version="1.0" encoding="UTF-8"?> <!-- =================================================================================================================== This context file is used only in a development IDE for rapid development, it is never released with the Alfresco.war =================================================================================================================--> <!-- Setup docBase to something like repo-amp/target/repo-amp-war and path to /alfresco The Alfresco.war 5.0 does not have a webapp (it used to have Alfresco Explorer but not anymore) that we will access, so this docBase might not be needed --> <Context docBase="${app.amp.client.war.folder}" path="${alfresco.client.contextPath}"> <Resources className="org.apache.naming.resources.VirtualDirContext" extraResourcePaths="/=${project.build.directory}/${project.build.finalName}/web" /> <!-- Setup the virtual class path like this: 1) target/classes 2) target/${project.build.finalName}/config 3) target/test-classes This way mvn compile can be invoked and all changes will be picked up --> <Loader searchVirtualFirst="true" className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="${project.build.outputDirectory};${project.build.directory}/${project.build.finalName}/config;${project.build.testOutputDirectory}" /> <!-- This enables hot reloading of web resources from uncompressed jars (while in prod they would be loaded from WEB-INF/lib/{\*.jar}/META-INF/resources --> <JarScanner scanAllDirectories="true" /> </Context>
Version 2.1.0 of the SDK have changes to the Linux run scripts and have new run scripts for Windows. So it make sense to take the new scripts from a newly generated 2.1.0 Repository AMP project and replace the 2.0.0 scripts with them. So follow these instructions [58] to generate a Repository AMP project based on the 2.1.0 archetype. Then just copy over the {newly generated 2.1.0 Repo AMP}/run.* scripts to the {REPO_AMP_PROJECT_PATH} directory, overwriting the run.sh script.
In the IDE, open up the {SHARE_AMP_PROJECT_PATH}/pom.xml project file. Scroll down so you see the parent section. Then update it to look as follows:
<parent> <groupId>org.alfresco.maven</groupId> <artifactId>alfresco-sdk-parent</artifactId> <version>2.1.0</version> </parent>
In the project file {SHARE_AMP_PROJECT_PATH}/pom.xml scroll down to the properties section. Then remove the property called alfresco.client.contextPath. This property is now called share.client.contextPath, and it is already set to /share in the SDK parent POM, so no need to set it here.
In the project file {SHARE_AMP_PROJECT_PATH}/pom.xml scroll down to the properties section. Then change the name of the property called alfresco.client.war to app.amp.client.war.artifactId.
In the same project file {SHARE_AMP_PROJECT_PATH}/pom.xml scroll down to the dependencies end tag. Then add the following build section after it with the yuicompressor-maven-plugin to enable JS compression:
. . . </dependencies> <build> <plugins> <!-- Compress JavaScript files and store as *-min.js --> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>yuicompressor-maven-plugin</artifactId> </plugin> </plugins> </build>
Open the {SHARE_AMP_PROJECT_PATH}/src/test/resources/alfresco/web-extension/share-config-custom.xml file and update the web-framework configuration so it looks like this:
<web-framework> <autowire> <!-- Changing this to 'development' currently breaks the Admin Console. Instead we make a POST to clear Share dependency caches, see 'clear-caches-refresh-ws' profile. --> <mode>production</mode> <!-- not really need in the long run, used for YUI - deprecate --> </autowire> <!-- We don't need to do this when we have the new refresh mojos in the Alfresco plug-in. If resource caching has been disabled then all the dependency caches will be cleared before processing the Aikau jsonModel request... (i.e. this.dojoDependencyHandler.clearCaches() ) For more information see the Aikau source code: https://github.com/Alfresco/Aikau --> <disable-resource-caching>false</disable-resource-caching> </web-framework>
Open the {SHARE_AMP_PROJECT_PATH}/tomcat/context.xml file. Change it to look like this for best RAD experience:
<?xml version="1.0" encoding="UTF-8"?> <!-- =================================================================================================================== This context file is used only in a development IDE for rapid development, it is never released with the Alfresco.war =================================================================================================================--> <!-- Setup docBase to something like share-amp/target/share-amp-war and path to /share --> <Context docBase="${app.amp.client.war.folder}" path="${share.client.contextPath}"> <Resources className="org.apache.naming.resources.VirtualDirContext" extraResourcePaths="/=${project.build.directory}/${project.build.finalName}/web" /> <!-- Configure where the Share (share.war) web application can load classes, test classes, and config --> <!-- Setup the virtual class path like this: 1) target/classes 2) target/${project.build.finalName}/config 3) target/test-classes This way mvn compile can be invoked and all changes will be picked up --> <Loader searchVirtualFirst="true" className="org.apache.catalina.loader.VirtualWebappLoader" virtualClasspath="${project.build.outputDirectory};${project.build.directory}/${project.build.finalName}/config;${project.build.testOutputDirectory}" /> <!-- This enables hot reloading of web resources from uncompressed jars (while in prod they would be loaded from WEB-INF/lib/{\*.jar}/META-INF/resources --> <JarScanner scanAllDirectories="true" /> </Context>
Version 2.1.0 of the SDK have changes to the Linux run scripts and have new run scripts for Windows. So it make sense to take the new scripts from a newly generated 2.1.0 Share AMP project and replace the 2.0.0 scripts with them. So follow these instructions [76] to generate a Share AMP project based on the 2.1.0 archetype. Then just copy over the {newly generated 2.1.0 Share AMP}/run.* scripts to the {SHARE_AMP_PROJECT_PATH} directory, overwriting the run.sh script.
Update the top AIO project file.
In the IDE, open up the {AIO_PROJECT_PATH}/pom.xml project file. Scroll down so you see the parent section. Then update it to look as follows:
<parent> <groupId>org.alfresco.maven</groupId> <artifactId>alfresco-sdk-parent</artifactId> <version>2.1.0</version> </parent>
In the same project file {AIO_PROJECT_PATH}/pom.xml scroll down to the properties section. Then update it with this extra property:
<properties> . . . <!-- The Alfresco Share web application is accessible via this URL --> <share.client.url>http://localhost:8080/share</share.client.url>
If the Records Management (RM) module is used then add a property specifying the RM version that should be used. In the properties section add this extra property:
<properties> . . . <alfresco.rm.version>2.3</alfresco.rm.version>
In the same project file {AIO_PROJECT_PATH}/pom.xml scroll down to the dependencyManagement end tag. Then add the following build section after it with the yuicompressor-maven-plugin to enable JS compression and the alfresco-maven-plugin to enable webapp RAD development:
. . . </dependencyManagement> <build> <plugins> <!-- Compress JavaScript files and store as *-min.js --> <plugin> <groupId>net.alchim31.maven</groupId> <artifactId>yuicompressor-maven-plugin</artifactId> </plugin> <plugin> <groupId>org.alfresco.maven.plugin</groupId> <artifactId>alfresco-maven-plugin</artifactId> </plugin> </plugins> </build>
In the same project file {AIO_PROJECT_PATH}/pom.xml scroll down to the profiles section. Then remove the profile with the rm id (identifier). The RM module is added via the {AIO_PROJECT_PATH}/repo/pom.xml and the {AIO_PROJECT_PATH}/share/pom.xml project files. See further down in these instructions for more information.
SDK version 2.1.0 comes with support for Solr4, which is deployed directly from the maven artefact. The maven module just contains Solr 4 configuration information and because of this has changed name from solr to solr-config, so we need to update to the new name. In the same project file {AIO_PROJECT_PATH}/pom.xml scroll down to the modules section. Update it so it looks like this:
. . . <modules> <module>repo-amp</module> <module>share-amp</module> <module>repo</module> <module>solr-config</module> <module>share</module> <module>runner</module> </modules>Note. You might have added extra modules that are not part of the AIO artefact, don't remove these modules from the definition.
Update the Repository Webapp (alfresco.war) Project file
In the project file {AIO_PROJECT_PATH}/repo/pom.xml scroll down to the profiles section. Then remove the profile with the rm id (identifier). The RM module is now instead added permanently as a dependency and overlay.
If the RM module is used, then it is now added permanently to the project instead of via profile activation. Add a dependency for it as follows. In the IDE, open up the {AIO_PROJECT_PATH}/repo/pom.xml project file. Scroll down so you see the dependencies section. Then add the following dependency:
<dependencies> . . . <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-rm</artifactId> <version>${alfresco.rm.version}</version> <type>amp</type> </dependency>
If the RM module is used, then it is now added permanently to the project instead of via profile activation. Add an overlay configuration as follows. In the {AIO_PROJECT_PATH}/repo/pom.xml project file scroll down so you see the overlays section. Then add the following overlay at the end:
<overlays> . . . <overlay> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-rm</artifactId> <type>amp</type> </overlay> </overlays>
When running all the web applictions during testing the repository webapp (alfresco.war) is reading its configuration from the {AIO_PROJECT_PATH}/repo/src/main/properties/local/alfresco-global.properties file. We need to update it so it uses Solr4, the following properties should be changed:
index.subsystem.name=solr4 solr.backup.alfresco.remoteBackupLocation=${dir.root}/solr4Backup/alfresco solr.backup.archive.remoteBackupLocation=${dir.root}/solr4Backup/archive
Update the Repository AMP Project file
In the project file {AIO_PROJECT_PATH}/repo-amp/pom.xml scroll down to the properties section. Then remove the property called alfresco.client.war. This property is now called app.amp.client.war.artifactId and defaults to alfresco, so no need to set it in the repo-amp project file. This property is used when you run with the -Pamp-to-war profile.
If the RM module is used, then it is now added permanently to the project instead of via profile activation. So to get access to the RM classes add a dependency as follows. In the {AIO_PROJECT_PATH}/repo-amp/pom.xml project file scroll down so you see the dependencies section. Then add the following dependency:
<dependencies> . . . <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-rm</artifactId> <version>${alfresco.rm.version}</version> <classifier>classes</classifier> </dependency>
In the project file {AIO_PROJECT_PATH}/repo-amp/pom.xml scroll down to the profiles section. Then remove the profile with the rm id (identifier). The RM classes are now instead added permanently as a dependency.
Update the Share Webapp (share.war) Project file
In the project file {AIO_PROJECT_PATH}/share/pom.xml add the following properties section just after the parent section:
. . . </parent> <properties> <!-- Used in share-config-custom.xml when testing. By default points to standard location (local) of Alfresco Repository --> <alfresco.repo.url>http://localhost:8080/alfresco</alfresco.repo.url> </properties>
The share configuration file has moved from the share AMP sub project to the share WAR project. This is because it contains generic configuration such as where the Repository is running and RAD related configuration. Move the {AIO_PROJECT_PATH}/share-amp/src/test/resources/alfresco/web-extension/share-config-custom.xml file to the {AIO_PROJECT_PATH}/share/src/main/resources/alfresco/web-extension location. Then update the web-framework configuration so it looks like this:
<web-framework> <autowire> <!-- Changing this to 'development' currently breaks the Admin Console. Instead we make a POST to clear Share dependency caches, see 'clear-caches-refresh-ws' profile. --> <mode>production</mode> <!-- not really need in the long run, used for YUI - deprecate --> </autowire> <!-- We don't need to do this when we have the new refresh mojos in the Alfresco plug-in. If resource caching has been disabled then all the dependency caches will be cleared before processing the Aikau jsonModel request... (i.e. this.dojoDependencyHandler.clearCaches() ) For more information see the Aikau source code: https://github.com/Alfresco/Aikau --> <disable-resource-caching>false</disable-resource-caching> </web-framework>
In the project file {AIO_PROJECT_PATH}/share/pom.xml scroll down to the profiles section. Then remove the profile with the rm id (identifier). The RM module is now instead added permanently as a dependency and overlay.
If the RM module is used, then it is now added permanently to the project instead of via profile activation. Add a dependency for it as follows. In the IDE, open up the {AIO_PROJECT_PATH}/share/pom.xml project file. Scroll down so you see the dependencies section. Then add the following dependency:
<dependencies> . . . <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-rm-share</artifactId> <version>${alfresco.rm.version}</version> <type>amp</type> </dependency>
If the RM module is used, then it is now added permanently to the project instead of via profile activation. Add an overlay configuration as follows. In the {AIO_PROJECT_PATH}/share/pom.xml project file scroll down so you see the overlays section. Then add the following overlay at the end:
<overlays> . . . <overlay> <groupId>${alfresco.groupId}</groupId> <artifactId>alfresco-rm-share</artifactId> <type>amp</type> </overlay> </overlays>
Update the Share AMP Project file
In the project file {AIO_PROJECT_PATH}/share-amp/pom.xml scroll down to the properties section. Then change the name of property called alfresco.client.war to its new name app.amp.client.war.artifactId. It defaults to alfresco so we need to override it here with the value share. This property is used when you run with the -Pamp-to-war profile.
In the project file {AIO_PROJECT_PATH}/share-amp/pom.xml scroll down to the properties section. Then remove the property called alfresco.repo.url. This property is only used by the {AIO_PROJECT_PATH}/share/pom.xml project in an All-in-One extension project.
In the project file {AIO_PROJECT_PATH}/share-amp/pom.xml scroll down to the properties section. Then remove the property called maven.tomcat.port. This property is only used by the {AIO_PROJECT_PATH}/runner/pom.xml project when starting an embeeded Tomcat instance. Default port number is configured to 8080 in the parent SDK pom.
In version 2.1.0 of the SDK there are two new profiles called regression-testing and functional-testing that uses Page Objects (PO) to do functional testing of the Share Web application. We need to add all dependencies needed for these tests. In the {AIO_PROJECT_PATH}/share-amp/pom.xml project file scroll down so you see the dependencies section. Then add the following dependencies:
<dependencies> . . . <!--=============================================================== The following dependencies are needed to be able to compile the custom functional tests that are based on Page Objects (PO) ===============================================================--> <!-- Bring in the Share Page Objects (PO) used in our functional tests. It contains page objects such as LoginPage --> <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>share-po</artifactId> <version>${alfresco.version}</version> <scope>test</scope> </dependency> <!-- Bring in the Share Page Object (PO) Tests that comes with Alfresco. It has the org.alfresco.po.share.AbstractTest class that our custom tests extend. --> <dependency> <groupId>${alfresco.groupId}</groupId> <artifactId>share-po</artifactId> <version>${alfresco.version}</version> <classifier>tests</classifier> <scope>test</scope> <!-- Exclude version 2.39.0 of selenium that does not work with latest FF browsers, we include version 2.45 later on here --> <exclusions> <exclusion> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> </exclusion> <exclusion> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-server</artifactId> </exclusion> </exclusions> </dependency> <!-- Bring in newer selenium version --> <dependency> <groupId>org.seleniumhq.selenium</groupId> <artifactId>selenium-java</artifactId> <version>2.45.0-alfresco</version> </dependency> <!-- Test NG is defined with test scope in share-po, so need it here too --> <!-- Alfresco code creates a wrapper around Test NG --> <dependency> <groupId>org.alfresco.test</groupId> <artifactId>alfresco-testng</artifactId> <version>1.1</version> <scope>test</scope> <exclusions> <exclusion> <groupId>org.hamcrest</groupId> <artifactId>hamcrest-core</artifactId> </exclusion> </exclusions> </dependency> </dependencies>
Replace Modules and Scripts
The project configuration for the runner module has changed quite a bit in version 2.1.0 of the SDK. And there should not be much custom configuration done to it. So it make sense to take the runner module from a newly generated 2.1.0 AIO project and replace the 2.0.0 runner module with it. So follow these instructions [57] to generate an AIO project based on the 2.1.0 archetype. Then delete the {AIO_PROJECT_PATH}/runner module/directory from the All-in-One project. Now copy the {newly generated 2.1.0 AIO}/runner module into the {AIO_PROJECT_PATH}/runner location.
The new runner module probably does not have the same parent configuration as your {AIO_PROJECT_PATH} project. So open up the {AIO_PROJECT_PATH}/runner/pom.xml file and make sure the parent section is correct.
If you have made changes to the virtual web application context because you have added more AMPs to the AIO project, then see these instructions [84] for how to update the 2.1.0 runner context.
The project configuration for the solr module has changed completely from bringing in the complete Solr 1.4 web application to just bringing in the Solr4 configuration. So it make sense to take the solr-config module from a newly generated 2.1.0 AIO project and replace the 2.0.0 solr module with it. So follow these instructions [57] to generate an AIO project based on the 2.1.0 archetype (if you have not already done it). Then delete the {AIO_PROJECT_PATH}/solr module/directory from the All-in-One project. Now copy the {newly generated 2.1.0 AIO}/solr-config module into the {AIO_PROJECT_PATH}/solr-config location.
The new solr-config module probably does not have the same parent configuration as your {AIO_PROJECT_PATH} project. So open up the {AIO_PROJECT_PATH}/solr-config/pom.xml file and make sure the parent section is correct.
If you have made changes to the Solr configuration, such as adding a synonyms list, then you will have to update the solr-config project with these changes.
Version 2.1.0 of the SDK have changes to the Linux run scripts and have new run scripts for Windows. So it make sense to take the new scripts from a newly generated 2.1.0 AIO project and replace the 2.0.0 scripts with them. So follow these instructions [57] to generate an AIO project based on the 2.1.0 archetype (if you have not already done it). Then just copy over the {newly generated 2.1.0 AIO}/run.* scripts to the {AIO_PROJECT_PATH} directory, overwriting the run.sh script.
By default, the Alfresco SDK uses H2 as its database, but it can be configured to use other databases such as MySQL, PostgreSQL, or DB2. MySQL [85] is a commonly used open source database. The following tutorials looks at how the Alfresco SDK can be configured to use MySQL rather than H2 as the main database for Alfresco, for both Repository AMP projects and All-in-One projects.
create database alfresco default character set utf8; grant all on alfresco.* to 'alfresco'@'localhost' identified by 'alfresco' with grant option; grant all on alfresco.* to 'alfresco'@'localhost.localdomain' identified by 'alfresco' with grant option;
mysql -u root -p
source db_setup.sql
This will create the Alfresco database (alfresco) and user/pwd (alfresco/alfresco).
<dependencies> ... <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.32</version> </dependency> </dependencies>
<!-- MySQL configuration --> <alfresco.db.name>alfresco</alfresco.db.name> <alfresco.db.username>alfresco</alfresco.db.username> <alfresco.db.password>alfresco</alfresco.db.password> <alfresco.db.host>localhost</alfresco.db.host> <alfresco.db.port>3306</alfresco.db.port> <alfresco.db.params></alfresco.db.params> <alfresco.db.url>jdbc:mysql://${alfresco.db.host}:${alfresco.db.port}/${alfresco.db.name}</alfresco.db.url> <alfresco.db.datasource.class>org.gjt.mm.mysql.Driver</alfresco.db.datasource.class>
Open the src/test/properties/local/alfresco-global.properties configuration file. Then comment out the following line:
#hibernate.dialect=org.hibernate.dialect.H2Dialect
mvn clean install
rm -rf alf_data_dev/This step is also very important as it will remove any content and indexes created when you started with the H2 database. When you switch over to run with MySQL the system thinks that it is the first time that you are running Alfresco, so it will create a new database, new content, and index again, which will clash with any previous starts with H2.
mvn install -Pamp-to-war
Alfresco will start up and use the MySQL database server that you configured. Track console messages to confirm such as:
... 2014-09-15 15:47:52,552 INFO [alfresco.repo.admin] [localhost-startStop-1] Using database URL 'jdbc:mysql://localhost:3306/alfresco' with user 'alfresco'. 2014-09-15 15:47:52,987 INFO [alfresco.repo.admin] [localhost-startStop-1] Connected to database MySQL version 5.6.11 ...
create database alfrescoaio default character set utf8; grant all on alfrescoaio.* to 'alfresco'@'localhost' identified by 'alfresco' with grant option; grant all on alfrescoaio.* to 'alfresco'@'localhost.localdomain' identified by 'alfresco' with grant option;
mysql -u root -p
source db_setup_aio.sql
This will create the Alfresco database and user.
Open the {AIO_PROJECT_ROOT}/runner/pom.xml project file. Then add the following dependency at the end of the tomcat7-maven-plugin definition:
<plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> ... </configuration> <dependencies> <dependency> <groupId>mysql</groupId> <artifactId>mysql-connector-java</artifactId> <version>5.1.32</version> </dependency> </dependencies> </plugin>
Open the {AIO_PROJECT_ROOT}/pom.xml project file. Then add the MySQL database connection properties as follows:
<properties> ... <!-- MySQL configuration --> <alfresco.db.name>alfrescoaio</alfresco.db.name> <alfresco.db.username>alfresco</alfresco.db.username> <alfresco.db.password>alfresco</alfresco.db.password> <alfresco.db.host>localhost</alfresco.db.host> <alfresco.db.port>3306</alfresco.db.port> <alfresco.db.params></alfresco.db.params> <alfresco.db.url>jdbc:mysql://${alfresco.db.host}:${alfresco.db.port}/${alfresco.db.name}</alfresco.db.url> <alfresco.db.datasource.class>org.gjt.mm.mysql.Driver</alfresco.db.datasource.class> </properties>
Open the {AIO_PROJECT_ROOT}/repo/src/main/properties/local/alfresco-global.properties configuration file. Then comment out the following line:
#hibernate.dialect=org.hibernate.dialect.H2DialectOpen the {AIO_PROJECT_ROOT}/repo-amp/src/test/properties/local/alfresco-global.properties configuration file. Then comment out the following line:
#hibernate.dialect=org.hibernate.dialect.H2Dialect
mvn clean installThis step is very important as it cleans up any previous configuration files from target/...
rm -rf alf_data_dev/This step is also very important as it will remove any content and indexes created when you started with the H2 database. When you switch over to run with MySQL the system thinks that it is the first time that you are running Alfresco, so it will create a new database, new content, and index again, which will clash with any previous starts with H2.
mvn install -Prun
Alfresco will start up and use the MySQL database server that you configured. As before, scan the console for messages that confirm that Alfresco has connected to MySQL:
2014-09-15 16:14:59,912 INFO [domain.schema.SchemaBootstrap] [localhost-startStop-1] Connecting to database: jdbc:mysql://localhost:3306/alfrescoaio, UserName=alfresco@localhost, MySQL Connector Java 2014-09-15 16:14:59,913 INFO [domain.schema.SchemaBootstrap] [localhost-startStop-1] Schema managed by database dialect org.hibernate.dialect.MySQLInnoDBDialect.
Links:
[1] http://docs.alfresco.com/
[2] https://github.com/Alfresco/alfresco-sdk/
[3] https://github.com/Alfresco/alfresco-sdk/issues
[4] http://forums.alfresco.com/forum/developer-discussions/development-environment
[5] https://docs.alfresco.com/../concepts/alfresco-sdk-whats-new.html
[6] https://docs.alfresco.com/../concepts/alfresco-sdk-introduction.html
[7] https://docs.alfresco.com/../concepts/alfresco-sdk-getting-started.html
[8] https://docs.alfresco.com/../concepts/alfresco-sdk-cmd-reference.html
[9] https://docs.alfresco.com/../concepts/alfresco-sdk-rad.html
[10] https://docs.alfresco.com/../concepts/alfresco-sdk-advanced-topics.html
[11] https://docs.alfresco.com/../concepts/alfresco-sdk-upgrading.html
[12] https://docs.alfresco.com/../concepts/alfresco-sdk-tutorials-mysql-intro.html
[13] https://wiki.alfresco.com/wiki/Managing_Alfresco_Lifecyle_with_Maven
[14] https://docs.alfresco.com/../concepts/alfresco-sdk-intro.html
[15] https://docs.alfresco.com/../concepts/alfresco-sdk-archetypes.html
[16] https://docs.alfresco.com/../concepts/alfresco-sdk-compatibility.html
[17] https://docs.alfresco.com/../concepts/alfresco-sdk-community-resources.html
[18] https://docs.alfresco.com/../concepts/alfresco-sdk-archetypes-repo-amp.html
[19] https://docs.alfresco.com/../concepts/alfresco-sdk-archetypes-share-amp.html
[20] https://docs.alfresco.com/../concepts/alfresco-sdk-archetypes-aio.html
[21] https://docs.alfresco.com/alfresco-sdk-archetypes-share-amp.html
[22] https://docs.alfresco.com/alfresco-sdk-archetypes-repo-amp.html
[23] https://github.com/Alfresco/alfresco-sdk/issues/180
[24] http://orderofthebee.org/
[25] http://mindthegab.com/
[26] http://www.marversolutions.com/wordpress/2015/01/28/alfresco5-maven-sdk-2/
[27] http://ohej.dk/2014/09/alfresco-sdk-2-0-beta4/
[28] https://docs.alfresco.com/../concepts/alfresco-sdk-before-you-begin.html
[29] https://docs.alfresco.com/../concepts/alfresco-sdk-installing-prerequisite-software.html
[30] https://docs.alfresco.com/../concepts/alfresco-sdk-tutorials-archetypes.html
[31] https://docs.alfresco.com/alfresco-sdk-whats-new.html
[32] https://docs.alfresco.com/alfresco-sdk-compatibility.html
[33] https://docs.alfresco.com/alfresco-sdk-archetypes.html
[34] https://docs.alfresco.com/../tasks/alfresco-sdk-install-spring-loaded.html
[35] https://docs.alfresco.com/../tasks/alfresco-sdk-install-java.html
[36] https://docs.alfresco.com/../tasks/alfresco-sdk-install-java-home.html
[37] https://docs.alfresco.com/../tasks/alfresco-sdk-install-maven.html
[38] https://docs.alfresco.com/../tasks/alfresco-sdk-install-maven-opts.html
[39] https://docs.alfresco.com/../concepts/alfresco-sdk-using-enterprise-edition.html
[40] https://docs.alfresco.com/../tasks/alfresco-sdk-install-verify-install.html
[41] https://github.com/spring-projects/spring-loaded
[42] http://maven.apache.org/download.cgi#Maven_Documentation
[43] http://www.oracle.com/technetwork/java/javase/downloads/index.html
[44] http://docs.oracle.com/javase/8/docs/technotes/guides/install/install_overview.html
[45] http://support.microsoft.com/kb/310519
[46] http://maven.apache.org/download.cgi
[47] http://books.sonatype.com/mvnref-book/reference/installation-sect-maven-install.html
[48] https://artifacts.alfresco.com
[49] https://myalfresco.force.com/support/articles/en_US/Technical_Article/Where-can-I-find-the-repository-for-Enterprise-Maven-artifacts
[50] http://www.alfresco.com/company/contact
[51] https://docs.alfresco.com/../tasks/alfresco-sdk-tutorials-configure-maven-enterprise.html
[52] http://maven.apache.org/guides/mini/guide-encryption.html
[53] https://docs.alfresco.com/alfresco-sdk-archetypes-aio.html
[54] https://docs.alfresco.com/../tasks/alfresco-sdk-tutorials-amp-archetype.html
[55] https://docs.alfresco.com/../tasks/alfresco-sdk-tutorials-share-amp-archetype.html
[56] https://docs.alfresco.com/../tasks/alfresco-sdk-tutorials-all-in-one-archetype.html
[57] https://docs.alfresco.com/alfresco-sdk-tutorials-all-in-one-archetype.html
[58] https://docs.alfresco.com/alfresco-sdk-tutorials-amp-archetype.html
[59] https://docs.alfresco.com/../concepts/alfresco-sdk-cmd-reference-repo-amp.html
[60] https://docs.alfresco.com/../concepts/alfresco-sdk-cmd-reference-share-amp.html
[61] https://docs.alfresco.com/../concepts/alfresco-sdk-cmd-reference-aio.html
[62] https://docs.alfresco.com/../tasks/alfresco-sdk-rad-eclipse-import-projects.html
[63] https://docs.alfresco.com/../tasks/alfresco-sdk-rad-eclipse-hot-reloading.html
[64] https://docs.alfresco.com/../tasks/alfresco-sdk-rad-intellij-import-projects.html
[65] https://docs.alfresco.com/../tasks/alfresco-sdk-rad-intellij-hot-reloading.html
[66] https://docs.alfresco.com/../tasks/alfresco-sdk-rad-eclipse-remote-debugging.html
[67] https://docs.alfresco.com/alfresco-sdk-rad-eclipse-import-projects.html
[68] https://docs.alfresco.com/alfresco-sdk-rad-intellij-import-projects.html
[69] https://docs.alfresco.com/../concepts/alfresco-sdk-advanced-add-custom-amps.html
[70] https://docs.alfresco.com/../tasks/alfresco-sdk-advanced-configure-ssl-repo-solr.html
[71] https://docs.alfresco.com/../tasks/alfresco-sdk-advanced-adding-internal-external-jars-to-repo-amp.html
[72] https://docs.alfresco.com/../tasks/alfresco-sdk-advanced-link-alf-amps-aio.html
[73] https://nilhcem.github.io/FakeSMTP/
[74] https://docs.alfresco.com/../tasks/alfresco-sdk-advanced-link-custom-amps-aio.html
[75] https://docs.alfresco.com/../tasks/alfresco-sdk-advanced-add-custom-amps-aio.html
[76] https://docs.alfresco.com/alfresco-sdk-tutorials-share-amp-archetype.html
[77] https://docs.alfresco.com/../tasks/alfresco-sdk-upgrading-alfresco-version.html
[78] https://docs.alfresco.com/../concepts/alfresco-sdk-upgrading-sdk-version.html
[79] https://docs.alfresco.com/../concepts/alfresco-sdk-upgrading-what-changes-are-allowed-in-release.html
[80] https://docs.alfresco.com/../concepts/alfresco-sdk-upgrading-sdkversion-200-210.html
[81] https://docs.alfresco.com/../tasks/alfresco-sdk-upgrading-repo-amp-sdkversion-200-210.html
[82] https://docs.alfresco.com/../tasks/alfresco-sdk-upgrading-share-amp-sdkversion-200-210.html
[83] https://docs.alfresco.com/../tasks/alfresco-sdk-upgrading-aio-sdkversion-200-210.html
[84] https://docs.alfresco.com/alfresco-sdk-advanced-add-custom-amps-aio.html
[85] http://www.mysql.com
[86] https://docs.alfresco.com/../tasks/alfresco-sdk-tutorials-using-mysql-simple-amp.html
[87] https://docs.alfresco.com/../tasks/alfresco-sdk-tutorials-using-mysql-all-in-one.html
[88] http://dev.mysql.com/doc/