2
Configuring the Classpath
9
~~ Licensed to the Apache Software Foundation (ASF) under one
10
~~ or more contributor license agreements. See the NOTICE file
11
~~ distributed with this work for additional information
12
~~ regarding copyright ownership. The ASF licenses this file
13
~~ to you under the Apache License, Version 2.0 (the
14
~~ "License"); you may not use this file except in compliance
15
~~ with the License. You may obtain a copy of the License at
17
~~ http://www.apache.org/licenses/LICENSE-2.0
19
~~ Unless required by applicable law or agreed to in writing,
20
~~ software distributed under the License is distributed on an
21
~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
22
~~ KIND, either express or implied. See the License for the
23
~~ specific language governing permissions and limitations
26
~~ NOTE: For help with the syntax of this file, see:
27
~~ http://maven.apache.org/doxia/references/apt-format.html
31
The surefire plugin builds the test classpath in the following order:
33
#{if}(${project.artifactId}=="maven-surefire-plugin")
34
[[1]] The {{{../test-mojo.html#testClassesDirectory}test-classes}} directory
36
[[2]] The {{{../test-mojo.html#classesDirectory}classes}} directory
39
[[1]] The {{{../integration-test-mojo.html#testClassesDirectory}test-classes}} directory
41
[[2]] The {{{../integration-test-mojo.html#classesDirectory}classes}} directory
44
[[3]] The project dependencies
46
[[4]] Additional classpath elements
48
Additional Classpath Elements
50
If you need to put more stuff in your classpath when ${thisPlugin} executes (e.g some funky resources or a container specific JAR),
51
we normally recommend you add it to your classpath as a dependency. Consider deploying shared jars to a private remote repository for your
54
But, if you must, you can use the <<<additionalClasspathElements>>> element to add custom resources/jars to your classpath.
55
This will be treated as an absolute file system path, so you may want use $\{basedir\} or another property combined with a relative path.
56
Note that additional classpath elements are added to the end of the classpath, so you cannot use these to
57
override project dependencies or resources.
65
<groupId>${project.groupId}</groupId>
66
<artifactId>${project.artifactId}</artifactId>
67
<version>${project.version}</version>
69
<additionalClasspathElements>
70
<additionalClasspathElement>path/to/additional/resources</additionalClasspathElement>
71
<additionalClasspathElement>path/to/additional/jar</additionalClasspathElement>
72
</additionalClasspathElements>
81
Removing Dependency Classpath Elements
83
Dependencies can be removed from the test classpath using the parameters <<<classpathDependencyExcludes>>> and
84
<<<classpathDependencyScopeExclude>>>. A list of specific dependencies can be removed from the
85
classpath by specifying the groupId:artifactId to be removed.
93
<groupId>${project.groupId}</groupId>
94
<artifactId>${project.artifactId}</artifactId>
95
<version>${project.version}</version>
97
<classpathDependencyExcludes>
98
<classpathDependencyExcludes>org.apache.commons:commons-email</classpathDependencyExcludes>
99
</classpathDependencyExcludes>
108
Dependencies under a certain scope can be removed from the classpath using
109
<<<classpathDependencyScopeExclude>>>. The valid values for the dependency scope
110
exclude are defined by <<<org.apache.maven.artifact.resolver.filter.ScopeArtifactFilter>>>.
112
* <<compile>> - system, provided, compile
114
* <<runtime>> - compile, runtime
116
* <<test>> - system, provided, compile, runtime, test
124
<groupId>${project.groupId}</groupId>
125
<artifactId>${project.artifactId}</artifactId>
126
<version>${project.version}</version>
128
<classpathDependencyScopeExclude>runtime</classpathDependencyScopeExclude>