Managing dependencies with maven

Maven is a nice build tool helper for java projects. A cool feature is the way to specify if some dependencies are

  1. necessaries at runtime
  2. provided by the application server
  3. necessaries while doing tests but not at deploy time

That’s an example in my pom.xml:

<!– I need to embed javamail in my package –>

<dependency>
<groupId>javax.mail</groupId>
<artifactId>mail</artifactId>
<version>1.4</version>
</dependency>

<!– while Log4j is provided by the application server –>

<dependency>
<artifactId>log4j</artifactId>
<groupId>log4j</groupId>
<version>1.2.14</version>
<scope>provided</scope>
</dependency>
<!– and  Hypersonic Database is used for testing–>
<dependency>
<groupId>hsqldb</groupId>
<artifactId>hsqldb</artifactId>
<version>1.8.0.1</version>
<scope>test</scope>
</dependency>