mmt-maven-plugin 0.1-SNAPSHOT released

After a month (or so) of experiements, it was time to deploy the first snapshot of a new version of the maven-amp-plugin, the mmt-maven-plugin.

Since there is no official documentation yet, I just wanted to share with you an initial draft of the usage and goal configurations; you can start using it already and test it in your builds that are currently based on maven-amp-plugin.

The plugin is currently committed as a branch of the Maven Alfresco Archetypes Google Code project, although it could be soon moved to an Alfresco internal code repository.

MMT Goals

The mmt-maven-plugin provides the following features:

  • Packages an AMP starting from a simple (and configurable) Maven project folder structure
  • Performs AMP to WAR overlay by using the Alfresco Repository ModuleManagementTool and emulating the same process during Alfresco boostrap
Usage - To build an AMP file
  1. Define your POM as <packaging>amp</packaging>
  2. Specify a module.properties file in the project's root folder, containing the properties module.id=${project.artifactId},  module.title=${project.name},  module.description=${project.description}, module.version=${project.version}; as you can see, the file is filtered with Maven project placeholders
  3. Declare the mmt-maven-plugin in your POM build section, as follows
<build>  <plugins>    <plugin>      <groupId>org.alfresco.maven.plugin</groupId>      <artifactId>mmt-maven-plugin</artifactId>      <version>0.1-SNAPSHOT</version>    </plugin>  </plugins></build>

you can optionally define the following configurations to override your Maven project's structure (although not recommended)

<configuration>  <classesDirectory>${project.build.outputDirectory}</classesDirectory>  <webappDirectory>src/main/webapp</webappDirectory>  <configDirectory>src/main/webapp</configDirectory></configuration>

Usage - To overlay an existing Alfresco WAR file, you'll need the following elements

  1. Add a dependency to the Alfresco WAR webapp
  2. Add the mmt-plugin configuration to run the install goal after the AMP have been packaged
<dependencies>  <dependency>    <groupId>org.alfresco.enterprise</groupId>    <artifactId>alfresco</artifactId>    <version>4.0.1</version>    <type>war</type>  </dependency></dependencies>

 

<plugin>  <groupId>org.alfresco.maven.plugin</groupId>  <artifactId>mmt-maven-plugin</artifactId>  <version>0.1-SNAPSHOT</version>  <executions>    <execution>      <id>unpack-amps</id>      <phase>package</phase>      <goals>        <goal>install</goal>      </goals>      <configuration>        <singleAmp>${project.build.directory}/${project.build.finalName}.${project.packaging}</singleAmp>      </configuration>    </execution>  </executions></plugin>

 

Please be aware that this is still an experimental work; I hope to give you some updates about this effort by the end of this/next week; meantime, any comment/feedback is indeed more than welcome.

My apologies for the ugly look 'n feel of the blog, I'm moving to a new blog engine as we speak!

Apache Maven 3 Cookbook review

Apache-maven3-cookbook-image
Today I had the possibility to read the new book published by Packt Publishing, Maven 3 Cookbook, written by Srirangan; in the following post I'll shortly review the topics discussed and give my personal opinion on the book.

The book contains a good collection of recipes to start playing with Apache Maven, an Open Source build automation tool widely adopted, especially for JVM-based languages, such as Java, Scala, but also applicable to other languages, like PHP, Ruby and C#.

The book is targeted for Software Developers who want to start with Maven, therefore it is important to have a generic knowledge about Software Development and the challenges that need to be tackled when building Software; the definition of Application Lifecycle Management is good reading to start.

It is highly advised to follow this book with a laptop close to you, having a working installation of Maven 3.0.x; the first chapter of this book will guide you through the process.

Let's talk about the contents; the book can be divided in two main parts:

Introduction to Maven as a build tool and its main features and conventions, with examples and snippets

(Chapter 1 to 4) 

In my opinion these chapters, especially if targeted to a Maven newbie, lack of main concepts, such as:

  • What is the Maven Reactor
  • Properties and resource filtering
  • What is/how to use Maven archetypes

