Wed 10 Jun 2009
Maven2 for non-java build
Posted by yujin under technology
No Comments
At work I’ve been working with my coworkers on standardizing our build process. We are managing 20+ public sites, each consisting of several applications in different platforms. So the idea that I had developed was using war as any web application builds (and same could be said for jar for any non-web applications. After all, war/jar is just a formality and they are just nicely structured zip files.
So I’ve started building out what I ended up calling bundles - basically stock distribution of such php applications as wordpress, drupal, phpBB etc using the standard maven 2 suggested layout with a pom.xml in it.
Take Drupal as an example
- pom.xml
- src/main/webapp

The pom.xml would look 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>org.drupal.bundles</groupId>
<artifactId>drupal</artifactId>
<packaging>war</packaging>
<version>6.9</version>
</project>
….
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<dependentWarIncludes>**/*</dependentWarIncludes>
<overlays>
<overlay>
<groupId>org.drupal.bundles</groupId>
<artifactId>drupal</artifactId>
<targetPath>drupal</targetPath>
</overlay>
</overlays>
</configuration>
</plugin><dependencies>
<dependency>
<groupId>org.drupal.bundles</groupId>
<artifactId>drupal</artifactId>
<version>6.9</version>
<type>war</type>
</dependency>
</dependencies>
…
Using this structure, you can put your own customization to the stock drupal code in your own maven2 project, while keeping the original source code in tact, hence giving you a easier way to manage base version upgrades etc.
Another added benefit to this is you can utilize zillions of maven2 plugins out there, including eclipse plugin to make your php app accessible in your eclipse. The most useful plugin is you can use Caucho’s resin plugin, allowing you to run your php application using quercus without needing any apache/php set up for your development environment.
