private RepositorySystemSession newSession(RepositorySystem system) {
      LocalRepository localRepo = new LocalRepository(localRepositoryDirectory);
      LocalRepositoryManager localRepositoryManager = system.newLocalRepositoryManager(localRepo);

      Map<String, String> systemProps = assembleSystemProps();

      if (settings.offlineMode()) {
        DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
        session.setOffline(true);
        session.setSystemProperties(systemProps);
        session.setLocalRepositoryManager(localRepositoryManager);
        return session;
      }

      MavenRepositorySystemSession session = new MavenRepositorySystemSession();
      session.setOffline(false);
      session.setRepositoryListener(logger.listener());
      session.setChecksumPolicy(RepositoryPolicy.CHECKSUM_POLICY_FAIL);
      session.setIgnoreInvalidArtifactDescriptor(false);
      session.setIgnoreMissingArtifactDescriptor(false);
      session.setNotFoundCachingEnabled(false);
      session.setTransferErrorCachingEnabled(false);
      session.setUpdatePolicy(RepositoryPolicy.UPDATE_POLICY_ALWAYS);
      session.setSystemProperties(systemProps);
      session.setLocalRepositoryManager(localRepositoryManager);
      return session;
    }