public void initIvy ( ) throws ParseException , IOException , ConfigurationException { if ( ivy == null ) { // creates clear ivy settings IvySettings ivySettings = new IvySettings ( ) ; File settingsFile = new File ( IVY_SETTINGS_FILE ) ; if ( settingsFile . exists ( ) ) { ivySettings . load ( settingsFile ) ; } else { URL settingsURL = ClassLoader . getSystemResource ( IVY_SETTINGS_FILE ) ; if ( settingsURL == null ) { // file not found in System classloader, we try the current one settingsURL = this . getClass ( ) . getClassLoader ( ) . getResource ( IVY_SETTINGS_FILE ) ; // extra validation to avoid uncontrolled NullPointerException // when invoking toURI() if ( settingsURL == null ) throw new ConfigurationException ( "Ivy settings file (" + IVY_SETTINGS_FILE + ") could not be found in classpath" ) ; } ivySettings . load ( settingsURL ) ; } // creates an Ivy instance with settings ivy = Ivy . newInstance ( ivySettings ) ; } ivyfile = File . createTempFile ( "ivy" , ".xml" ) ; ivyfile . deleteOnExit ( ) ; applyVerbose ( ) ; String [ ] confs = new String [ ] { "default" } ; resolveOptions = new ResolveOptions ( ) . setConfs ( confs ) ; if ( isOffLine ) { resolveOptions = resolveOptions . setUseCacheOnly ( true ) ; } else { Map < String , Object > params = configuration . getParameters ( ) ; if ( params != null ) { Object value = params . get ( "offline" ) ; if ( value != null ) { String offlineOpt = value . toString ( ) ; if ( offlineOpt != null ) { boolean offline = Boolean . parseBoolean ( offlineOpt ) ; if ( offline ) { resolveOptions = resolveOptions . setUseCacheOnly ( true ) ; } } } } } }
Ivy configuration initialization