Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titletest.groovy
themeMidnight
languagegroovy
import java.util.zip.*


def printClassPath(classLoader, pattern) {
  println "$classLoader"

   classLoader.URLs.findAll { 
    it.toExternalForm().endsWith(".jar")
  }.each { url ->
    def f = new File(url.toURI())
    try {
      boolean firstTime = true
      new ZipFile(f).entries().findAll { it.name =~ pattern }.each { ZipEntry entry -> 
        if (firstTime) {
          println "  > $url"
          firstTime = false
        }
        println "    > ${entry.name}"  
      }
    } catch (Throwable e) {
      println "Error opening jar file ${f}, message: ${e.message}"
    }
  }

   // if we have a parent, make a recursive call to search for the class there also
  if (classLoader.parent) printClassPath(classLoader.parent, pattern)
}


// call the method with the current classpath, look for classes matching 'http'
// (?i) switches on case insensitive regex matching
// the / .. / is a groovy string syntax suitable for regex handling
printClassPath this.class.classLoader, /(?i)http/
 

...