private void configureAdditionalClasspath ( final ClassRealm realm ) { log . debug ( "Configuring additional classpath with scope: {}" , classpathScope ) ; List < File > classpath = Lists . newArrayList ( ) ; // add build output directory if scope includes 'compile' if ( classpathScope . matches ( compile ) ) { classpath . add ( new File ( project . getBuild ( ) . getOutputDirectory ( ) ) ) ; } // add build test output directory if scope includes 'test' if ( classpathScope . matches ( test ) ) { classpath . add ( new File ( project . getBuild ( ) . getTestOutputDirectory ( ) ) ) ; } // add matching project dependency artifacts if ( ! project . getArtifacts ( ) . isEmpty ( ) ) { for ( Artifact artifact : project . getArtifacts ( ) ) { if ( classpathScope . matches ( artifact . getScope ( ) ) ) { File file = artifact . getFile ( ) ; if ( ! file . exists ( ) ) { // for sanity, this should not really ever happen log . warn ( "Artifact not resolved; ignoring: {}" , artifact ) ; continue ; } classpath . add ( file ) ; } } } if ( ! classpath . isEmpty ( ) ) { log . debug ( "Additional classpath:" ) ; for ( File file : classpath ) { log . debug ( " {}" , file ) ; try { realm . addURL ( file . toURI ( ) . toURL ( ) ) ; } catch ( MalformedURLException e ) { throw Throwables . propagate ( e ) ; } } } }
Configure additional classpath elements for the runtime realm .