Uploaded image for project: 'Maven Surefire'
  1. Maven Surefire
  2. SUREFIRE-502

Specified classesDirectory is added to the end of the classpath

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.4.3
    • 2.5
    • classloading
    • None
    • Windows Vista SP1, Java 1.5.0_13, Maven 2.0.9
    • Patch

    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)

      { classpathElements.remove( project.getBuild().getOutputDirectory() ); classpathElements.add( replacementIndex, classesDirectory.getAbsolutePath() ); }

      else

      { classpathElements.add( classesDirectory.getAbsolutePath() ); }

      }

      Attachments

        1. SUREFIRE-502.patch
          1 kB
          James Shiell
        2. SurefirePlugin.java
          36 kB
          Markus Dahm

        Issue Links

          Activity

            People

              pgier Paul Gier
              jshiell James Shiell
              Votes:
              1 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: