private Properties loadProperties ( File baseDir , Properties currentProperties , String key , boolean override ) throws IOException { Properties loadedProperties = new Properties ( ) ; String include = ( String ) currentProperties . remove ( key ) ; if ( ! StringUtils . isNullOrEmpty ( include ) ) { // allow for multiples List < String > names = StringUtils . getList ( include , DEFAULT_LIST_DELIMITER ) ; for ( String name : names ) { if ( StringUtils . isNullOrEmpty ( name ) ) { continue ; } // interpolate any variables final String fileName = interpolateString ( name ) ; // try co-located File file = new File ( baseDir , fileName ) ; if ( ! file . exists ( ) ) { // try absolute path file = new File ( fileName ) ; } if ( ! file . exists ( ) ) { log . warn ( "failed to locate {}" , file ) ; continue ; } // load properties log . debug ( "loading {} settings from {}" , key , file ) ; try ( FileInputStream iis = new FileInputStream ( file ) ) { loadedProperties . load ( iis ) ; } // read nested properties loadedProperties = loadProperties ( file . getParentFile ( ) , loadedProperties , key , override ) ; } } Properties merged = new Properties ( ) ; if ( override ) { // "override" settings overwrite the current properties merged . putAll ( currentProperties ) ; merged . putAll ( loadedProperties ) ; } else { // "include" settings are overwritten by the current properties merged . putAll ( loadedProperties ) ; merged . putAll ( currentProperties ) ; } return merged ; }
Recursively read referenced properties files .