private ClassLoader getClassLoader()
        throws MojoExecutionException
    {
        List<URL> classpathURLs = new ArrayList<URL>();
        this.addRelevantPluginDependenciesToClasspath( classpathURLs );
        this.addRelevantProjectDependenciesToClasspath( classpathURLs );
        this.addAdditionalClasspathElements( classpathURLs );
        
        if (outputDirectory.isDirectory()) {
        	// load compiled classes
        	Collection listFiles = FileUtils.listFiles(outputDirectory, new String[]{"class"}, true);
        	for (Object object : listFiles) {
        		if (object instanceof File) {
        			File f = (File) object;
        			if (f.isFile()) {
        				try {
        					classpathURLs.add(f.toURI().toURL());
        				} catch (Exception e) {
        					// TODO: handle exception
        				}
        			}
        		}
        	}
        }
        
        
        return new URLClassLoader( classpathURLs.toArray( new URL[classpathURLs.size()] ) , getClass().getClassLoader());
    }
private ClassLoader getClassLoader ( ) throws MojoExecutionException { List < URL > classpathURLs = new ArrayList < URL > ( ) ; this . addRelevantPluginDependenciesToClasspath ( classpathURLs ) ; this . addRelevantProjectDependenciesToClasspath ( classpathURLs ) ; this . addAdditionalClasspathElements ( classpathURLs ) ; if ( outputDirectory . isDirectory ( ) ) { Collection listFiles = FileUtils . listFiles ( outputDirectory , new String [ ] { "class" } , true ) ; for ( Object object : listFiles ) { if ( object instanceof File ) { File f = ( File ) object ; if ( f . isFile ( ) ) { try { classpathURLs . add ( f . toURI ( ) . toURL ( ) ) ; } catch ( Exception e ) { } } } } } return new URLClassLoader ( classpathURLs . toArray ( new URL [ classpathURLs . size ( ) ] ) , getClass ( ) . getClassLoader ( ) ) ; }
Set up a classloader for the execution of the main class.

@return the classloader
@throws MojoExecutionException if a problem happens