The concept of Maven Lifecycle, which I consider the most important if you need to model your build behaviors, is not extensively explained, although I think it should be necessary to understand the examples - in the second part of the book - which make use of plugin's <executions>.

I strongly advise to have a full understanding of these concepts (especially before complaining that Maven is too complex ;-) and to read Maven: The Complete Reference from Sonatype.

Nevertheless, this first part is a quick reading that allows you to setup a complete project environment using Maven in no more than 20 minutes, not bad.

Chapter 2 (Software Engineering Techniques) focuses on Maven built-in build automation, such as compilation, packaging, multi-module, reporting, code quality, unit/web testing and distribution; it is a nice and quick walk through the main features of Maven, although not extensively explained, which is good if you're starting. I liked the summary of useful commands provided by the maven-dependency-plugin, which are simply mandatory to debug your build.

Chapter 3 (Agile Team Collaboration) covers same topics of chapter 2 with a special focus on team collaboration, therefore SCM configuration, setting up a centralized Maven repository and Maven offline mode. I see many topics not related with Agile in this chapter, for example I'd have expected SCM to be categorized as a highly advisable Software Engineering Technique; I was also expecting more details on the SCM release process (maven-release-plugin explained). I liked the observations of the author regarding Distributed Development, especially the way he managed to explain important dynamics with simple words (page 67)

The extensive description on how to install Nexus and Tomcat could probably be jumped, assuming there is enough documentation on Google already for that.

Chapter 4 (Reporting and Documentation) is the one I've enjoyed the most, since it delivers practical snippets to setup your Maven site reporting, checkstlyle, javadocs and more; this is something that - within the project - tends to be forgotten/avoided/de-prioritized due to different reasons; Maven provides an extremely powerful set of tools to automatize these processes, which are properly described and tested in this chapter.

Different Maven recipes for different goals, in different languages, plus IDE integration and write your first Maven Plugin

(Chapter 5 to 9) 

In general, it's a good collection of snippets and recipes; of course you can always find nicer/better/newer snippets of the very same thing on Google and you can probably adopt them with less hassle; on the other hand, there are some extremely useful examples of technologies involving some custom configuration (see Hibernate) or a deeper understanding of the different tools involved (i.e. the Android SDK)

Chapter 5 (Java Development with Maven) explains a very nice and clean Hibernate project using hibernate3-maven-plugin and delivers a very clean structure; I wasn't extremely surprised by the configurations of Seam and Spring, very basic. Maybe I was expecting some examples on how to deliver multi-environment setup using resource filtering

Chapter 6 (Google Development with Maven) is the second chapter I've enjoyed the most (maybe because I don't have an extensive experience with Google Development platform); the entire environment setup is nicely described and allows you to be up and running in a very short time, but with full control on your build processes.

Chapter 7 (Scala, Groovy, and Flex) contains some snippets to start with the mentioned languages and use Maven as build tool; it does not provide a lot of very specific information, everything can be reached on the Web with no hassle, but it's nice to have it for completeness, especially for teams that adopt different programming languages in the same project. Maybe Clojure was worth to be mentioned.

Chapter 8 (IDE integration) provides an explanation on how to setup your IDE (if you use IntelliJ Idea, Eclipse or Netbeans) with Maven. There are many screenshots that help you with the configuration; all mentioned IDEs all provide a solid and intuitive way to configure Maven and most of the times you don't need to follow a tutorial. Nice to have it for completeness.

Chapter 9 (Extending Apache Maven) is a quick tour on how to write your own plugin using different languages; the main goal of the chapter is to make the reader aware that it is very simple to build your own plugin/behavior and that you can use different languages, but it cannot be considered a guideline for Maven Plugin Development.

Conclusions

