private static String determineLocalRoot ( ) throws IOException { // Determine current working directory File dir = new File ( "." ) ; // Traverse up the directory hierarchy while ( dir != null && dir . exists ( ) && dir . isDirectory ( ) ) { File wyf = new File ( dir + File . separator + "wy.toml" ) ; if ( wyf . exists ( ) ) { return dir . getPath ( ) ; } // Traverse back up the directory hierarchy looking for a suitable directory. dir = dir . getParentFile ( ) ; } // If we get here then it means we didn't find a root, therefore just use // current directory. return "." ; }
Determine where the root of this project is . This is the nearest enclosing directory containing a wy . toml file . The point is that we may be operating in some subdirectory of the project and want the tool to automatically search out the real root for us .