Maven build script for compiling and deploying portlet on the Apache Pluto

Apache Pluto is reference implementation of the JSR 286 specification. You can think about it as Apache Tomcat of the portal world.

Recently i did install Pluto 2.0 on my machine which is very simple all you have to do is download Pluto and extract it in say c:/software folder. After doing that you can go in c:/software/pluto2.0.0/bin directory and execute catalina.bat start. Once the server is started you can access it http://localhost:8080/pluto/portal using tomcat + tomcat as user id and password.


What i like most about pluto is that it can work with small memory and you can restart it in less than few seconds. Other advantage of using Pluto is you can use a maven script like this and when you execute mvn integration-test it will deploy the portlet on your pluto server, you will have to add it to page using its admin UI but once that is done you can update your portlet by executing mvn integration-test and the new code will be deployed and ready for testing.

I like to use Pluto for building small sample portlets which are JSR 286 compliant and does not need any IBM WebSphere specific features, once the portlet development is done is verified on pluto i deploy it on WebSphere Portal


<?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">

<!-- Change this to something akin to your java package structure -->
<groupId>com.webspherenotes.portlet</groupId>
<modelVersion>4.0.0</modelVersion>
<version>1.0</version>
<artifactId>HelloWorldPortlet</artifactId>
<packaging>war</packaging>
<name>${pom.artifactId}</name>
<!-- Dependency Version Properties ======================================= -->
<properties>
<pluto.version>2.0.0</pluto.version>
<portlet-api.version>2.0</portlet-api.version>
<servlet-api.version>2.4</servlet-api.version>
<jsp-api.version>2.0</jsp-api.version>
<junit.version>3.8.1</junit.version>
<pluto.home>C:/software/pluto-2.0.0</pluto.home>

</properties>
<dependencies>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<version>${portlet-api.version}</version>
<scope>provided</scope><!-- Prevents addition to war file -->
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<version>${servlet-api.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.portals.pluto</groupId>
<artifactId>pluto-util</artifactId>
<version>${pluto.version}</version>
<scope>provided</scope>
</dependency>

</dependencies>
<build>
<finalName>${pom.name}</finalName>
<plugins>

<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<phase>integration-test</phase>
<configuration>
<tasks>
<property environment="env"/>
<!-- This assumes that you have set a CATALINA_HOME environmental variable
<property name="pluto.home" value="C:/software/pluto-2.0.0"/>-->
<copy file="target/${pom.name}.war" todir="${pluto.home}/webapps"/>
</tasks>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- configure to use Java 6 to compile (change to your JDK) -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<!-- configure maven-war-plugin to use updated web.xml -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<webXml>${project.build.directory}/pluto-resources/web.xml</webXml>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.portals.pluto</groupId>
<artifactId>maven-pluto-plugin</artifactId>
<version>${pluto.version}</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>assemble</goal>
</goals>
</execution>
</executions>
</plugin>


</plugins>
</build>

</project>


Before we use this maven script create a .xml file like this in the META-INF folder of your web app and dont forget to use directory structure used by Maven for structuring your code

<?xml version="1.0" encoding="UTF-8"?>
<Context path="/HelloWorld" docBase="HelloWorld" crossContext="true"/>