  ------
  Configuring the Classpath
  ------
  Pascal Lambert
  ------
  2010-01-09
  ------
  
 ~~ Licensed to the Apache Software Foundation (ASF) under one
 ~~ or more contributor license agreements.  See the NOTICE file
 ~~ distributed with this work for additional information
 ~~ regarding copyright ownership.  The ASF licenses this file
 ~~ to you under the Apache License, Version 2.0 (the
 ~~ "License"); you may not use this file except in compliance
 ~~ with the License.  You may obtain a copy of the License at
 ~~
 ~~   http://www.apache.org/licenses/LICENSE-2.0
 ~~
 ~~ Unless required by applicable law or agreed to in writing,
 ~~ software distributed under the License is distributed on an
 ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 ~~ KIND, either express or implied.  See the License for the
 ~~ specific language governing permissions and limitations
 ~~ under the License.

 ~~ NOTE: For help with the syntax of this file, see:
 ~~ http://maven.apache.org/doxia/references/apt-format.html

The Default Classpath

  The Surefire plugin builds the test classpath in the following order:

#{if}(${project.artifactId}=="maven-surefire-plugin")
  [[1]] The {{{../test-mojo.html#testClassesDirectory}test-classes}} directory

  [[2]] The {{{../test-mojo.html#classesDirectory}classes}} directory

#{else}
  [[1]] The {{{../integration-test-mojo.html#testClassesDirectory}test-classes}} directory

  [[2]] The {{{../integration-test-mojo.html#classesDirectory}classes}} JAR file or directory

#{end}
  [[3]] The project dependencies

  [[4]] Additional classpath elements


#{if}(${project.artifactId}=="maven-failsafe-plugin")
  Notice that loading JAR file is preferable over the output classes directory in the maven-failsafe-plugin.
  This behavior can be changed by configuration parameter <<<classesDirectory>>>.
#{end}


Additional Classpath Elements

  If you need to put more stuff in your classpath when ${thisPlugin} executes (e.g some funky resources or a container specific JAR),
  we normally recommend you add it to your classpath as a dependency.  Consider deploying shared JARs to a private remote repository for your
  organization.

  But, if you must, you can use the <<<additionalClasspathElements>>> element to add custom resources/JARs to your classpath.
  This will be treated as an absolute file system path, so you may want use $\{basedir\} or another property combined with a relative path.
  Note that additional classpath elements are added to the end of the classpath, so you cannot use these to
  override project dependencies or resources.

+---+
<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <configuration>
          <additionalClasspathElements>
            <additionalClasspathElement>path/to/additional/resources</additionalClasspathElement>
            <additionalClasspathElement>path/to/additional/jar</additionalClasspathElement>
            <additionalClasspathElement>path/to/csv/jar1, path/to/csv/jar2</additionalClasspathElement>
          </additionalClasspathElements>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
+---+

Removing Dependency Classpath Elements

  Dependencies can be removed from the test classpath using the parameters <<<classpathDependencyExcludes>>> and
  <<<classpathDependencyScopeExclude>>>.  A list of specific dependencies can be removed from the
  classpath by specifying the <<<groupId:artifactId>>> to be removed.

+---+
<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <configuration>
          <classpathDependencyExcludes>
            <classpathDependencyExclude>org.apache.commons:commons-email</classpathDependencyExclude>
          </classpathDependencyExcludes>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
+---+

  Dependencies under a certain scope can be removed from the classpath using
  <<<classpathDependencyScopeExclude>>>.  The valid values for the dependency scope
  exclude are defined by <<<org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter>>>.

  * <<compile>> - system, provided, compile

  * <<runtime>> - compile, runtime

  * <<test>> - system, provided, compile, runtime, test

+---+
<project>
  [...]
  <build>
    <plugins>
      <plugin>
        <groupId>${project.groupId}</groupId>
        <artifactId>${project.artifactId}</artifactId>
        <version>${project.version}</version>
        <configuration>
          <classpathDependencyScopeExclude>runtime</classpathDependencyScopeExclude>
        </configuration>
      </plugin>
    </plugins>
  </build>
  [...]
</project>
+---+
