public void update(Settings settings, File settingsFile) throws ManipulationException {
    try {
      Settings defaultSettings = new Settings();

      if (settingsFile.exists()) {
        DefaultSettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest();
        settingsRequest.setGlobalSettingsFile(settingsFile);
        defaultSettings = settingsBuilder.build(settingsRequest).getEffectiveSettings();
      }

      for (Profile profile : settings.getProfiles()) {
        Iterator<Profile> i = defaultSettings.getProfiles().iterator();
        while (i.hasNext()) {
          if (i.next().getId().equals(profile.getId())) {
            i.remove();
          }
        }
        defaultSettings.addProfile(profile);
      }
      for (String activeProfile : settings.getActiveProfiles()) {
        Iterator<String> i = defaultSettings.getActiveProfiles().iterator();
        while (i.hasNext()) {
          if (i.next().equals(activeProfile)) {
            i.remove();
          }
        }
        defaultSettings.addActiveProfile(activeProfile);
      }
      for (Mirror mirror : settings.getMirrors()) {
        defaultSettings.addMirror(mirror);
      }
      for (Proxy proxy : settings.getProxies()) {
        defaultSettings.addProxy(proxy);
      }
      for (Server server : settings.getServers()) {
        defaultSettings.addServer(server);
      }
      for (String pluginGroup : settings.getPluginGroups()) {
        defaultSettings.addPluginGroup(pluginGroup);
      }
      if (settings.getLocalRepository() != null) {
        defaultSettings.setLocalRepository(settings.getLocalRepository());
      }

      write(defaultSettings, settingsFile);
    } catch (SettingsBuildingException e) {
      throw new ManipulationException(
          "Failed to build existing settings.xml for repo removal backup.",
          e,
          settingsFile,
          e.getMessage());
    }
  }
  public Model loadModel(
      Task task, File pomFile, boolean local, RemoteRepositories remoteRepositories) {
    RepositorySystemSession session = getSession(task, null);

    remoteRepositories =
        remoteRepositories == null
            ? AetherUtils.getDefaultRepositories(project)
            : remoteRepositories;

    List<org.sonatype.aether.repository.RemoteRepository> repositories =
        ConverterUtils.toRepositories(
            task.getProject(), session, remoteRepositories, getRemoteRepoMan());

    ModelResolver modelResolver =
        new AntModelResolver(session, "project", getSystem(), getRemoteRepoMan(), repositories);

    Settings settings = getSettings();

    try {
      DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
      request.setLocationTracking(true);
      request.setProcessPlugins(false);
      if (local) {
        request.setPomFile(pomFile);
        request.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_STRICT);
      } else {
        request.setModelSource(new FileModelSource(pomFile));
        request.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
      }
      request.setSystemProperties(getSystemProperties());
      request.setUserProperties(getUserProperties());
      request.setProfiles(SettingsUtils.convert(settings.getProfiles()));
      request.setActiveProfileIds(settings.getActiveProfiles());
      request.setModelResolver(modelResolver);
      return modelBuilder.build(request).getEffectiveModel();
    } catch (ModelBuildingException e) {
      throw new BuildException("Could not load POM " + pomFile + ": " + e.getMessage(), e);
    }
  }