package net.sourceforge.javautil.classloader.util;
import java.util.List;
import net.sourceforge.javautil.classloader.impl.ClassInfo;
import net.sourceforge.javautil.classloader.impl.ClassSearchInfo;
import net.sourceforge.javautil.classloader.impl.PackageSearchInfo;
import net.sourceforge.javautil.classloader.source.ClassSource;
import net.sourceforge.javautil.classloader.source.LibDirectoryClassSource;
import net.sourceforge.javautil.common.io.impl.SystemDirectory;
/**
* This will allow one to search for a package using all the libraries found in a particular directory recursively.
*
* @author elponderador
* @author $Author$
* @version $Id$
*/
public class PackageSearch {
/**
* The first argument should be the directory to search in.
* The second argument should be the package name to search for.
*
* @param args Command line arguments
*/
public static void main (String[] args) {
if (args.length != 2) {
System.err.println("Please provide the library directory and the package name to search for.");
} else {
System.out.println("Searching for " + args[1] + " in " + args[0]);
LibDirectoryClassSource lib = new LibDirectoryClassSource(new SystemDirectory(args[0]), true);
List<ClassSource> sources = lib.getAllNonCompositeSources();
PackageSearchInfo info = new PackageSearchInfo(args[1]);
for (ClassSource source : sources) {
if (source.hasPackage(info)) {
System.out.println("Found in " + source);
}
}
}
}
}