Maven 3 Cookbook is a great contribution to the Maven Community and I am happy to have it reviewed; it does not cover everything for sure, but gives you a very quick start on Maven and remarks what are the most important aspects of a software lifecycle providing simple examples; it is definitely a nice reading for someone that has never used Maven.

From a general perspective, the book is well written, it provides a clear chapter structure and a high readability; the Maven archetypes provided by Packt are very useful and save a lot of time copy/pasting code if you want to run the examples.

The Maven expert could get a bit bored with this reading, although there are some very nice considerations and snippets, especially on Chapter 3, 4 and 6.

Although the book covers and amazing amount of topics, yet being able to keep it simple and readable, some important topics are missing; I strongly advise to deepen your Maven know-how reading also

 

Many thanks to Packt Publishing for providing me a digital copy of the book!

Filed under  //   Book   Maven   build  

Alfresco Distribution - Multi-environment, Enforce and Assembly with Maven

I'm currently refactoring a Maven build - while fixing some minor bugs - on an Alfreco Share project; along with the common project's structure (alfresco and share folder), my colleagues have introduced a distribution module which uses the maven-assembly-plugin to create a big ZIP file containing everything that is needed to perform a deployment:

  • WAR files to deploy (alfresco and share)
  • Server certificates
  • Tomcat shared configurations and libs
  • ... any other file involved in the deployment procedure

The folder structure is straightforward:

  • src
    • environments
      • prod
      • staging
      • test

The issue - or rather the improvement - was to accept the name of the target environment as build parameter and only import those specific settings.

There's nothing new of course, but I thought that contributing this Maven snippet might be helpful for others.

Filed under  //   Alfresco   Maven   alm   build   ecm  

The Hippo Rijkshuisstijl Archetype

Media_httppillitufile_vykac
Media_httppillitufile_ykexs
Media_httppillitufile_dfeai

In the last 6 months we at Sourcesense had intense activities related to Hippo 7; we found this new version pretty cool and we've used it to build a website for a customer and sell around some consultancy. In the same context, we've been working a lot with the Rijkshuisstijl - which is the official Dutch Governmental Web Stylesheet; tired of copy-pasting, we decided to wrap up a nice package to use, reuse and share with the rest of the community. The main goal of this package is to provide a standard way to deliver a working Hippo CMS environment (and reusable examples of customization) for a small/medium Rijkshuisstijl-compliant website; there is also a special focus on the development environment and application lifecycle management, which are topics that can be easily de-prioritized at the beginning of a project, but can make the difference on the long run. We're proud to share with you the Hippo Rijkshuisstijl Archetype! Many thanks to the whole sourcesense NL team for the great support, but a special one goes to Paul Bakker, who was my teammate on all these activities and contributed a lot to this archetype.

Read the rest of this post »

Filed under  //   alm   archetype   calm   cms   ecm   government   hippo   hst   rijkshuisstijl  

Private Repositories with Nexus

Media_httppillitufile_qonmf
Creating Private repositories with Nexus can be an hard task, especially if you're not accustomed with its internal roles/privileges mechanism; let's first introduce some bits of it: Nexus authorization model is composed by - privileges, which are aggregated in - roles, which are assigned to - users, having username/password used for the HTTP-based authentication while accessing a specific repository/group/artifact Everytime you access a Nexus content, the anonymous credentials are used by default; if the access is denied, an HTTP authentication is requested. The default Nexus configuration provides an anonymous user with read access to all repositories; this means that when you create a new repository it will be automatically accessible, regardless it's Browseable and/or Indexable. What I wanted to achieve was to have an anonymous access AND one (or more) private repository; these are the steps that I performed in order to achieve it 1. Create a new Hosted repository, say Private Sourcesense 2. Create Privileges for Private Sourcesense repository and for each Nexus Repository Group that must be publicly and anonymously accessed; in my case it was Public Repositories and Public Snapshot Repositories; for each entry Nexus will automatically create separated read, create, update, delete privileges. 3. Create a sourcesense-private role that has create,read,update,delete privileges on the Private Repository previously created; feel free to aggregate any other available Nexus role 4. Create a sourcesense-anonymous role that aggregates the Nexus Repository Group read privileges previously created. 5. Create a sourcesense-private and sourcesense-anonymous user associating their related role. 6. Set sourcesense-anonymous as the Nexus anonymous user (via Administration > Server dialog) Now, if I create a new repository (proxied or hosted) this won't be anonymously accessible either via HTTP or UI by default; you first have to associate it with one of the Nexus Public Groups.
Filed under  //   Maven   Nexus   Sonatype  

