“Once upon a midnight dreary, while I pondered weak and weary…”

Here’s the scene–you’re sitting in a luxurious armchair next to a dancing fire, hot beverage in hand. Shadows dance on the tapestry-covered wall, and your cat Lenore II is purring softly from her favorite perch atop the mantle.

“Ah, distinctly I remember it was in the bleak December…”

At least you’re passing this cold December night in grand style (in front of your computer customizing Liferay Portal, of course).

“Eagerly I wished the morrow;–vainly I had sought to borrow From Liferay surcease of sorrow–sorrow for my last Lenore–”

We’re sorry to hear your previous cat, the original Lenore, has passed away. Just take good care of Lenore II, would you?

“And the silken sad uncertain rustling of each purple curtain Thrilled me–filled me with *Ant*astic terrors never felt before;”

Okay now you’re being melodramatic; nobody can disdain Apache Ant that vehemently. What about customizing Liferay Portal using the Ant-based Plugins SDK could make you feel sadness and terror?

“Deep into that darkness peering, long I stood there wondering, fearing…”

We get it! You don’t want to use our Ant-based Plugins SDK. Give us surcease from the melodrama, okay?

“Open here I flung the shutter, when, with many a flirt and flutter, In there stepped a stately Maven of the saintly days of yore.”

So, you’d rather use Apache Maven to develop your Liferay plugins?

“But Apache Maven still beguiling all my sad soul into smiling…”

Edgar Allen Poe liked Maven too, so you’re in good company. Trust us; we know. But if your soul was made sad because you thought you had to use Liferay’s Ant-based Plugins SDK to develop your plugins, Apache Maven will make your sad soul smile. And while you’re at it, take care of Lenore II for all of us animal lovers, would you?

Quoth the Maven, “Let us proceed undaunted in exploration of these topics:”

  • Installing Maven
  • Using Maven Repositories
  • Installing Required Liferay Artifacts
  • Using a Parent Plugin Project
  • Creating Liferay Plugins with Maven
  • Deploying Liferay Plugins with Maven
  • Liferay Plugin Types to Develop with Maven

As an alternative to developing plugins using the Plugins SDK, you can leverage the Apache Maven build management framework. Here’s a list of some exciting Maven features:

  • Offers a simple build process.
  • Features a project object model.
  • Has a defined project life cycle.
  • Provides a dependency management system.

Maven’s core installation is lightweight; there are core plugins for compiling source code and creating distributions, and there is an abundance of non-core plugins, letting you extend Maven easily for your customizations.

Many developers are switching from Ant to Maven because it offers a common interface for project builds. Maven’s universal directory structure makes it easier for you to understand another developer’s project more quickly. With Maven, there’s a simple process to build, install, and deploy project artifacts.

Maven uses a project object model (POM) to describe a software project. The POM is specified as XML in a file named pom.xml. Think of pom.xml as a blueprint for your entire project; it describes your project’s directories, required plugins, build sequence, and dependencies. The POM is your project’s sole descriptive declaration. Once you create the pom.xml file and invoke the build process, Maven does the rest, downloading your project’s inferred dependencies and building your project artifacts. If you’re not already familiar with how Maven works, you can get familiar with Maven’s project object model by reading Sonatype’s documentation for it at http://www.sonatype.com/books/mvnref-book/reference/pom-relationships.html.

Maven provides a clear definition of a project’s structure and manages a project from a single piece of information–its POM. Understanding a Maven project can be much easier than understanding an Ant-based project’s various build files. Maven forces projects to conform to a standard build process, whereas Ant projects can be built differently from project to project. Also, Maven provides an easy way to share artifacts (e.g., JARs, WARs, etc.) across projects via public repositories.

There are disadvantages to using Maven. You might find the Maven project structure too restrictive, or decide that reorganizing your projects to work with Maven is too cumbersome. Maven is intended primarily for Java-based projects, so it can be difficult to manage your project’s non-Java source code. Consider Maven’s advantages and disadvantages, then decide how you want to manage your projects. After you’re finished reading about Maven here, you can read an in-depth book about Maven at Maven: The Complete Reference by Sonatype, Inc. at http://www.sonatype.com/books/mvnref-book/reference/.

Liferay provides Maven archetypes to help you build plugins of various types, including Liferay portlets, themes, hooks, layout templates, web plugins, and more. You can also install and deploy Liferay artifacts to your repositories. We’ll dive into all these topics in this chapter.

“Straight I wheeled a cushioned seat in front of computer desk once more; Then, upon the velvet falling, I betook to Maven installing…”

Installing Maven

You can download Maven from http://maven.apache.org/download.cgi. We recommend putting your Maven installation’s bin directory in your system’s path, so you can run the Maven executable (mvn)...

Read More

Using Maven repositories

Wouldn’t it be nice to install and deploy your Liferay artifacts to a repository? Great news! Maven lets you install your artifacts to your machine’s local repository and even deploy them to remote...

Read More

Installing Required Liferay Artifacts

To create Liferay plugins using Maven, you’ll need the archives required by Liferay (e.g., required JAR and WAR files). This won’t be problem–Liferay provides them as Maven artifacts. So how do you...

Read More

Using Liferay IDE with Maven

Wouldn’t it be nice if you could manage your Liferay Maven projects from Liferay IDE? You can! Liferay IDE 2.0 introduces the Maven project configurator (m2e-liferay), or the added support of...

Read More

Using a Parent Plugin Project

Maven supports project inheritance. You can create a parent project that contains properties child projects have in common, and child projects inherit those properties from the parent project. This...

Read More

Creating Liferay Plugins with Maven

Liferay offers many archetypes to help create Maven projects for multiple plugin types, including portlet, theme, hook, and layout template plugins. We provide archetypes for each of these plugin...

Read More

Deploying Liferay Plugins with Maven

With Maven it’s easy to deploy plugins to a Liferay Portal instance. Just follow these steps: Make sure your parent POM’s Liferay-specific properties specify the correct Liferay version and your...

Read More

Liferay Plugin Types to Develop with Maven

You can develop all Liferay plugin types with Maven: portlets, themes, layout templates, hooks, and Ext. Next, you’ll learn how to create each plugin type using Maven, and we’ll point out where...

Read More


“But the chair whose violet lining with the lamp-light gloating o’er, Lenore II shall press, ah, nevermore!” Lenore II didn’t make it through the chapter, but you did. You can develop all your...

Read More
0 (0 Votes)
Summary Previous