public static File getIvySettingsFile() throws IOException {
    URL settingsUrl = Thread.currentThread().getContextClassLoader().getResource(IVY_SETTINGS_FILE_NAME);
    if (settingsUrl == null) {
      throw new IOException("Failed to find " + IVY_SETTINGS_FILE_NAME + " from class path");
    }

    // Check if settingsUrl is file on classpath
    File ivySettingsFile = new File(settingsUrl.getFile());
    if (ivySettingsFile.exists()) {
      // can access settingsUrl as a file
      return ivySettingsFile;
    }

    // Create temporary Ivy settings file.
    ivySettingsFile = File.createTempFile("ivy.settings", ".xml");
    ivySettingsFile.deleteOnExit();

    try (OutputStream os = new BufferedOutputStream(new FileOutputStream(ivySettingsFile))) {
      Resources.copy(settingsUrl, os);
    }

    return ivySettingsFile;
  }
public static File getIvySettingsFile ( ) throws IOException { URL settingsUrl = Thread . currentThread ( ) . getContextClassLoader ( ) . getResource ( IVY_SETTINGS_FILE_NAME ) ; if ( settingsUrl == null ) { throw new IOException ( "Failed to find " + IVY_SETTINGS_FILE_NAME + " from class path" ) ; } File ivySettingsFile = new File ( settingsUrl . getFile ( ) ) ; if ( ivySettingsFile . exists ( ) ) { return ivySettingsFile ; } ivySettingsFile = File . createTempFile ( "ivy.settings" , ".xml" ) ; ivySettingsFile . deleteOnExit ( ) ; try ( OutputStream os = new BufferedOutputStream ( new FileOutputStream ( ivySettingsFile ) ) ) { Resources . copy ( settingsUrl , os ) ; } return ivySettingsFile ; }
Get ivy settings file from classpath