*** apache-ant-1.6.1/src/main/org/apache/tools/ant/taskdefs/ImportTask.java Thu Feb 12 14:33:24 2004 --- BuildProcess/ImportFloat.java Thu Apr 15 09:26:20 2004 *************** *** 60,65 **** --- 60,66 ---- public class ImportTask extends Task { private String file; private boolean optional; + private boolean find = false; private static final FileUtils FILE_UTILS = FileUtils.newFileUtils(); /** *************** *** 73,78 **** --- 74,90 ---- } /** + * sets the float attribute + * + * @param float if true, traverses the directory hierarchy upwards + * to locate the actual file to import. + * Default is false. + */ + public void setFloat(boolean find) { + this.find = true; + } + + /** * the name of the file to import. How relative paths are resolved is still * in flux: use absolute paths for safety. * @param file the name of the file *************** *** 120,126 **** // *not* the current directory (same as entity includes). File buildFileParent = new File(buildFile.getParent()); ! File importedFile = FILE_UTILS.resolveFile(buildFileParent, file); if (!importedFile.exists()) { String message = --- 132,163 ---- // *not* the current directory (same as entity includes). File buildFileParent = new File(buildFile.getParent()); ! File importedFile = null; ! ! /* Search for the import file towards the root of the file ! * system (like the --find command line option for build ! * files). ! * Note that is you specify foo/bar.xml, the search will be for ! * foo/bar.xml, ../foo/bar.xml, ../../foo/bar.xml, and so on. ! * This makes it possible to import files from a higher level ! * sibling directory. ! */ ! ! File findFile = new File(file); ! if ( find && !findFile.isAbsolute() ) { ! File parent = buildFileParent; ! while ( parent != null ) { ! findFile = new File(parent, file); ! if ( findFile.exists() ) { ! importedFile = findFile; ! break; ! } ! parent = parent.getParentFile(); ! } ! } ! ! if ( importedFile == null ) ! importedFile = FILE_UTILS.resolveFile(buildFileParent, file); if (!importedFile.exists()) { String message = *** apache-ant-1.6.1/docs/manual/CoreTasks/import.html Thu Feb 12 14:33:14 2004 --- BuildProcess/ant-manual-import.html Thu Apr 15 09:16:58 2004 *************** *** 93,98 **** --- 93,108 ---- No + + float
+ + + if true, locate the file to be imported by traversing the file + system towards the root. + Default is false.
+ + No +