if (path == null) {
throw new BuildException("Missing nested <classpath>!");
}
// Normalize the reference directory (containing the jar)
final FileUtils fileUtils = FileUtils.getFileUtils();
dir = fileUtils.normalize(dir.getAbsolutePath());
// Create as many directory prefixes as parent levels to traverse,
// in addition to the reference directory itself
File currDir = dir;
String[] dirs = new String[maxParentLevels + 1];
for (int i = 0; i < maxParentLevels + 1; ++i) {
dirs[i] = currDir.getAbsolutePath() + File.separatorChar;
currDir = currDir.getParentFile();
if (currDir == null) {
maxParentLevels = i + 1;
break;
}
}
String[] elements = path.list();
StringBuffer buffer = new StringBuffer();
StringBuffer element = new StringBuffer();
for (int i = 0; i < elements.length; ++i) {
// Normalize the current file
File pathEntry = new File(elements[i]);
pathEntry = fileUtils.normalize(pathEntry.getAbsolutePath());
String fullPath = pathEntry.getAbsolutePath();
// Find the longest prefix shared by the current file
// and the reference directory.
String relPath = null;