How do I build my project?
Author: Deron Eriksson
Description: This tutorial describes how to build a maven project.
Tutorial created using: Windows Vista || JDK 1.6.0_04 || Eclipse Web Tools Platform 2.0.1 (Eclipse 3.3.1)


Page:    1 2 >

A mavenSW project can be built using the "mvn package" command:

mvn package

As a result, if you're in your project's root directory (that contains your pom.xml file), you can type "mvn package" to build the project. In this tutorial, we'll create an EclipseSW External Tool Configuration to perform the package command on a selected project to build the project via Eclipse.

In other tutorials, we created a default maven project using the "archetype:create" goal and we imported this project into Eclipse. This "mytest" project is shown below.

'mytest' project in Navigator View

The type of package (or "artifact") that is built is specified in a project's pom.xml file by the "packaging" element. The "mytest" project's packaging is specified to be "jar", so a jarW (Java archive) file will be built in response to the "package" goal.

pom.xml

<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>com.maventest</groupId>
  <artifactId>mytest</artifactId>
  <packaging>jar</packaging>
  <version>1.0-SNAPSHOT</version>
  <name>mytest</name>
  <url>http://maven.apache.org</url>
  <dependencies>
    <dependency>
      <groupId>junit</groupId>
      <artifactId>junit</artifactId>
      <version>3.8.1</version>
      <scope>test</scope>
    </dependency>
  </dependencies>
</project>

Here, I create an External Tool Configuration called "mvn package". This will allow us to select a project in the Eclipse Navigator view and then run the External Tool Configuration to perform the maven package command.

External Tool Configuration for 'mvn package'

I selected the "mytest" project and then brought up the "mvn package" external tool. I clicked Run.

Executing 'mvn package' on 'mytest' project via External Tool Configuration

(Continued on page 2)

Page:    1 2 >