SurefirePlugin#constructSurefireBooter changes the classpath by doing:

...
        getLog().debug( "Test Classpath :" );

        // Check if we need to add configured classes/test classes 
directories here.
        // If they are configured, we should remove the default to avoid 
conflicts.
        if ( !project.getBuild().getOutputDirectory().equals( 
classesDirectory.getAbsolutePath() ) )
        {
            classpathElements.remove( project
.getBuild().getOutputDirectory() );
            classpathElements.add( classesDirectory.getAbsolutePath() );
        }
        if ( !project.getBuild().getTestOutputDirectory().equals( 
testClassesDirectory.getAbsolutePath() ) )
        {
            classpathElements.remove( project
.getBuild().getTestOutputDirectory() );
            classpathElements.add( testClassesDirectory.getAbsolutePath() 
);
        }
...

project.getBuild().getOutputDirectory() is "
S:\pdv_cms\GDCAMS\src\pip\gdcams-pip-itest/target/classes"
classesDirectory.getAbsolutePath() is: "
S:\pdv_cms\GDCAMS\src\pip\gdcams-pip-itest\target\classes"

So i think here a 2 bugs:

(1) files/directories shouldn´t be compared just as String.equals(....)
(2) an Element of classpathElements shouldn´t be removed and added to the 
end of the list, it should be replaced.


I´ll file a bug to that issue and temporary fix my 
<outputDirectory>${project.basedir}/${target.dir}/classes</outputDirectory> 
to use \\ instead of /

have fun, 

Torsten





[EMAIL PROTECTED] 
17.07.2008 10:43
Bitte antworten an
"Maven Users List" <users@maven.apache.org>


An
users@maven.apache.org
Kopie

Thema
own classes and test-classes at the end of test classpath running 
surefire-2.4






Hi, 

if I´m running JUnit Tests with Surefire-2.4 I got the following 
classpath:

[DEBUG] Adding managed dependencies for unknown:surefire-junit4
[DEBUG]   org.apache.maven.surefire:surefire-api:jar:2.4
[DEBUG]   org.apache.maven.surefire:surefire-booter:jar:2.4
[DEBUG]   org.codehaus.plexus:plexus-utils:jar:1.4.9
[DEBUG]   org.apache.maven.surefire:surefire-junit4:jar:2.4:test (selected 

for test)
[DEBUG]     junit:junit:jar:4.0:test (selected for test)
[DEBUG]     org.apache.maven.surefire:surefire-api:jar:2.4:test (selected 
for test)
[DEBUG] Adding to surefire test classpath: 
s:\mavenrepo\org\apache\maven\surefire\surefire-junit4\2.4\surefire-junit4-2.4.jar
[DEBUG] Adding to surefire test classpath: 
s:\mavenrepo\junit\junit\4.0\junit-4.0.jar
[DEBUG] Adding to surefire test classpath: 
s:\mavenrepo\org\apache\maven\surefire\surefire-api\2.4\surefire-api-2.4.jar
[DEBUG] Test Classpath :
[DEBUG]   s:\mavenrepo\log4j\log4j\1.2.13\log4j-1.2.13.jar
[DEBUG]   s:\mavenrepo\javax\xml\ws\jaxws-api\2.1\jaxws-api-2.1.jar
[DEBUG]   s:\mavenrepo\javax\xml\bind\jaxb-api\2.1\jaxb-api-2.1.jar
...
...
[DEBUG]   s:\mavenrepo\org\objectstyle\ashwood\ashwood\1.1\ashwood-1.1.jar
[DEBUG] 
s:\mavenrepo\com\gide\gdcams\pip\gdcams-pip-srv-common\2.7.1-SNAPSHOT\gdcams-pip-srv-common-2.7.1-SNAPSHOT-tests.jar
[DEBUG] 
s:\mavenrepo\com\gide\gdcams\pip\gdcams-pip-server-ts\2.7.1-SNAPSHOT\gdcams-pip-server-ts-2.7.1-SNAPSHOT.jar
[DEBUG]   s:\mavenrepo\org\apache\xmlsec\1.4.1\xmlsec-1.4.1.jar
[DEBUG]   S:\pdv_cms\GDCAMS\src\pip\gdcams-pip-itest\target\classes
[DEBUG]   S:\pdv_cms\GDCAMS\src\pip\gdcams-pip-itest\target\test-classes

As you can see, the classes and test-classes are at the end of the "test 
classpath", which now causes some problems.

The only thing I changed was the following snippet, added to my own parent 

pom.xml:

        <properties> 
          <target.dir>target</target.dir>
        </properties> 

        <build>
                ....
                <!-- special (output)Directory for Eclipse -->
                <!-- see 
http://docs.codehaus.org/display/M2ECLIPSE/Project+FAQ#ProjectFAQ-HowtoconfigureMavenprojecttouseseparateoutputfoldersinEclipse--
>
 
<outputDirectory>${project.basedir}/${target.dir}/classes</outputDirectory>
 
<testOutputDirectory>${project.basedir}/${target.dir}/test-classes</testOutputDirectory>
 


                ....
        </build>

<profiles>
    <profile>
      <id>eclipse-folders</id>
      <properties>
        <target.dir>target-eclipse</target.dir>
      </properties>
    </profile>
</profiles>

Any idea, what´s going wrong here ?
Why are the classes and test-classes added to the end of the classpath ?


thanx, Torsten



Reply via email to