| <html><head><META http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Automated Build Highlights</title><meta content="DocBook XSL Stylesheets V1.76.0" name="generator"><link rel="home" href="index.html" title="A Guide to the GreenPages Sample"><link rel="up" href="ch03.html" title="Chapter 3. GreenPages Highlights"><link rel="prev" href="ch03s03.html" title="Testing Highlights"><link rel="next" href="apa.html" title="Appendix A. Further Resources"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table summary="Navigation header" width="100%"><tr><td align="left" width="20%"><a accesskey="p" href="ch03s03.html">Prev</a> </td><th align="center" width="60%"> </th><td align="right" width="20%"> <a accesskey="n" href="apa.html">Next</a></td></tr></table><hr></div><div class="section" title="Automated Build Highlights"><div class="titlepage"><div><div><h2 class="title" style="clear: both"><a name="highlights.automated.build"></a>Automated Build Highlights</h2></div></div></div><p> |
| Another important aspect of application development is automated build. This permits |
| application artifacts to be created outside of the developer’s IDE. The application can then be |
| created and tested in a variety of environments, including continuous integration servers. |
| </p><div class="section" title="Building the PAR"><div class="titlepage"><div><div><h3 class="title"><a name="N10642"></a>Building the PAR</h3></div></div></div><p> |
| All of the GreenPages projects have Maven POM files for building. |
| The PAR is built using the file <code class="filename">pom.xml</code> in the <code class="literal">greenpages</code> folder. |
| This file defines a parent POM and a packaging type of <code class="literal">par</code>: |
| </p><pre class="programlisting"><parent> |
| <groupId>org.eclipse.virgo</groupId> |
| <artifactId>greenpages.parent</artifactId> |
| <version>2.4.0.RELEASE</version> |
| <relativePath>../greenpages.parent</relativePath> |
| </parent> |
| |
| <modelVersion>4.0.0</modelVersion> |
| <groupId>org.eclipse.virgo</groupId> |
| <artifactId>greenpages</artifactId> |
| <name>GreenPages PAR</name> |
| <description>GreenPages PAR</description> |
| <packaging>par</packaging> |
| </pre><p> |
| </p><p> |
| Thorsten Maus created a Maven plugin (see <a class="xref" href="apas02.html" title="Documentation">Documentation</a>) |
| that builds a PAR file from a list of dependencies. |
| The file <code class="filename">pom.xml</code> lists those dependencies: |
| </p><pre class="programlisting"><dependencies> |
| <dependency> |
| <groupId>org.eclipse.virgo</groupId> |
| <artifactId>greenpages.app</artifactId> |
| <version>${project.version}</version> |
| </dependency> |
| <dependency> |
| <groupId>org.eclipse.virgo</groupId> |
| <artifactId>greenpages.jpa</artifactId> |
| <version>${project.version}</version> |
| </dependency> |
| <dependency> |
| <groupId>org.eclipse.virgo</groupId> |
| <artifactId>greenpages.db</artifactId> |
| <version>${project.version}</version> |
| </dependency> |
| <dependency> |
| <groupId>org.eclipse.virgo</groupId> |
| <artifactId>greenpages.web</artifactId> |
| <version>${project.version}</version> |
| <type>war</type> |
| </dependency> |
| <dependency> |
| <groupId>org.freemarker</groupId> |
| <artifactId>com.springsource.freemarker</artifactId> |
| <scope>provided</scope> |
| </dependency> |
| </dependencies> |
| </pre><p> |
| The freemarker dependency is required to ensure the Web Application Bundle has the correct set of dependencies. |
| Most dependencies are resolved |
| transitively from the bundle projects, but the ‘war’ project does not pass on its dependencies; |
| it expects |
| them to be contained in its <code class="literal">lib</code> directory. |
| </p><p> |
| The <code class="literal"><build><plugins>???</code> section contains a declaration for the |
| <code class="literal">par</code> plugin and configuration of the application symbolic name of the PAR: |
| </p><pre class="programlisting"><plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-par-plugin</artifactId> |
| <version>1.0.0.RELEASE</version> |
| <configuration> |
| <applicationSymbolicName>greenpages</applicationSymbolicName> |
| </configuration> |
| </plugin> |
| </pre><p> |
| </p></div><div class="section" title="Obtaining Dependencies"><div class="titlepage"><div><div><h3 class="title"><a name="N10679"></a>Obtaining Dependencies</h3></div></div></div><p> |
| The Maven <code class="literal">dependency</code> plugin is used to collect the transitive dependency graph for the PAR. |
| </p><p> |
| The <code class="literal"><build><plugins>???</code> section |
| has a declaration for the <code class="literal">dependency</code> plugin: |
| </p><pre class="programlisting"><plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-dependency-plugin</artifactId> |
| <executions> |
| <execution> |
| <id>copy-dependencies</id> |
| <phase>package</phase> |
| <goals> |
| <goal>copy-dependencies</goal> |
| </goals> |
| <configuration> |
| <outputDirectory>${project.build.directory}/par-provided</outputDirectory> |
| <overWriteIfNewer>true</overWriteIfNewer> |
| <excludeGroupIds>org.eclipse.virgo,org.apache.log4j</excludeGroupIds> |
| </configuration> |
| </execution> |
| </executions> |
| </plugin> |
| </pre><p> |
| </p><p> |
| The WAB must be prevented from having its dependencies included in a <code class="literal">lib</code> directory as they should be provided |
| by the runtime enviroment. The <code class="literal">greenpages.web</code> POM file contains the following: |
| </p><pre class="programlisting"><build> |
| <plugins> |
| <plugin> |
| <artifactId>maven-war-plugin</artifactId> |
| <version>2.1-beta-1</version> |
| <configuration> |
| <packagingExcludes>WEB-INF/lib/**</packagingExcludes> |
| </configuration> |
| </plugin> |
| </plugins> |
| </build></pre><p> |
| </p></div><div class="section" title="Automatically Running the Tests"><div class="titlepage"><div><div><h3 class="title"><a name="N106A0"></a>Automatically Running the Tests</h3></div></div></div><p> |
| The following plug-in entry in the <code class="literal">pom.xml</code> file in the <code class="literal">parent</code> |
| directory ensure that the concrete test classes are run as part of the build: |
| </p><pre class="programlisting"><plugin> |
| <groupId>org.apache.maven.plugins</groupId> |
| <artifactId>maven-surefire-plugin</artifactId> |
| <configuration> |
| <includes> |
| <include>**/*Tests.java</include> |
| </includes> |
| <excludes> |
| <exclude>**/Abstract*.java</exclude> |
| </excludes> |
| <junitArtifactName>org.junit:com.springsource.org.junit</junitArtifactName> |
| <argLine>-javaagent:${user.home}/.m2/repository/???</argLine> |
| </configuration> |
| </plugin> |
| </pre><p> |
| The location of the user's Maven repository is hard-coded. |
| </p></div></div><div class="navfooter"><hr><table summary="Navigation footer" width="100%"><tr><td align="left" width="40%"><a accesskey="p" href="ch03s03.html">Prev</a> </td><td align="center" width="20%"><a accesskey="u" href="ch03.html">Up</a></td><td align="right" width="40%"> <a accesskey="n" href="apa.html">Next</a></td></tr><tr><td valign="top" align="left" width="40%"> </td><td align="center" width="20%"><a accesskey="h" href="index.html">Home</a></td><td valign="top" align="right" width="40%"> </td></tr></table></div></body></html> |