It is time to talk about the delivery format of your project. You tell me, he use for many post AMP format and now he wants to give us something else? Yeap it's true...!
Depending on your projects, your distribution of roles, your teams and your business practices, the delivery format can be simple or very very complex!
Take the classic case, on the one side we have a development team and in the other side we have an operation (production) team. The first one is responsible for creating the product, the other is in charge of installing the product and verify that it works throughout its lifetime.
The question: What is the exchange format of product between these two teams?
Ps: we will not consider here all the documentation from the production team ...
Let's make a list of possible cases:
- AMP(s): For the development team is the simple format. Indeed it is the output format of our project! So you have just to get AMP file and send it! Of course if our project consists of several AMPs, we will send all AMPs. In this case, the production team is responsible for generating the WAR application using the script provided by Alfresco.
- A WAR: Here the development team is responsible for creating the war. They have to integrate different modules in the default Alfresco war. The production team have to simply install the application.
- AMP + WAR: In this scenario, the production team want to have the application and AMPs.
- Other: Here you can invent anything that goes through your head. If you work in big projects, or in a large size companies, I think you have very beautiful examples!
The idea as usual is to run a Maven command and wait for the generated file(s). Never forget that the developer is supposed to be lazy ^ ^.
In lines below, I will present two approaches to generate anything other than your AMP. These approaches are based on a new project called war-alf-osecm.
Note: This approach is not very consistent with the philosophy but Maven does the work desired.
Creating a new project AMP
Create a directory with the name: alf-war-osecm and add a pom.xml with value below
Alfresco AMP Open Source ECM
Open Source ECM - Extension
Integrating the tool into a repository
In this project, we will use AlfrescoModule Management Tool . This module is available in the bin directory of Alfresco standard installation . It is also available here: http://wiki.alfresco.com/wiki/Community_Edition_file_list_3.3.
So initially, we will install this file in our maven repository with the command:
call mvn install:install-file -Dfile=alfresco-mmt.jar -DgroupId=org.alfresco.sdk -DartifactId=mmt -Dversion=3.3 -Dpackaging=jar -DgeneratePom=true -DcreateChecksum=true
Note : We perform this command in the directory where Alfresco module management tool file is.
Due to this integreation, It will be possible to find it through the classic mechanism of dependency .
Create a new Alfresco WAR
Now, as the title suggests, I want to generate a WAR with all AMPs. It will integrate all AMPs in a WAR Alfresco. This process will be divided into 4 parts.
- Setting Properties: In this part, we will initialize the properties that we used during other parts.
- Import pre-requisite: We will install Alfresco war and tool into our working directory.
- Import of AMP: In our working directory, we will create a subdirectory that will serve to contain all AMPs to integrate.
- War Generation : Here, we will launch a command line to integrate AMPs
- (Optional) Install war in maven repository: After generation, you can optionally add the generated war in our maven repository.
We will define four properties
- Work.dir: Working directory
- Amps.dir: AMP directory
- Mmt.jar: Module Management Tool filename
- Alfresco.war: Alfresco war filename
Via the plugin maven-dependency-plugin we will use the goal copy during the prepare-package phase. To simplify, we want to copy a set of dependencies (alfresco.war and tool) in our working directory.
In this stage, we will add a dependencies block in our pom.xml. In our case, dependencies contains 2 dependencies :
Our pom.xml looks like
Then, we continue using maven-dependency-plugin. We will realize the goal copy-dependencies in the phase of prepare-package. More simply, we want to copy all MPAs (defined in length) in a subdirectory of work amps.dir ().
Via the plugin exec-maven-plugin, we will realize the goal exec during the package phase. In other words, we want to achieve the same behavior as apply-amps.bat file (or .sh) but via Maven.
Now it is possible to run the command
mvn clean package
You can now find in your work.dir a new alfresco.war containing all AMP dependencies defined in our pom.xml.
(Optional) Install the war locally
If you want to install this war in your local repository (and thus be able to create dependencies for testing or integration purposes), here is the configuration to add to your build phase:
With the command
mvn clean install
you can install your new war. Of course, you can change various settings to suit your needs ...
Note: You can do the same deploy phase if you change some parameters... ^ ^
Create a custom delivery format
Now we'll look at creating a custom delivery format. In my case, I wish
- Create a zip file containing
- A root folder : groupId.artifactId
- A sub-folder amps containing my amps
- A sub-folder application containing alfresco.war (with the amp already include)
To do the job, I'll use maven-assembly-plugin. This plugin is used to create custom distribution formats. Configuration of this plugin is done in 2 steps:
- Create a description file
- Adding configuration in pom.xml
Create a description file
This description file defines the expected result ie what are the directories to create, file formats, rights, encoding ... We can actually define a lot of parameters!
In our case, we will create osecm-assembly.xml in alf-war-osecm\src\assembly directory. This file contains the following configuration:
As you can see, it takes the configuration expected in my requirements.
Adding to the pom.xml
Now we must declare in the pom.xml this new file. So we add maven-assembly-plugin with the configuration below
Finally, I can run the command :
mvn clean assembly:assembly
This command assemble my custom distribution format. In the target directory, you can find your custom file called : alf-war-osecm-0.1-production.zip ready to be sent!
Note: This plugin may be greedy in memory. To resolve this problem increase values in MAVEN_OPTS environment variable.