Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The other possible addition to the parent POM files is specifying build properties that are common to all the modules, for example JDK settings, etc. This will be described later.

You do not have to memorize this directory structure. Most of the time you can use Maven archetypes to create prototypes for particular type of Maven 2 project. See bellow section on using archetypes.

2.    Maven 2 project file pom.xml

...

Code Block
titlepom.xml
<?xml version="1.0" encoding="UTF-8"?>

<!--
Maven 2 is shortly identified as maven. If we want to give a reference to Maven 1.0.2 we will call Maven 1.
This POM extends SuperPOM, which means that the following elements are already defined:
maven central repository (http://repo1.maven.org/maven2)
maven plugin repository  (http://repo1.maven.org/maven2)

default build directories:

  target
  target/classes
  target/test-classes
  target/site
  src/main/java
  src/test/java
  src/main/scripts
  src/main/resources
  src/test/resources


as well as default profiles: release-profile

and default plugins:
	maven-source-plugin
	maven-javadoc-plugin
	maven-deploy-plugin

-->
<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>
	<artifactId>org-glast-groupmanager</artifactId>
	<groupId>glast</groupId>
	<version>1.6-SNAPSHOT</version>
	<description>Glast Group Manager</description>
	<url>http://glast-ground.slac.stanford.edu/GroupManager/</url>
	<name>Glast Group Manager</name>
	<inceptionYear>2005</inceptionYear>
 	<repositories>
		<!-- Not yet defined -->
	</repositories>
  	<scm>
		<developerConnection>
			scm:cvs:ext:${maven.username}@glast   java.slac.stanford.edu:/cvs/java:${pom.artifactId}  <!-- to be verified -->
                </developerConnection>
         </scm>
         <dependencies>
		<!-- dependencies here -->
		<dependency>
      			<groupId>tomcat</groupId>
      			<artifactId>servlet-api</artifactId>
      			<version>5.0.18</version>
    		</dependency>
		<!-- ... -->
		<!-- Needed by cruisecontrol -->
		<dependency>
      			<groupId>maven</groupId>
      			<artifactId>maven-scm-plugin</artifactId>
      			<version>1.5</version>
      			<type>plugin</type>
   		 </dependency>
	</dependencies>
	<build>
   		 <resources>
     			 <resource>
			<directory>src/main/resource</directory> <!-- should have been resources -->
			<includes>
	  			<include>META-INF/*.tld</include>
			</includes>
      		</resource>
    </resources>
  </build>
</project>

scope tag

The new element that has been introduced in dependencies is the scope tag. It describes what the dependency
is used for, how to find the dependency, and when it should be included in the classpath.
There are five options for scope:

  • compile: This is the default scope (for example, the struts2-core artifact uses this scope because no
    other was provided), and these dependencies are available on all classpaths. Any
    dependency with compile scope will be packaged with the final artifact.
  • provided: The dependency will be provided by the JDK or the application server at runtime.
    It is required for compilation but will not be packaged in the application.
  • runtime: The dependency is not required for compilation but is required to run the
    application. It will be available only on the runtime classpath and the test classpath.
  • test: The dependency is only required for testing and will be available on the test classpath
    and the runtime classpath.
  • system: The dependency is always available (you need to provide the JAR file) and is not
    retrieved via a repository lookup.

4. profiles.xml file

If we run mvn install target with this POM file, it will still not build completely as we need to locate dependencies that are not found in the parent POM central repositories (modules and plugins): http://repo1.maven.org/maven2

...