title: Changing order of locations on classpath to be loaded up by surefire-plugin
body: <p>Does anybody know how to change it ?</p>
  
  <p>I mean from  </p>
  
  <pre><code>target/test-classes ... target/classes .... maven dependencies
  </code></pre>
  
  <p>to</p>
  
  <pre><code>target/test-classes ... maven dependencies .... target/classes 
  </code></pre>
  
  <p>It relates to this surefire-plugin <a href="http://jira.codehaus.org/browse/SUREFIRE-667" rel="nofollow">feature request</a> </p>
  
  <p>It's because surefire-plugin cannot include/exclude resources from /target/classes  ... it can only include/exlude resources via <code>&lt;testResources&gt;</code> element which can affect only /target/test-classes, not /target/classes</p>
  
  <p>It all happens here in Surefire-plugin :</p>
  
  <pre><code>File projectClassesDirectory = new File( project.getBuild().getOutputDirectory() );
  if ( !projectClassesDirectory.equals( classesDirectory ) )
  {
      int indexToReplace = classpathElements.indexOf( project.getBuild().getOutputDirectory() );
      if ( indexToReplace != -1 )
      {
          classpathElements.remove( indexToReplace );
          classpathElements.add( indexToReplace, classesDirectory.getAbsolutePath() );
      }
      else
      {
          classpathElements.add( 1, classesDirectory.getAbsolutePath() );
      }
  }
  
  File projectTestClassesDirectory = new File( project.getBuild().getTestOutputDirectory() );
  if ( !projectTestClassesDirectory.equals( testClassesDirectory ) )
  {
      int indexToReplace = classpathElements.indexOf( project.getBuild().getTestOutputDirectory() );
      if ( indexToReplace != -1 )
      {
          classpathElements.remove( indexToReplace );
          classpathElements.add( indexToReplace, testClassesDirectory.getAbsolutePath() );
      }
      else
      {
          classpathElements.add( 0, testClassesDirectory.getAbsolutePath() );
      }
  }
  
  getLog().debug( "Test Classpath :" );
  
  for ( Iterator i = classpathElements.iterator(); i.hasNext(); )
  {
      String classpathElement = (String) i.next();
  
      getLog().debug( "  " + classpathElement );
  
      surefireBooter.addClassPathUrl( classpathElement );
  }
  </code></pre>