What is a Maven POM

The Build Doctor has started to publish a set of short articles regarding Apache Maven; I've contributed some thoughts about the POM, the main concept behind the convention over configuration approach introduced by Maven. Apache Maven provides a great support for most of the common application lifecycle challenges; as any other framework or technology, it can be used and it can be abused, that's why best practices are important; these easy guidelines can lower drastically the learning curve and contrast the frequent skepticism of people saying that Maven is just overcomplicated for its purpose.
Filed under  //   Maven   build   build+doctor   lifecycle   pom  

Migrating Hippo ECM from 7.0 to 7.1

It was easier than expected, but I went through some small tricks on the pom.xml and the content model that might be helpful for those that are planning to move towards 7.1; well, a good chance to share some knowledge, I hope I can save you some time ;-) Feel free to
  • Brutally copy/paste these instruction on a more structured Hippo-hosted documentation page
  • Add additional steps to take in consideration (just comment on the blog)
  - Added the following dependency in cms/pom.xml
<dependency>
 <groupId>org.onehippo.ecm.hst.toolkit-resources.addon.toolkit-cnd</groupId>
 <artifactId>hst-addon-cnd_7_1</artifactId>
 <version>${hst.version}</version>
</dependency>
- HINT! Be sure that all your addons have been released for the major ecm/hst versions (2.06.06/2.03.09); in my case, I had to modify the following dependency from
<dependency>
 <groupId>org.hippoecm</groupId>
 <artifactId>hippo-ecm-addon-reviewed-action-common</artifactId>
 <version>${hst.version}</version>
</dependency>
to
<dependency>
 <groupId>org.hippoecm</groupId>
 <artifactId>hippo-ecm-addon-reviewed-action-common</artifactId>
 <version>${reviewed-action-addon.version}</version>
</dependency>
where reviewed-action-addon.version = 2.03.04; I strongly advise you to keep a clear separation between dependencyManagement (on your project parent pom) and dependencies in your cms/pom.xml and site/pom.xml
- Added /content/documents folder in the JCR Node structure: your content/src/main/resources/myproject-root.xml should look like
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="documents">
 <sv:property sv:name="jcr:primaryType" sv:type="Name">
   <sv:value>hippostd:folder</sv:value>
 </sv:property>
 <sv:property sv:name="jcr:mixinTypes" sv:type="Name">
   <sv:value>hippo:harddocument</sv:value>
 </sv:property>
 <sv:property sv:name="hippostd:foldertype" sv:type="String">
   <sv:value>New Folder</sv:value>
   <sv:value>New Document</sv:value>
 </sv:property>
 <sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="myproject">
   <sv:property sv:name="jcr:primaryType" sv:type="Name">
     <sv:value>hippostd:folder</sv:value>
   </sv:property>
   <sv:property sv:name="jcr:mixinTypes" sv:type="Name">
     <sv:value>hippo:harddocument</sv:value>
   </sv:property>
   <sv:property sv:name="hippostd:foldertype" sv:type="String">
     <sv:value>New Folder</sv:value>
     <sv:value>New Document</sv:value>
   </sv:property>
 </sv:node>
</sv:node>
- Upgraded namespaces in myproject-types.cnd from
<'hippostd'='http://www.hippoecm.org/hippostd/nt/1.2'>
<'hippo'='http://www.hippoecm.org/nt/1.2'>
to
<'hippostd'='http://www.hippoecm.org/hippostd/nt/1.3'>
<'hippo'='http://www.hippoecm.org/nt/1.3'>
- Update any contentRoot reference in hippoecm-extension.xml from
<sv:property sv:name="hippo:contentroot" sv:type="String">
 <sv:value>/content/myproject</sv:value>
