bootstrap/src/main/java/com/streamsets/pipeline/BootstrapMain.java
public static Map<String, List<URL>> getStageLibrariesClasspaths(String stageLibrariesDir, String librariesExtraDir,
      final Set<String> stageLibs, String libsCommonLibDir) throws Exception {
    Map<String, List<URL>> map = new LinkedHashMap<String, List<URL>>();

    File baseDir = new File(stageLibrariesDir).getAbsoluteFile();
    if (baseDir.exists()) {
      File[] libDirs = baseDir.listFiles(createStageLibFilter(stageLibs));
      StringBuilder commonLibJars = new StringBuilder();
      if (libsCommonLibDir != null) {
        commonLibJars.append(new File(libsCommonLibDir).getAbsolutePath()).append(FILE_SEPARATOR).append(JARS_WILDCARD).
            append(CLASSPATH_SEPARATOR);
      }
      for (File libDir : libDirs) {
        File jarsDir = new File(libDir, STAGE_LIB_JARS_DIR);
        File etc = new File(libDir, STAGE_LIB_CONF_DIR);
        if (!jarsDir.exists()) {
          throw new IllegalArgumentException(String.format(MISSING_STAGE_LIB_JARS_DIR_MSG, libDir));
        }
        StringBuilder sb = new StringBuilder();
        if (etc.exists()) {
          sb.append(etc.getAbsolutePath()).append(FILE_SEPARATOR).append(CLASSPATH_SEPARATOR);
        }
        sb.append(commonLibJars);
        sb.append(jarsDir.getAbsolutePath()).append(FILE_SEPARATOR).append(JARS_WILDCARD);

        // add extralibs if avail
        if (librariesExtraDir != null) {
          File libExtraDir = new File(librariesExtraDir, libDir.getName());
          if (libExtraDir.exists()) {
            File extraJarsDir = new File(libExtraDir, STAGE_LIB_JARS_DIR);
            if (extraJarsDir.exists()) {
              sb.append(CLASSPATH_SEPARATOR).append(extraJarsDir.getAbsolutePath()).append(FILE_SEPARATOR).
                  append(JARS_WILDCARD);
            }
            File extraEtc = new File(libExtraDir, STAGE_LIB_CONF_DIR);
            if (extraEtc.exists()) {
              sb.append(CLASSPATH_SEPARATOR).append(extraEtc.getAbsolutePath());
            }
          }
        }

        map.put(libDir.getParentFile().getName() + FILE_SEPARATOR + libDir.getName(), getClasspathUrls(sb.toString()));
      }
    } else {
      throw new IllegalArgumentException(String.format(MISSING_STAGE_LIBRARIES_DIR_MSG, baseDir));
    }
    return map;
  }
public static Map<String, List<URL>> getStageLibrariesClasspaths(String stageLibrariesDir, String librariesExtraDir,
      final Set<String> stageLibs, String libsCommonLibDir) throws Exception {
    Map<String, List<URL>> map = new LinkedHashMap<String, List<URL>>();

    File baseDir = new File(stageLibrariesDir).getAbsoluteFile();
    if (baseDir.exists()) {
      File[] libDirs = baseDir.listFiles(createStageLibFilter(stageLibs));
      StringBuilder commonLibJars = new StringBuilder();
      if (libsCommonLibDir != null) {
        commonLibJars.append(new File(libsCommonLibDir).getAbsolutePath()).append(FILE_SEPARATOR).append(JARS_WILDCARD).
            append(CLASSPATH_SEPARATOR);
      }
      for (File libDir : libDirs) {
        File jarsDir = new File(libDir, STAGE_LIB_JARS_DIR);
        File etc = new File(libDir, STAGE_LIB_CONF_DIR);
        if (!jarsDir.exists()) {
          throw new IllegalArgumentException(String.format(MISSING_STAGE_LIB_JARS_DIR_MSG, libDir));
        }
        StringBuilder sb = new StringBuilder();
        if (etc.exists()) {
          sb.append(etc.getAbsolutePath()).append(FILE_SEPARATOR).append(CLASSPATH_SEPARATOR);
        }
        sb.append(commonLibJars);
        sb.append(jarsDir.getAbsolutePath()).append(FILE_SEPARATOR).append(JARS_WILDCARD);

        // add extralibs if avail
        if (librariesExtraDir != null) {
          File libExtraDir = new File(librariesExtraDir, libDir.getName());
          if (libExtraDir.exists()) {
            File extraJarsDir = new File(libExtraDir, STAGE_LIB_JARS_DIR);
            if (extraJarsDir.exists()) {
              sb.append(CLASSPATH_SEPARATOR).append(extraJarsDir.getAbsolutePath()).append(FILE_SEPARATOR).
                  append(JARS_WILDCARD);
            }
            File extraEtc = new File(libExtraDir, STAGE_LIB_CONF_DIR);
            if (extraEtc.exists()) {
              sb.append(CLASSPATH_SEPARATOR).append(extraEtc.getAbsolutePath());
            }
          }
        }

        map.put(libDir.getParentFile().getName() + FILE_SEPARATOR + libDir.getName(), getClasspathUrls(sb.toString()));
      }
    } else {
      throw new IllegalArgumentException(String.format(MISSING_STAGE_LIBRARIES_DIR_MSG, baseDir));
    }
    return map;
  }
