public PipelineStageBeans duplicatePipelineStageBeans(
    StageLibraryTask stageLib,
    PipelineStageBeans pipelineStageBeans,
    InterceptorCreatorContextBuilder interceptorCreatorContextBuilder,
    Map<String, Object> constants,
    List<Issue> errors
  ) {
    List<StageBean> stageBeans = new ArrayList<>(pipelineStageBeans.size());


    for(StageBean original: pipelineStageBeans.getStages()) {

      // Create StageDefinition map for this stage
      Map<Class, ServiceDefinition> services = original.getServices().stream()
        .collect(Collectors.toMap(c -> c.getDefinition().getProvides(), ServiceBean::getDefinition));

      StageBean stageBean = createStage(
          stageLib,
          original.getDefinition(),
          ClassLoaderReleaser.NOOP_RELEASER,
          original.getConfiguration(),
          services::get,
          interceptorCreatorContextBuilder,
          constants,
          errors
      );

      if (stageBean != null) {
        stageBeans.add(stageBean);
      }
    }

    return new PipelineStageBeans(stageBeans);
  }
public PipelineStageBeans duplicatePipelineStageBeans ( StageLibraryTask stageLib , PipelineStageBeans pipelineStageBeans , InterceptorCreatorContextBuilder interceptorCreatorContextBuilder , Map < String , Object > constants , List < Issue > errors ) { List < StageBean > stageBeans = new ArrayList < > ( pipelineStageBeans . size ( ) ) ; for ( StageBean original : pipelineStageBeans . getStages ( ) ) { Map < Class , ServiceDefinition > services = original . getServices ( ) . stream ( ) . collect ( Collectors . toMap ( c -> c . getDefinition ( ) . getProvides ( ) , ServiceBean :: getDefinition ) ) ; StageBean stageBean = createStage ( stageLib , original . getDefinition ( ) , ClassLoaderReleaser . NOOP_RELEASER , original . getConfiguration ( ) , services :: get , interceptorCreatorContextBuilder , constants , errors ) ; if ( stageBean != null ) { stageBeans . add ( stageBean ) ; } } return new PipelineStageBeans ( stageBeans ) ; }
Creates additional PipelineStageBeans for additional runners. Stages will share stage definition and thus
class loader with the first given runner. That includes stages with private class loader as well.

@param pipelineStageBeans First runner that should be duplicated.
@param interceptorCreatorContextBuilder Builder for interceptor context
@param constants Pipeline constants
@param errors Any generated errors will be stored in this list

@return PipelineStageBeans with new instances of the given stages