</sv:property>
to
<sv:property sv:name="hippo:contentroot" sv:type="String">
 <sv:value>/content/documents/myproject</sv:value>
</sv:property>
- Removed any instance of sv:property[@sv:name="frontend:overrides"] from mytypes-templates.xml from
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="hippo:template">
 <sv:property sv:name="jcr:primaryType" sv:type="Name">
   <sv:value>frontend:plugincluster</sv:value>
 </sv:property>
 <sv:property sv:name="frontend:overrides" sv:type="String">
   <sv:value>wicket.id</sv:value>
   <sv:value>wicket.dialog</sv:value>
   <sv:value>engine</sv:value>
   <sv:value>mode</sv:value>
 </sv:property>
 <sv:property sv:name="mode" sv:type="String">
   <sv:value>edit</sv:value>
 </sv:property>
 <sv:property sv:name="wicket.model" sv:type="String">
   <sv:value>${cluster.id}.model</sv:value>
 </sv:property>
</sv:node>
to
<sv:node xmlns:sv="http://www.jcp.org/jcr/sv/1.0" sv:name="hippo:template">
 <sv:property sv:name="jcr:primaryType" sv:type="Name">
   <sv:value>frontend:plugincluster</sv:value>
 </sv:property>
 <sv:property sv:name="frontend:properties" sv:type="String">
   <sv:value>mode</sv:value>
 </sv:property>
 <sv:property sv:name="frontend:references" sv:type="String">
   <sv:value>engine</sv:value>
   <sv:value>wicket.model</sv:value>
 </sv:property>
 <sv:property sv:name="frontend:services" sv:type="String">
   <sv:value>wicket.id</sv:value>
 </sv:property>
 <sv:property sv:name="mode" sv:type="String">
   <sv:value>edit</sv:value>
 </sv:property>
</sv:node>
- Changed hippostd:fixeddirectory to hippostd:directory
from
<sv:property sv:name="jcr:primaryType" sv:type="Name">
 <sv:value>hippostd:fixeddirectory</sv:value>
</sv:property>
to
<sv:property sv:name="jcr:primaryType" sv:type="Name">
 <sv:value>hippostd:directory</sv:value>
</sv:property>
- Changed hippostd:foldertype syntax from
<sv:property sv:name="hippostd:foldertype" sv:type="String">
 <sv:value>New File Folder</sv:value>
 ....
</sv:property>

to
<sv:property sv:name="hippostd:foldertype" sv:type="String">
 <sv:value>new-document</sv:value>
 ....
</sv:property>
Filed under  //   Maven   ecm   hippo   migration  

Maven Calm

Calm stands for...

Media_httppillitufile_ninwb
Calm Application Lifecycle Management, which stands for Calm Application Lifecycle Management Application Lifecycle Management ... ehm just kidding ;) Calm is an early implementation of main ALM use cases on an Open Source and collaborative framework based on Apache Maven.  

What exactly is Maven Calm

Maven Calm is not just a Corporate POM. It's a cross-corporate POM which provides lifecycle-oriented configuration for your Maven Plugins; the best way to start is having a look at the presentation! In short, your Project or Corporate POM should look like this to inherit all the ALM oriented behaviors.  

How can you Customize it

Have a look at the README to see which properties are used and their default values; you can (re)define them in your pom.xml or profiles.xml.  

How can you Contribute

 

  • Contribute your ideas, maven profiles and best practices in this google group (maven-calm at googlegroups dot com)
  • Request for joining the project at Maven Calm Google Code
 

How can you Run it

Property filtering and multiple environments

