in command.line/java/com/jetbrains/teamcity/command/CommandRegistry.java [53:97]
private Collection<ICommand> findCommand() {
final HashSet<ICommand> result = new HashSet<ICommand>();
if (getClass().getClassLoader() instanceof URLClassLoader) {
final URLClassLoader loader = (URLClassLoader) getClass().getClassLoader();
for (URL url : loader.getURLs()) {
final File file = new File(url.getFile());
if (file.isDirectory()) {
final ArrayList<File> children = new ArrayList<File>();
FileUtil.collectMatchedFiles(file, Pattern.compile(".*\\.class"), children);
for (File child : children) {
if (isSimpleClass(child.getPath())) {// do not touch inner classes
final String classFilePath = FileUtil.getRelativePath(file, child);
final String className = getClassName(classFilePath);
final ICommand instance = createCommand(className);
if (instance != null) {
result.add(instance);
}
}
}
} else {
// jars
try {
final JarFile jar = new JarFile(file);
if (!isCommandExtensionJar(jar.getName())) {
Debug.getInstance().debug(CommandRegistry.class, MessageFormat.format("New commans jar found: {0}", jar.getName()));
final Enumeration<JarEntry> entries = jar.entries();
while (entries.hasMoreElements()) {
final String fileName = entries.nextElement().getName();
if (isSimpleClass(fileName)) {
final String className = getClassName(fileName);
final ICommand instance = createCommand(className);
if (instance != null) {
result.add(instance);
}
}
}
}
} catch (IOException e) {
// do nothing
}
}
}
}
return result;
}