def expand_jars(directories)
      # If there are jar files, then the file list is the sorted jar files.
      # Otherwise, the file list is a singleton directory array.
      expanded = directories.map do |dir|
        jars = Dir[File.join(dir , "**", "*.jar")].sort
        jars.empty? ? [dir] : jars
      end
      expanded.flatten
    end
def expand_jars(directories)
      # If there are jar files, then the file list is the sorted jar files.
      # Otherwise, the file list is a singleton directory array.
      expanded = directories.map do |dir|
        jars = Dir[File.join(dir , "**", "*.jar")].sort
        jars.empty? ? [dir] : jars
      end
      expanded.flatten
    end
Expands the given directories to include the contained jar files.
 If a directory contains jar files, then the jar files are included in
 the resulting array. Otherwise, the directory itself is included in
 the resulting array.

 @param [<String>] directories the directories containing jars to add
 @return [<String>] each directory or its jars