class RemoveSnapshotsTask extends RepositoryTaskSupport {

  @Override
  protected void execute(final Repository repository) {
    if (hasBeenProcessed(repository)) {
      log.debug("Skipping repository '{}'; it has already been processed", repository.getName());
      return;
    }

    if (isGroupRepository(repository)) {
      markProcessed(repository); // nothing to do for the group itself

      repository.facet(GroupFacet.class).members().stream().filter(this::appliesTo).forEach(this::execute);
    }
    else {
      log.info("Executing removal of snapshots on repository '{}'", repository.getName());

      TaskConfiguration config = getConfiguration();
      RemoveSnapshotsConfig removeSnapshotsConfig = new RemoveSnapshotsConfig(
          config.getInteger(MINIMUM_SNAPSHOT_RETAINED_COUNT, 1),
          config.getInteger(SNAPSHOT_RETENTION_DAYS, 30),
          config.getBoolean(REMOVE_IF_RELEASED, false),
          config.getInteger(GRACE_PERIOD, -1));
      repository.facet(RemoveSnapshotsFacet.class).removeSnapshots(removeSnapshotsConfig);
      markProcessed(repository);
    }
  }

  @Inject public  RemoveSnapshotsTask(@Named(Maven2Format.NAME) final Format maven2Format);

}