private ClassLoader expandClasspath ( ExtendedEmailPublisherContext context , ClassLoader loader ) throws IOException { List < ClasspathEntry > classpathList = new ArrayList <> ( ) ; if ( classpath != null && ! classpath . isEmpty ( ) ) { transformToClasspathEntries ( classpath , context , classpathList ) ; } List < GroovyScriptPath > globalClasspath = getDescriptor ( ) . getDefaultClasspath ( ) ; if ( globalClasspath != null && ! globalClasspath . isEmpty ( ) ) { transformToClasspathEntries ( globalClasspath , context , classpathList ) ; } boolean useSecurity = Jenkins . getActiveInstance ( ) . isUseSecurity ( ) ; if ( ! classpathList . isEmpty ( ) ) { GroovyClassLoader gloader = new GroovyClassLoader ( loader ) ; gloader . setShouldRecompile ( true ) ; for ( ClasspathEntry entry : classpathList ) { if ( useSecurity ) { ScriptApproval . get ( ) . using ( entry ) ; } gloader . addURL ( entry . getURL ( ) ) ; } loader = gloader ; } if ( useSecurity ) { return GroovySandbox . createSecureClassLoader ( loader ) ; } else { return loader ; } }
Expand the plugin class loader with URL taken from the project descriptor and the global configuration .