Every property of your POM is dumped into a project.properties file which is bundled with your classpath; you are free to choose how to define your properties. You can setup your IOC container to parse this file from the classpath in order to externalize the environment-related configurations; you can easily define different environments in your profiles.xml, triggered either by a command-line property called env (-Denv=yourEnv) or by a direct profile invocation (-PyourCustomProfile); have a look at this sample.

Run Tests

mvn integration-test

Run Selenium Tests

NOTE! You need to have firefox installed mvn integration-test -Pselenium

Generate and Deploy documentation

NOTE! Check this settings.xml template to see how to configure credentials mvn site-deploy

Deploy POM/JAR/WAR packages on a (remote) Maven repository

NOTE! Check this settings.xml template to see how to configure credentials mvn deploy

Deploy WAR packages on a J2EE Container

mvn cargo:deployer-redeploy

Release

This might include several other processes aforementioned, as configurable with a whole set of pom.xml or profiles.xmlproperties. For example the default maven.release.goals property is by default configured to perform:

  • Interactive project modules version update
  • Site generation and Deployment
  • SCM tagging and version control
  • Deploy on a remote Maven repository

If you use SVN, the credentials stored in your USER_HOME/.subversion will be used mvn release:prepare release:perform

Create production-ready Tomcat Bundles

Check the Tomcat configuration of your webapp in features/tomcat:

|- features
  |- tomcat
    |- conf
      |- setenv.sh
      |- server.xml
      |- context.xml
      |- catalina.policy
    |- web.xml
    |- any.other.appl.file.xml

Then run the following command mvn clean install -Ptomcat

 

Troubleshooting

Dependency problems or duplications?

mvn dependency:tree > dep-tree.log mvn dependency:list > dep-list.log

Problems with your plugin executions? Checkout the effective POM and profiles

mvn help:effective-pom -P my_optional_profiles > eff-pom.log mvn help:active-profiles -P my_optional_profiles > eff-profiles.log

Filed under  //   Maven   alm   calm   lifecycle   sourcesense  

Maven and Calm

Back to blogging! Last weekend I've spent a wonderful time in London with my girlfriend and a very interesting Maven training led by Jason Van Zyl, its founder; even using/coaching/spreading Maven technology and best practices since couple of years now, I found this training terribly interesting; Jason is an easy guy, always smiley and available for any question; this made all the training very chill and relaxing. I found particularly interesting the chapter on Nexus and its advanced features, such as Staging Repositories; I'm planning to upgrade the Sourcesense Repository this weekend adding all these cool features plus a CI node powered by Hudson; looking forward to test the Procurement platform and the OSGI support :P Talking about Jason and Maven, last Friday Sourcesense has organized an event that has drawn an significant attention, considering that invitations have been sent out only 3 days in advance; Rene (from Atlassian), Gianugo, Jason and myself had a 30-minutes long speech on different topics, all aimed at improving the software development process using the right tools, rather than designing huge infrastructures and complex processes. More in details, maven-calm is just a Corporate POM, but with an Open Source approach; struggling since years with Maven I realized that we were starting yet again to do copy/paste of POM files, either from other project or rather from other Corporate POM (i.e. the Codehaus Parent POM, one of my preferred ones ;-) and that this process was potentially leading to some of the problems we were facing while copy/pasting our old Ant build.xml files. If you use Maven for your project development processes (test, package, release, deploy, ...) you'd probably write the very same configuration of maven-calm, so why not just use maven-calm as parent pom? If you rather are scared of Maven because you think the learning curve is too steep or for any other reason, you can just give maven-calm a try; with the README you're up and running in 5 minutes, with all the project's infrastructure in place. As you see, a lot of interesting Maven work has approached at Sourcesense lately and more will come soon! Stay tuned ;-)
Filed under  //   Maven   calm   training  

About

About me

Born in Italy, living in Amsterdam.

Constantly working with Open Source technologies, I've built a strong passion for ALM and build process engineering.

Addicted to italian food and (played) football.

Hobbies: books, photography, movies, South Park, beers with friends.