code: public DefaultRepositorySystemSession getSession(final Settings settings, boolean legacyLocalRepository) {
          DefaultRepositorySystemSession session = new DefaultRepositorySystemSession();
  
          MavenManagerBuilder builder = new MavenManagerBuilder(system, settings);
  
          session.setLocalRepositoryManager(builder.localRepositoryManager(session, legacyLocalRepository));
          session.setWorkspaceReader(builder.workspaceReader());
          session.setTransferListener(builder.transferListerer());
          session.setRepositoryListener(builder.repositoryListener());
          session.setOffline(settings.isOffline());
          session.setMirrorSelector(builder.mirrorSelector());
          session.setProxySelector(builder.proxySelector());
          session.setDependencyManager(builder.dependencyManager());
          session.setArtifactDescriptorPolicy(builder.artifactRepositoryPolicy());
  
          session.setDependencyTraverser(builder.dependencyTraverser());
          session.setDependencyGraphTransformer(builder.dependencyGraphTransformer());
  
          // set artifact stereotypes
          session.setArtifactTypeRegistry(builder.artifactTypeRegistry());
  
          // set system properties for interpolation
          session.setSystemProperties(SecurityActions.getProperties());
          session.setConfigProperties(SecurityActions.getProperties());
  
          return session;
      }
docs: Spawns a working session from the repository system. This is used to as environment for execution of Maven
  commands
  
  @param settings
  A configuration of current session
  @param legacyLocalRepository
  Whether to ignore origin of artifacts in local repository; defaults to false
  @return A working session spawned from the repository system.