Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 2.0.2
-
Fix Version/s: None
-
Labels:None
-
Number of attachments :
Description
When executing compiler:testCompile, all runtime dependencies are added to the classpath to compile the test source code. This is contrary to the purpose of the runtime scope, which is simply to include the dependency when running the code, not compiling.
Here is what Maven's website[1] says about the runtime scope:
"this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath."
...And here is what Better Builds with Maven says about the runtime scope:
"This is because, in this situation, the (runtime) dependency is used only for packaging, not for compilation. In fact, if the dependency were required for compilation, for stability it would always be declared in the current POM as a dependency - regardless of whether another dependency introduces it." - page 65
"Check that the scope of your dependencies are set correctly (to test if only used for unit tests, or runtime if it is needed to bundle with or run the application but not for compiling your source code)." - page 204
[1] http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html
[2] http://www.devzuz.com/web/guest/products/resources#BBWM
If you check http://maven.apache.org/developers/mojo-api-specification.html#The_Descriptor_and_Annotations and see the options for requiresDependencyResolution you'll see the problem: There's no requiredClassPath value just for just test-compilation. The test-value is used for executing tests and for that reason all dependencies are selected.