File findSdkHome ( final String path ) { File dotCeylon = new File ( path ) ; // or some other directory File [ ] homes = null ; if ( ! dotCeylon . exists ( ) ) { return null ; } else { homes = dotCeylon . listFiles ( new FilenameFilter ( ) { @ Override public boolean accept ( final File dir , final String name ) { if ( name . startsWith ( "ceylon-1." ) ) { return true ; } return false ; } } ) ; } if ( homes . length == 0 ) { return null ; } else if ( homes . length == 1 & homes [ 0 ] . isDirectory ( ) ) { return homes [ 0 ] ; } else { Arrays . sort ( homes ) ; if ( homes [ homes . length - 1 ] . isDirectory ( ) ) { return homes [ homes . length - 1 ] ; } else { return null ; } } }
Find Ceylon SDK home in a folder in the form of ceylon - 1 . x . x .