public static Map < String , List < URL > > getStageLibrariesClasspaths ( String stageLibrariesDir , String librariesExtraDir , final Set < String > stageLibs , String libsCommonLibDir ) throws Exception { Map < String , List < URL > > map = new LinkedHashMap < String , List < URL > > ( ) ; File baseDir = new File ( stageLibrariesDir ) . getAbsoluteFile ( ) ; if ( baseDir . exists ( ) ) { File [ ] libDirs = baseDir . listFiles ( createStageLibFilter ( stageLibs ) ) ; StringBuilder commonLibJars = new StringBuilder ( ) ; if ( libsCommonLibDir != null ) { commonLibJars . append ( new File ( libsCommonLibDir ) . getAbsolutePath ( ) ) . append ( FILE_SEPARATOR ) . append ( JARS_WILDCARD ) . append ( CLASSPATH_SEPARATOR ) ; } for ( File libDir : libDirs ) { File jarsDir = new File ( libDir , STAGE_LIB_JARS_DIR ) ; File etc = new File ( libDir , STAGE_LIB_CONF_DIR ) ; if ( ! jarsDir . exists ( ) ) { throw new IllegalArgumentException ( String . format ( MISSING_STAGE_LIB_JARS_DIR_MSG , libDir ) ) ; } StringBuilder sb = new StringBuilder ( ) ; if ( etc . exists ( ) ) { sb . append ( etc . getAbsolutePath ( ) ) . append ( FILE_SEPARATOR ) . append ( CLASSPATH_SEPARATOR ) ; } sb . append ( commonLibJars ) ; sb . append ( jarsDir . getAbsolutePath ( ) ) . append ( FILE_SEPARATOR ) . append ( JARS_WILDCARD ) ; // add extralibs if avail if ( librariesExtraDir != null ) { File libExtraDir = new File ( librariesExtraDir , libDir . getName ( ) ) ; if ( libExtraDir . exists ( ) ) { File extraJarsDir = new File ( libExtraDir , STAGE_LIB_JARS_DIR ) ; if ( extraJarsDir . exists ( ) ) { sb . append ( CLASSPATH_SEPARATOR ) . append ( extraJarsDir . getAbsolutePath ( ) ) . append ( FILE_SEPARATOR ) . append ( JARS_WILDCARD ) ; } File extraEtc = new File ( libExtraDir , STAGE_LIB_CONF_DIR ) ; if ( extraEtc . exists ( ) ) { sb . append ( CLASSPATH_SEPARATOR ) . append ( extraEtc . getAbsolutePath ( ) ) ; } } } map . put ( libDir . getParentFile ( ) . getName ( ) + FILE_SEPARATOR + libDir . getName ( ) , getClasspathUrls ( sb . toString ( ) ) ) ; } } else { throw new IllegalArgumentException ( String . format ( MISSING_STAGE_LIBRARIES_DIR_MSG , baseDir ) ) ; } return map ; }
Visible for testing
Visible for testing