Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Add some library support to speed up looking for Java 1.7 changes in javadoc and simultaneously shorten the script a bit. Inspired by http://marxsoftware.blogspot.com/2011/03/jdk-7-new-interfaces-classes-enums-and.html
#!/usr/bin/env groovy
// searchJdk7ApiDocsForSince17.groovy
@Grab(group='org.ccil.cowan.tagsoup', module='tagsoup', version='0.9.7')
@Grab(group='org.codehaus.gpars', module='gpars', version='0.11')
import groovyx.gpars.GParsPool
import java.util.concurrent.atomic.AtomicInteger
def xml = new XmlParser(new org.ccil.cowan.tagsoup.Parser()).parse("http://download.oracle.com/javase/7/docs/api/allclasses-frame.html")
def urls = xml.'**'.a.@href
AtomicInteger numUrlsProcessed = new AtomicInteger()
AtomicInteger numUrlsMatching = new AtomicInteger()
println "${urls.size()} total URLs to search for 1.7 text."
def withJava7 = new ArrayList<String>()
GParsPool.withPool(4){
urls.eachParallel
{
def match = false
numUrlsProcessed.getAndIncrement()
def eachUrl = "http://download.oracle.com/javase/7/docs/api/${it}"
try
{
if (eachUrl.toURL().text.contains("1.7"))
{
numUrlsMatching.getAndIncrement()
match = true
withJava7.add(it)
}
}
catch (Exception ex) // catch HTTP problems like 404 or 504.
{
println "ERROR trying to acces ${eachUrl}: ${ex.toString()}"
}
println "${numUrlsMatching} of ${numUrlsProcessed} match 1.7 (${match ? eachUrl : '-'})!"
}
}
println "Javadoc files with 1.7: "
withJava7.each
{
println "\t${it}"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.