Details
-
Type:
Bug
-
Status:
Closed
-
Priority:
Major
-
Resolution: Fixed
-
Affects Version/s: 2.4.3
-
Fix Version/s: 2.5
-
Component/s: classloading
-
Labels:None
-
Environment:Windows Vista SP1, Java 1.5.0_13, Maven 2.0.9
-
Complexity:Intermediate
-
Patch Submitted:Yes
Description
When you specify a classesDirectory in the configuration element of the Surefire plugin definition the classesDirectory is appended to the end of the classpath rather than replacing the build output directory. This means included dependencies take precedence over your source code.
The problem appears to be the following code:
if ( !project.getBuild().getOutputDirectory().equals( classesDirectory.getAbsolutePath() ) )
{ classpathElements.remove( project.getBuild().getOutputDirectory() ); classpathElements.add( classesDirectory.getAbsolutePath() ); }The classes directory should replace the build output directory, e.g.
if ( !project.getBuild().getOutputDirectory().equals( classesDirectory.getAbsolutePath() ) )
{
final int replacementIndex = classpathElements.indexOf(project.getBuild().getOutputDirectory());
if (replacementIndex >= 0)
else
{ classpathElements.add( classesDirectory.getAbsolutePath() ); }}
Issue Links
- is duplicated by
-
SUREFIRE-504
own classes and test-classes at the end of test classpath
-
-
SUREFIRE-517
Invalid classpath order with classesDirectory and testClassesDirectory
-
- relates to
-
SUREFIRE-619
The surefire plugin should generate the test classpath
-
Patch with suggested fix.