package com.tactfactory.harmony.dependencies.libraries;

import java.io.File;
import java.io.FileFilter;
import java.util.HashMap;
import java.util.Map;

import com.tactfactory.harmony.utils.ConsoleUtils;

/**
 * Library Pool. Contains all the libraries brought by 
 * the core and all the bundles.
 */
public class LibraryPool {
	/** File filter to parse only libraries. */
	private final FileFilter filter = new FileFilter() {
		
		@Override
		public boolean accept(File pathname) {
			return pathname.isDirectory() 
					|| pathname.getName().endsWith(".jar");
		}
	};
	/** Map of all the libraries <FileName, File>. */
	private final Map<String, File> pool = new HashMap<String, File>();
	
	/**
	 * Get the File pointing to the library file.
	 * @param fileName The filename of the library
	 * @return The library File
	 */
	public File getLibrary(String fileName) {
		return this.pool.get(fileName);
	}
	
	/**
	 * Parse the given file to find all the available libraries in 
	 * order to fill the pool.
	 * @param file The folder to parse
	 */
	public void parseLibraries(File file) {
		if (file.exists()) {
			if (file.isDirectory()) {
				File[] files = file.listFiles(this.filter);
				for (File f : files) {
					this.parseLibraries(f);
				}
			} else if (file.isFile()) {
				String fileName = file.getName();
				if (this.pool.get(fileName) != null) {
					ConsoleUtils.displayWarning(
							"The library " 
							+ fileName
							+ " has been found multiple times."
							+ "Keeping "
							+ this.pool.get(fileName).getAbsolutePath());
				} else {
					ConsoleUtils.displayDebug("Adding library " + fileName
							+ " to the pool.");
					this.pool.put(fileName, file);
				}
			}
			
		}
	}
}

@@ -481,16 +481,18 @@
 e) %7B%0A%09%09%09
+//
 return p
@@ -517,16 +517,18 @@
 y() %0A%09%09%09
+//
 %09%09%7C%7C pat
@@ -561,16 +561,102 @@
 .jar%22);%0A
+%09%09%09return pathname.isDirectory()%0A%09%09%09%09%09%7C%7C pathname.getAbsolutePath().contains(%22lib/%22);%0A
 %09%09%7D%0A%09%7D;%0A
@@ -1377,24 +1377,20 @@
 %09String 
-fileName
+path
  = file.
@@ -1392,21 +1392,93 @@
 file.get
-Name(
+AbsolutePath();%0A%09%09%09%09String fileName = path.substring(path.indexOf(%22lib/%22) + 4
 );%0A%09%09%09%09i

Fix #2899